Quaternions, rotations, transforms, and geometric primitives.
Unit quaternion for 3D rotations. Aliases: Quaternionf (f32), Quaterniond (f64).
Quaternionf.identity() // No rotation
Quaternionf.init(w, x, y, z) // Direct
Quaternionf.fromAxisAngle(axis, angle) // From axis + angle
Quaternionf.fromRotationMatrix(R) // From 3x3 rotation matrixq.mul(other) // Compose rotations
q.conjugate() // Conjugate (q*)
q.inverse() // Inverse (q⁻¹)
q.norm() // Quaternion norm
q.normalized() // Unit quaternion
q.rotate(vector) // Rotate a 3D vector
q.toRotationMatrix() // Convert to 3x3 matrix
q.slerp(other, t) // Spherical linear interpolation (t ∈ [0,1])Rigid body transform (rotation + translation) in 3D.
Transform(f32).identity()
Transform(f32).init(rotation_matrix, translation_vector)
Transform(f32).fromQuaternion(q, translation_vector)
t.transformPoint(point) // Apply rotation + translation
t.transformVector(vec) // Apply rotation only
t.mul(other) // Compose transforms
t.inverse() // Inverse transform
t.toMatrix() // To 4x4 homogeneous matrixAxis-angle representation.
AngleAxis(f32).init(angle, axis)
aa.toRotationMatrix() // Convert to 3x3 matrix
aa.toQuaternion() // Convert to quaternion2D rotation by angle.
Rotation2D(f32).init(angle)
r.toMatrix() // 2x2 rotation matrix
r.rotate(vector) // Rotate 2D vectorconst R = Zigen.eulerToRotationMatrix(f64, .X, .Y, .Z, angles);| Type | Description |
|---|---|
Isometry(T) |
Rigid body (rotation + translation) |
Affine(T) |
Affine transform (includes scaling/shearing) |
Projective(T) |
Projective transform |
| Type | Description |
|---|---|
Hyperplane(T, n) |
N-dimensional hyperplane |
AlignedBox(T, n) |
Axis-aligned bounding box |
ParametrizedLine(T, n) |
Parametric line (origin + direction) |
Scaling(T, n) |
Non-uniform scaling |
UniformScaling(T) |
Uniform scaling |
Translation(T, n) |
Pure translation |
// Umeyama alignment: find optimal rigid transform from src to dst
const transform = try Zigen.umeyama(f64, 3, src_points, dst_points);