Rapier C — 2D / f32 0.36.0+c.0
Loading...
Searching...
No Matches
rapier_math.h File Reference

Inline value constructors and arithmetic; no allocation or error-state changes. More...

Go to the source code of this file.

Macros

#define R2_PI   ((R2Real)3.14159265358979323846)
 Pi in the selected scalar precision.

Functions

static R2Vector r2Vector (R2Real x, R2Real y)
 Construct a vector from its components.
static R2Rotation r2Rotation (R2Real angle)
 Construct a 2D rotation from an angle in radians.
static R2Vector r2VectorAdd (R2Vector a, R2Vector b)
 Return a + b.
static R2Vector r2VectorSub (R2Vector a, R2Vector b)
 Return a - b.
static R2Vector r2VectorScale (R2Vector vector, R2Real scale)
 Multiply each component by scale.
static R2Real r2VectorDot (R2Vector a, R2Vector b)
 Return the dot product.
static R2Real r2VectorLength (R2Vector vector)
 Return the Euclidean length.
static R2Vector r2VectorNormalize (R2Vector vector)
 Normalize a nonzero vector; a zero vector is returned unchanged.
static R2Rotation r2RotationMul (R2Rotation a, R2Rotation b)
 Compose rotations, applying b then a.
static R2Vector r2RotationTransformVector (R2Rotation rotation, R2Vector vector)
 Rotate a vector; rotation must be normalized.
static R2Pose r2Pose (R2Vector translation, R2Rotation rotation)
 Construct a pose from translation and rotation without validation.
static R2Pose r2TranslationPose (R2Vector translation)
 Construct a pose with the supplied translation and identity rotation.
static R2MassProperties r2MassProperties (R2Vector local_com, R2Real mass, R2AngVector principal_inertia)
 Construct mass properties from a local center of mass, a mass, and principal angular inertia (a scalar in 2D); in 3D the principal inertia frame is the identity rotation.
static R2Rotation r2RotationInverse (R2Rotation rotation)
 Return the inverse of a normalized rotation.
static R2Vector r2PoseTransformPoint (R2Pose pose, R2Vector point)
 Transform a point by rotation then translation.
static R2Pose r2PoseInverse (R2Pose pose)
 Return the inverse rigid transform.

Detailed Description

Inline value constructors and arithmetic; no allocation or error-state changes.

Trigonometry uses the library's Sin and Cos, so results match across platforms with enhanced-determinism; square roots are exactly rounded everywhere.