warp.spatial_dot#

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

Return the dot product of two 6D spatial vectors.

A wrench dotted with a twist gives instantaneous power. Both arguments must have the same scalar type.

Parameters:
  • a – First spatial vector.

  • b – Second spatial vector.

Returns:

The dot product, as a scalar of the same type as the arguments.

Example

@wp.kernel
def compute_power(
    twists: wp.array[wp.spatial_vector],
    wrenches: wp.array[wp.spatial_vector],
    out: wp.array[float],
):
    i = wp.tid()
    out[i] = wp.spatial_dot(wrenches[i], twists[i])

# spinning at 2 rad/s about z under a torque of 3 N.m about z
twists = wp.array([wp.spatial_vector(0.0, 0.0, 2.0, 1.0, 0.0, 0.0)], dtype=wp.spatial_vector)
wrenches = wp.array([wp.spatial_vector(0.0, 0.0, 3.0, 0.0, 0.0, 0.0)], dtype=wp.spatial_vector)
out = wp.empty(1, dtype=float)
wp.launch(compute_power, dim=1, inputs=[twists, wrenches], outputs=[out])
print(out.numpy())
[6.]