warp.transform_inverse#

warp.transform_inverse(
xform: Transformation[Float],
) Transformation[Float]#
  • Kernel: true
  • Python: true
  • Differentiable: true

Return the inverse of xform.

The inverse maps points transformed by xform back to their original coordinate frame. Because quat_inverse() returns the conjugate, xform.q must have unit length; normalize it first if needed.

Parameters:

xform – Transformation to invert. Its rotation quaternion must have unit length.

Returns:

The inverse transformation, with rotation quat_inverse(xform.q) and translation -quat_rotate(quat_inverse(xform.q), xform.p).

Example

@wp.kernel
def to_local(
    xform: wp.transform, points: wp.array[wp.vec3], out: wp.array[wp.vec3]
):
    i = wp.tid()
    out[i] = wp.transform_point(wp.transform_inverse(xform), points[i])

xform = wp.transform(wp.vec3(0.0, 0.0, 5.0), wp.quat_rpy(0.0, 0.0, wp.pi / 2.0))
points = wp.array([wp.vec3(-2.0, 1.0, 8.0)], dtype=wp.vec3)
out = wp.empty(1, dtype=wp.vec3)
wp.launch(to_local, dim=1, inputs=[xform, points], outputs=[out])
print(np.round(out.numpy(), 3))
[[1. 2. 3.]]