warp.transform_point#
- warp.transform_point( ) Vector[Float, Literal[3]]#
Return
pointtransformed byxform, with rotation applied before translation.xform.qmust have unit length; otherwise the result may distort. Usetransform_vector()to transform directions.- Parameters:
xform – Transformation to apply.
point – Point to transform.
- Returns:
quat_rotate(xform.q, point) + xform.p, equivalent to using homogeneous coordinatew = 1.
Example
@wp.kernel def apply( xform: wp.transform, points: wp.array[wp.vec3], out_points: wp.array[wp.vec3], out_vectors: wp.array[wp.vec3], ): i = wp.tid() out_points[i] = wp.transform_point(xform, points[i]) out_vectors[i] = wp.transform_vector(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(1.0, 2.0, 0.0)], dtype=wp.vec3) out_points = wp.empty(1, dtype=wp.vec3) out_vectors = wp.empty(1, dtype=wp.vec3) wp.launch(apply, dim=1, inputs=[xform, points], outputs=[out_points, out_vectors]) print(np.round(out_points.numpy(), 3)) # rotated and translated print(np.round(out_vectors.numpy(), 3)) # rotated only
[[-2. 1. 5.]] [[-2. 1. 0.]]
- warp.transform_point( ) Vector[Float, Literal[3]]
Return
pointtransformed by the 4x4 matrixmat, using homogeneous coordinatew = 1.The fourth component is discarded without a perspective divide. Matrices that use row-vector conventions, such as those from USD, must be transposed. Use
transform_vector()to transform directions.- Parameters:
mat – Transformation matrix, applied to a column vector.
point – Point to transform.
- Returns:
The first three components of
mat * (point.x, point.y, point.z, 1).
Example
@wp.kernel def apply( mat: wp.mat44, points: wp.array[wp.vec3], out_points: wp.array[wp.vec3], out_vectors: wp.array[wp.vec3], ): i = wp.tid() out_points[i] = wp.transform_point(mat, points[i]) out_vectors[i] = wp.transform_vector(mat, points[i]) # scale by 2 along x and translate by 5 along z mat = wp.mat44(2.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 5.0, 0.0, 0.0, 0.0, 1.0) points = wp.array([wp.vec3(1.0, 2.0, 3.0)], dtype=wp.vec3) out_points = wp.empty(1, dtype=wp.vec3) out_vectors = wp.empty(1, dtype=wp.vec3) wp.launch(apply, dim=1, inputs=[mat, points], outputs=[out_points, out_vectors]) print(out_points.numpy()) # translation included print(out_vectors.numpy()) # translation ignored
[[2. 2. 8.]] [[2. 2. 3.]]