warp.transform_multiply#
- warp.transform_multiply( ) Transformation[Float]#
Return the composition of transformations
aandb, applyingbbeforea.With unit quaternions, the operation is associative but not commutative, and
transform_point(a * b, x) == transform_point(a, transform_point(b, x)). Non-unit quaternions may distort and invalidate these identities.- Parameters:
a – Outer transformation, applied second.
b – Inner transformation, applied first.
- Returns:
The composed transformation, with translation
a.p + quat_rotate(a.q, b.p)and rotationa.q * b.q.
Example
@wp.kernel def compose( a: wp.array[wp.transform], b: wp.array[wp.transform], out: wp.array[wp.transform] ): i = wp.tid() out[i] = wp.transform_multiply(a[i], b[i]) # a turns a quarter turn about the z axis and shifts along x, b only shifts along x a = wp.array([wp.transform(wp.vec3(1.0, 0.0, 0.0), wp.quat_rpy(0.0, 0.0, wp.pi / 2.0))], dtype=wp.transform) b = wp.array([wp.transform(wp.vec3(2.0, 0.0, 0.0), wp.quat_identity())], dtype=wp.transform) out = wp.empty(1, dtype=wp.transform) wp.launch(compose, dim=1, inputs=[a, b], outputs=[out]) print(np.round(out.numpy(), 3))
[[1. 2. 0. 0. 0. 0.707 0.707]]