warp.spatial_adjoint#

warp.spatial_adjoint(
r: Matrix[Float, Literal[3], Literal[3]],
s: Matrix[Float, Literal[3], Literal[3]],
) Matrix[Float, Literal[6], Literal[6]]#
  • Kernel: true
  • Python: false
  • Differentiable: true

Construct a 6x6 spatial matrix from the two 3x3 blocks r and s.

For a rigid transform (R, p), setting r = R and s = skew(p) * R constructs the matrix that maps twist (w, v) to (R * w, cross(p, R * w) + R * v). Wrenches transform differently from twists; use transform_wrench() to transform them.

Parameters:
  • r – Block placed on both diagonals.

  • s – Block placed in the lower-left corner.

Returns:

The 6x6 block matrix [[r, 0], [s, r]].

Example

@wp.kernel
def build(out: wp.array[wp.spatial_matrix]):
    r = wp.mat33(1.0, 0.0, 0.0,
                 0.0, 1.0, 0.0,
                 0.0, 0.0, 1.0)
    s = wp.mat33(0.0, -3.0, 2.0,
                 3.0, 0.0, -1.0,
                 -2.0, 1.0, 0.0)
    out[0] = wp.spatial_adjoint(r, s)

out = wp.empty(1, dtype=wp.spatial_matrix)
wp.launch(build, dim=1, outputs=[out])
print(out.numpy()[0])
[[ 1.  0.  0.  0.  0.  0.]
 [ 0.  1.  0.  0.  0.  0.]
 [ 0.  0.  1.  0.  0.  0.]
 [ 0. -3.  2.  1.  0.  0.]
 [ 3.  0. -1.  0.  1.  0.]
 [-2.  1.  0.  0.  0.  1.]]