Skip to main content

lunar_math/
lib.rs

1//! math re-exports and custom utilities
2//!
3//! this crate wraps [`glam`] for vector/matrix math and provides engine-specific types
4//! like [`Transform`], [`Color`], and [`Rect`].
5//!
6//! # re-exports
7//!
8//! the full `glam` crate is re-exported for convenience, so you can access
9//! any glam types directly via `lunar_math::glam`.
10
11pub use glam;
12
13/// 2D vector type alias.
14///
15/// backed by [`glam::Vec2`], provides x, y components with SIMD support.
16pub type Vec2 = glam::Vec2;
17
18/// 3D vector type alias.
19///
20/// backed by [`glam::Vec3`]. use for general-purpose 3D math and component storage.
21pub type Vec3 = glam::Vec3;
22
23/// 16-byte aligned 3D vector type alias.
24///
25/// backed by [`glam::Vec3A`]. use in hot-loop math (culling, physics, SoA buffers)
26/// where SIMD register fit matters — same cost as Vec3 on most paths but aligns
27/// to 16 bytes so glam's SSE2/NEON paths can load it in one instruction.
28pub type Vec3A = glam::Vec3A;
29
30/// 4D vector type alias.
31///
32/// backed by [`glam::Vec4`], useful for packed colors and shader uniforms.
33pub type Vec4 = glam::Vec4;
34
35/// 2x2 matrix type alias.
36///
37/// backed by [`glam::Mat2`], used for 2D rotations.
38pub type Mat2 = glam::Mat2;
39
40/// 3x3 matrix type alias.
41///
42/// backed by [`glam::Mat3`]. useful for 2D affine transforms and normal matrix computation.
43pub type Mat3 = glam::Mat3;
44
45/// 4x4 matrix type alias.
46///
47/// backed by [`glam::Mat4`]. useful for custom projection matrices and 3D transforms.
48pub type Mat4 = glam::Mat4;
49
50/// quaternion type alias.
51///
52/// backed by [`glam::Quat`]. used for 3D rotation in `LocalTransform3d`.
53/// quaternions avoid gimbal lock and interpolate cleanly via slerp.
54pub type Quat = glam::Quat;
55
56mod macros;
57mod screen_rect;
58mod types;
59
60pub use screen_rect::ScreenRect;
61pub use types::{Color, LocalTransform, Rect, Transform, WorldTransform};