warp.spatial_cross#

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

Return the spatial cross product of a and b, treating both as twists.

The operation is antisymmetric: spatial_cross(a, b) == -spatial_cross(b, a). It computes velocity-product terms used in spatial-acceleration calculations for moving coordinate frames. Use spatial_cross_dual() when b is a wrench. Both arguments must have the same scalar type.

Parameters:
  • a – First spatial vector, interpreted as a twist.

  • b – Second spatial vector, interpreted as a twist.

Returns:

The spatial vector (w_a x w_b, v_a x w_b + w_a x v_b), where a = (w_a, v_a) and b = (w_b, v_b).

Example

@wp.kernel
def compute_spatial_cross(
    a: wp.array[wp.spatial_vector],
    b: wp.array[wp.spatial_vector],
    out: wp.array[wp.spatial_vector],
):
    i = wp.tid()
    out[i] = wp.spatial_cross(a[i], b[i])

a = wp.array([wp.spatial_vector(0.0, 0.0, 1.0, 0.0, 0.0, 0.0)], dtype=wp.spatial_vector)
b = wp.array([wp.spatial_vector(0.0, 0.0, 0.0, 1.0, 0.0, 0.0)], dtype=wp.spatial_vector)
out = wp.empty(1, dtype=wp.spatial_vector)
wp.launch(compute_spatial_cross, dim=1, inputs=[a, b], outputs=[out])
print(out.numpy())
[[0. 0. 0. 0. 1. 0.]]