Units
Theunits.h header provides fundamental spatial and mathematical types used throughout Atlas Engine. These types offer clean, type-safe wrappers around GLM types with convenient APIs for game development.
Position3d
Represents a 3D position with single-precision floating point coordinates.Static Factory Methods
Operations
Usage Example
Type Aliases
The following aliases all usePosition3d internally but provide semantic clarity:
| Type | Purpose | Example |
|---|---|---|
Scale3d | Scaling factors | {2.0f, 1.0f, 1.0f} |
Size3d | Physical dimensions | {0.5f, 0.5f, 0.5f} |
Point3d | Point in space | {10.0f, 5.0f, 3.0f} |
Normal3d | Surface normals | {0.0f, 1.0f, 0.0f} |
Magnitude3d | Vector magnitudes | {1.0f, 1.0f, 1.0f} |
Velocity3d | Movement velocity | {5.0f, 0.0f, 2.0f} |
Impulse3d | Physics impulse | {0.0f, 0.0f, 20.0f} |
Force3d | Force vectors | {0.0f, -9.8f, 0.0f} |
Vector3 | Generic 3D vector | {1.0f, 2.0f, 3.0f} |
Rotation3d
Represents rotation using Euler angles (pitch, yaw, roll) in degrees.Operations
Usage Example
Quaternion
Represents rotation using a quaternion with conversion to/from Euler angles.Color
Represents RGBA colors with single-precision components (0.0 to 1.0).Static Color Constants
Operations
Usage Example
Position2d
Represents a 2D position with single-precision floating point coordinates.Type Aliases
Scale2d- 2D scaling factorsPoint2d- 2D point in spaceMovement2d- 2D movement vectorMagnitude2d- 2D magnitude vector
Usage Example
Size2d
Represents 2D dimensions with width and height.Operations
Radians
Represents angular measurements in radians with conversion from degrees.Usage Example
Direction3d
Enumeration of cardinal 3D directions.Id
Type alias for OpenGL object identifiers.Best Practices
- Use type aliases for semantic clarity: Use
Velocity3dinstead ofPosition3dwhen representing velocity - Prefer static factory methods: Use
Position3d::zero()instead ofPosition3d(0, 0, 0) - Use Color constants: Prefer
Color::red()overColor(1.0f, 0.0f, 0.0f, 1.0f) - Convert to GLM when needed: Use
.toGlm()when interfacing with rendering code - Use hex colors for web colors:
Color::fromHex(0xFF5733)is cleaner than manual RGB values