warp.spatial_cross_dual#

warp.spatial_cross_dual(
a: Vector[Float, Literal[6]],
b: Vector[Float, Literal[6]],
) Vector[Float, Literal[6]]#
  • Kernel: true
  • Python: true
  • Differentiable: true

Return the spatial force cross product of twist a and wrench b.

This is the wrench counterpart of spatial_cross(): the second operand and result are both wrenches. “Dual” refers to the wrench-twist dot product, which computes mechanical power. The operation is not antisymmetric, so its operands are not interchangeable. Both arguments must have the same scalar type.

Parameters:
  • a – Twist represented as a spatial vector.

  • b – Wrench represented as a spatial vector.

Returns:

The wrench (w x n + v x f, w x f), where a = (w, v) and b = (n, f).

Example

@wp.kernel
def compute_spatial_cross_dual(
    twists: wp.array[wp.spatial_vector],
    wrenches: wp.array[wp.spatial_vector],
    out: wp.array[wp.spatial_vector],
):
    i = wp.tid()
    out[i] = wp.spatial_cross_dual(twists[i], wrenches[i])

twists = wp.array([wp.spatial_vector(0.0, 0.0, 1.0, 1.0, 0.0, 0.0)], dtype=wp.spatial_vector)
wrenches = wp.array([wp.spatial_vector(0.0, 0.0, 0.0, 0.0, 1.0, 0.0)], dtype=wp.spatial_vector)
out = wp.empty(1, dtype=wp.spatial_vector)
wp.launch(compute_spatial_cross_dual, dim=1, inputs=[twists, wrenches], outputs=[out])
print(out.numpy())
[[ 0.  0.  1. -1.  0.  0.]]