Skip to main content

Crate tpt_math_geometry

Crate tpt_math_geometry 

Source
Expand description

Geometry module built on tpt_math_linalg_fixed.

A from-scratch, const-generic geometry layer (matching the breadth of nalgebra’s geometry module) with no nalgebra dependency and no allocator — everything here is stack-allocated fixed-size storage. It provides points, translations, rotations (2-D and 3-D), unit quaternions, isometries, similarities, uniform scaling and the perspective / orthographic projection matrices.

§Conventions (stated explicitly)

  • Active (alibi) rotations. A rotation acts on a vector v as R * v (matrix–vector multiplication with the vector on the right), which rotates the point/vector rather than the coordinate frame.
  • Column vectors. Points and vectors are column vectors; transformations are applied as M * v.
  • Right-handed coordinates. The 2-D rotation by a positive angle is counter-clockwise. The 3-D right-handed basis is x × y = z.
  • Euler angles (3-D) use the intrinsic Tait–Bryan order Rz(yaw) · Ry(pitch) · Rx(roll) — that is, the vector is first rolled about x, then pitched about y, then yawed about z.
  • Quaternions are Hamilton quaternions q = w + x i + y j + z k (scalar part w last), matching nalgebra’s memory layout.
  • Projection matrices are right-handed, look down -z, with Normalised Device Coordinates z in [-1, 1] (OpenGL-style depth range).
  • Isometry composition is written as B * A and means “apply A, then B”: `(B * A)(p) = B.rotation * (A.rotation * p + A.translation)
    • B.translation`.

Structs§

Isometry
A rigid motion: a rotation followed by a translation.
Orthographic3
A right-handed orthographic projection (view space → clip space), looking down -z, with NDC depth in [-1, 1] (OpenGL-style).
Perspective3
A right-handed perspective projection (view space → clip space), looking down -z, with NDC depth in [-1, 1] (OpenGL-style).
Point
A point in D-dimensional Euclidean space.
Quaternion
A quaternion q = w + x i + y j + z k (Hamilton convention, scalar w last).
Rotation
An orthogonal, orientation-preserving (determinant +1) linear map in D dimensions, stored as its rotation matrix.
Scale
A non-uniform (axis-aligned) scaling.
Similarity
A similarity transform: a uniform scaling, then a rotation, then a translation.
Translation
A translation in D-dimensional space.
UnitQuaternion
A unit (normalised) quaternion, representing a 3-D rotation.

Type Aliases§

Isometry2
2-D isometry.
Isometry3
3-D isometry.
Point2
2-D point.
Point3
3-D point.
Rotation2
2-D rotation.
Rotation3
3-D rotation.
Similarity3
3-D similarity.