warp.quat_rpy#
- warp.quat_rpy(roll: Float, pitch: Float, yaw: Float) Quaternion[Float]#
Return the rotation quaternion for the given roll, pitch, and yaw angles in radians.
The rotations are applied in the order roll, pitch, yaw about the fixed axes (extrinsic x-y-z), which is equivalent to applying yaw, pitch, and then roll about the rotating axes (intrinsic z-y’-x’’).
- Parameters:
roll – Rotation angle about the
xaxis, in radians.pitch – Rotation angle about the
yaxis, in radians.yaw – Rotation angle about the
zaxis, in radians.
- Returns:
The unit quaternion
qz * qy * qx, whereqx,qy, andqzare the rotations ofroll,pitch, andyawabout their axes.
Example
@wp.kernel def orient(points: wp.array[wp.vec3], out: wp.array[wp.vec3]): i = wp.tid() # quarter turn about x (roll), then a quarter turn about z (yaw) q = wp.quat_rpy(wp.pi / 2.0, 0.0, wp.pi / 2.0) out[i] = wp.quat_rotate(q, points[i]) # roll maps (1, 2, 3) to (1, -3, 2), then yaw maps that to (3, 1, 2) points = wp.array([wp.vec3(1.0, 2.0, 3.0)], dtype=wp.vec3) out = wp.empty(1, dtype=wp.vec3) wp.launch(orient, dim=1, inputs=[points], outputs=[out]) print(np.round(out.numpy(), 3))
[[3. 1. 2.]]