Construct a finite point from x, y, and z coordinates.
Physics
:= []
Physics module - friendly 3D projective geometric algebra primitives.
This module uses compact grade-specific PGA storage. The public API stays geometric, but each object stores coefficients for its PGA subspace rather than plain graphics vectors.
Construct a finite point on the z=0 plane.
origin : Point
The finite point at the coordinate origin.
Construct a free vector from x, y, and z components.
Construct a free vector on the z=0 plane.
zero : Vector
The zero vector.
coords : Point -> Coords
Return normalized x, y, and z coordinates for a point.
components : Vector -> Coords
Return x, y, and z components for a free vector.
Return the x/y components of a point for 2D drawing boundaries.
vector_xy_components : Vector -> Vec2
Return the x/y components of a vector for 2D drawing boundaries.
point_coeffs : Point -> PointCoeffs
Return a read-only point coefficient record.
vector_coeffs : Vector -> VectorCoeffs
Return a read-only vector coefficient record.
plane_coeffs : Plane -> PlaneCoeffs
Return a read-only plane coefficient record.
line_coeffs : Line -> LineCoeffs
Return a read-only line coefficient record.
motor_coeffs : Motor -> MotorCoeffs
Return a read-only motor coefficient record.
add : Point, Vector -> Point
Translate a point by a free vector.
sub : Point, Point -> Vector
Return the free vector from the second point to the first point.
add_vec : Vector, Vector -> Vector
Add two free vectors.
sub_vec : Vector, Vector -> Vector
Subtract the second free vector from the first.
Scale a free vector by a scalar amount.
Compute the Euclidean dot product of two free vectors.
cross : Vector, Vector -> Vector
Compute the Euclidean cross product of two free vectors.
length_squared : Vector -> F32
Compute the squared Euclidean length of a free vector.
Compute the Euclidean length of a free vector.
normalize : Vector -> Vector
Return a unit-length vector, or zero for a zero-length input.
reflect : Vector, Vector -> Vector
Reflect a vector around a surface normal.
Compute the Euclidean distance between two finite points.
Construct a normalized plane from a normal and signed distance to origin.
plane_from_point_normal : Point, Vector -> Plane
Construct a plane through a point with the given normal direction.
signed_distance : Plane, Point -> F32
Compute the signed Euclidean distance from a normalized plane to a point.
project_point_plane : Plane, Point -> Point
Project a point onto a normalized plane.
line_from_points : Point, Point -> Line
Construct a PGA line passing through two finite points.
motor_identity : Motor
The identity motor.
translation : Vector -> Motor
Construct a translation motor from a free offset vector.
translation_vector : Motor -> Vector
Extract the translation offset represented by a translation motor.
apply_motor_point : Motor, Point -> Point
Apply a translation motor to a finite point.
body : Point, Vector -> Body
Construct a simple particle body.
apply_acceleration : Body, Vector, F32 -> Body
Integrate acceleration into a body's velocity over a time step.
integrate_body : Body, F32 -> Body
Integrate velocity into a body's position over a time step.
Clamp only the y component of a free vector.
Point
:= {
e032 : F32,
e013 : F32,
e021 : F32,
e123 : F32,
}
A finite 3D PGA point stored as compact grade-3 homogeneous coefficients.
Vector
:= {
e032 : F32,
e013 : F32,
e021 : F32,
}
A free 3D direction or translation stored as the ideal part of a point.
Plane
:= {
e0 : F32,
e1 : F32,
e2 : F32,
e3 : F32,
}
A 3D PGA plane stored as grade-1 coefficients.
Line
:= {
e01 : F32,
e02 : F32,
e03 : F32,
e23 : F32,
e31 : F32,
e12 : F32,
}
A 3D PGA line stored as six grade-2 Plucker-style coefficients.
Motor
:= {
s : F32,
e23 : F32,
e31 : F32,
e12 : F32,
e01 : F32,
e02 : F32,
e03 : F32,
e0123 : F32,
}
A 3D PGA motor stored as compact even-subalgebra coefficients.
Body : {
position : Point,
velocity : Vector,
}
A simple particle body with a PGA point position and vector velocity.
Plain coordinate view returned by accessors.
PointCoeffs : {
e032 : F32,
e013 : F32,
e021 : F32,
e123 : F32,
}
Read-only coefficient view for a point.
VectorCoeffs : {
e032 : F32,
e013 : F32,
e021 : F32,
}
Read-only coefficient view for a vector.
PlaneCoeffs : {
e0 : F32,
e1 : F32,
e2 : F32,
e3 : F32,
}
Read-only coefficient view for a plane.
Read-only coefficient view for a line.
MotorCoeffs : {
s : F32,
e23 : F32,
e31 : F32,
e12 : F32,
e01 : F32,
e02 : F32,
e03 : F32,
e0123 : F32,
}
Read-only coefficient view for a motor.