v3d.Transform#
- class visu3d.Transform(**kwargs)[source]#
Bases:
visu3d.dc_arrays.transformation.TransformBase
Affine transformation (Position, rotation and scale of an object).
- R#
Rotation/scale/skewing of the transformation ( [[x0, y0, z0], [x1, y1, z1], [x2, y2, z2]])
- Type:
FloatArray[’*shape 3 3’]
- R: FloatArray['*shape 3 3'] = ((1, 0, 0), (0, 1, 0), (0, 0, 1))#
- t: FloatArray['*shape 3'] = (0, 0, 0)#
- classmethod identity() visu3d.dc_arrays.transformation.Transform [source]#
Returns the identity transform.
- classmethod from_matrix(matrix: etils.enp.array_types.typing.FloatArray) visu3d.dc_arrays.transformation.Transform [source]#
Constructs from a 4x4 transform matrix.
- classmethod from_angle(*, x=None, y=None, z=None) visu3d.dc_arrays.transformation.Transform [source]#
Returns a transformation rotation around an axis (in radians).
Example:
tr = v3d.Transform.from_angle(x=1/4 * enp.tau) # Rotate 90° around x
Rotations are applied following the Tait-Bryan chained rotations (z, y, x):
R = Rz @ Ry @ Rx
- Parameters:
x – Rotation around x (in radians): roll == ϕ == phi == x
y – Rotation around y (in radians): pitch == θ == theta == y
z – Rotation around z (in radians): yaw == ψ == psi == z
- Returns:
The transformation.
- Return type:
tr
- classmethod from_look_at(*, pos: etils.enp.array_types.typing.FloatArray, target: etils.enp.array_types.typing.FloatArray) visu3d.dc_arrays.transformation.Transform [source]#
Factory to create a transformation which look at.
Used to convert camera to world coordinates.
This transformation assume the following conventions:
World coordinates: Floor is (x, y), z pointing upward
Camera coordinates: See
v3d.CameraSpec
docstring.
The transformation assume the width dimension of the camera is parallel to the floor of the world.
- Parameters:
pos – Origin position
target – Target position
- Returns:
The Transform.
- look_at(target: etils.enp.array_types.typing.FloatArray) visu3d.dc_arrays.transformation.Transform [source]#
Returns a new transform looking at the target.
- property x_dir: etils.enp.array_types.typing.FloatArray#
x axis of the transformation ([x0, x1, x2]).
- property y_dir: etils.enp.array_types.typing.FloatArray#
y axis of the transformation ([y0, y1, y2]).
- property z_dir: etils.enp.array_types.typing.FloatArray#
z axis of the transformation ([z0, z1, z2]).
- property x_ray: visu3d.dc_arrays.ray.Ray#
Array pointing to z.
- property y_ray: visu3d.dc_arrays.ray.Ray#
Array pointing to z.
- property z_ray: visu3d.dc_arrays.ray.Ray#
Array pointing to z.
- property ray_basis: visu3d.dc_arrays.ray.Ray#
The (x, y, z) basis of the transformation, as ray.
- property scale_xyz: etils.enp.array_types.typing.FloatArray#
Returns the (sx, sy, sz) scale of the transform along each axis.
- property scale#
Returns the global scale (if x, y, z share the same scale).
- Returns:
The global scale shared by all axis.
- Raises:
ValueError – If the x, y, z scales are different between axis.
- mul_scale(factor: etils.enp.array_types.typing.FloatArray) visu3d.dc_arrays.transformation.Transform [source]#
Scale the transformation (sx, sy, sz) by the given factor.
This is similar to v3d.Ray.scale_dir, applied on each individual axis.
- Parameters:
factor – The factor by which scale each axis. If scalar, broadcast all axis by the same value.
- Returns:
The new transform with scaled.
- normalize() visu3d.dc_arrays.transformation.Transform [source]#
Normalize the scale x, y, z to be (1, 1, 1).
- property matrix4x4: etils.enp.array_types.typing.FloatArray#
Returns the 4x4 transformation matrix.
[R|t] [0|1]
- property inv: visu3d.dc_arrays.transformation.Transform#
Returns the inverse camera transform.
- apply_to_pos(point: etils.enp.array_types.typing.FloatArray) etils.enp.array_types.typing.FloatArray [source]#
Apply the transformation on the point cloud.
- apply_to_dir(direction: etils.enp.array_types.typing.FloatArray) etils.enp.array_types.typing.FloatArray [source]#
Apply the transformation on the direction.
- apply_transform(tr: visu3d.dc_arrays.transformation.Transform) visu3d.dc_arrays.transformation.Transform [source]#