Skip to content

hertzforge.rotate

rotate

Turning and sliding a coordinate system.

A coordinate system is stored as four rows: three orthonormal basis vectors and an origin. Turning it about one of its axes changes only the basis, and the origin stays where it is; sliding it along one moves only the origin.

Functions:

Name Description
rotation_about

The 3x3 rotation of angle radians about axis, by Rodrigues'

rotate_frame

A copy of matrix with its basis turned angle radians about one

identity_frame

The frame with its rotation undone: the identity basis at the

translate_frame

A copy of matrix with its origin moved distance along one of

frame_from_angles

A frame at origin turned by angles, in degrees, about the

angles_of

The fixed-axis X, Y, Z angles in degrees that turn the geometry's

Functions:

rotation_about

rotation_about(axis: ArrayLike, angle: float) -> ndarray

The 3x3 rotation of angle radians about axis, by Rodrigues' formula.

axis is normalized here, so it need not be a unit vector. A positive angle turns counterclockwise looking down the axis toward the origin (the right-hand rule).

rotate_frame

rotate_frame(matrix: ArrayLike, axis: int, angle: float) -> ndarray

A copy of matrix with its basis turned angle radians about one of its own axes.

The axis moves with the frame, so turning about X twice by 45 degrees is turning about the frame's X by 90 degrees, not about the world's X. The origin is unchanged.

identity_frame

identity_frame(matrix: ArrayLike) -> ndarray

The frame with its rotation undone: the identity basis at the same origin.

translate_frame

translate_frame(matrix: ArrayLike, axis: int, distance: float) -> ndarray

A copy of matrix with its origin moved distance along one of its own axes. The basis is unchanged; rotate_frame is the opposite case.

frame_from_angles

frame_from_angles(angles: ArrayLike, origin: ArrayLike = (0.0, 0.0, 0.0)) -> ndarray

A frame at origin turned by angles, in degrees, about the geometry's fixed X, then Y, then Z axes, the order a person types them in. The first three rows are the frame's axes and the fourth is its origin, as in a coordinate system.

angles_of

angles_of(matrix: ArrayLike) -> tuple[float, float, float]

The fixed-axis X, Y, Z angles in degrees that turn the geometry's axes into the frame's, the inverse of frame_from_angles. X and Z are in (-180, 180] and Y in [-90, 90]. At a quarter turn about Y the X and Z turns are about the same axis, and the angle is given as Z with X at zero.