| Crates.io | ggmath |
| lib.rs | ggmath |
| version | 0.15.0 |
| created_at | 2024-12-15 19:09:16.923379+00 |
| updated_at | 2026-01-23 08:55:31.110457+00 |
| description | A math library for games and graphics with support for generics and SIMD. |
| homepage | |
| repository | https://github.com/Noam2Stein/ggmath |
| max_upload_size | |
| id | 1484352 |
| size | 225,030 |
ggmathA math library for games and graphics with support for generics and SIMD.
The library features:
Vec2<T>, Vec3<T>, Vec4<T>.Mat2<T>, Mat3<T>, Mat4<T>.Quat<T>.Affine2<T>, Affine3<T>.Mask2<T>, Mask3<T>, Mask4<T>.For appropriate scalars these types are SIMD aligned and use SIMD instructions to maximize performance.
As a result of SIMD alignment, some of these types have padding. For example,
Vec3<f32> is aligned to 16 bytes and as a result has 4-bytes of padding. To
fix this the library features unaligned types which don't have padding but are
not backed by SIMD:
Vec2U<T>, Vec3U<T>, Vec4U<T>.Mat2U<T>, Mat3U<T>, Mat4U<T>.QuatU<T>.Affine2U<T>, Affine3U<T>.Mask2U<T>, Mask3U<T>, Mask4U<T>.Unaligned types are useful for situations where saving memory is high priority, for example when storing large arrays of these types.
All of these types are specific cases of these generic structs:
Vector<N, T, A>.Matrix<N, T, A> (todo).Quaternion<T, A> (todo).Affine<N, T, A> (todo).Mask<N, T, A> (todo).Where:
N is the length (2, 3, or 4).T is the scalar type.A is either Aligned or Unaligned.The full generic form of these types are useful to write code that is generic over length and or alignment.
ggmath is not mature yet but is under active development.
Feature List:
Crate Support:
Performance:
f32 SSE2 optimizationsf32 SSE4.2+ optimizationsf64 AVX+ optimizationsi32 u32 SSE2+ optimizationsi8 u8 bool SSE2+ optimizations for Mat4<T>i16 u16 AVX2+ optimizations for Mat4<T>f32 NEON optimizationsi32 u32 NEON optimizationsi8 u8 bool NEON optimizations for Mat4<T>f32 WASM optimizationsi32 u32 WASM optimizationsi8 u8 bool WASM optimizations for Mat4<T>Add this to your Cargo.toml:
[dependencies]
ggmath = "0.15.0"
For no_std support, disable default features:
[dependencies]
ggmath = { version = "0.15.0", default-features = false }
While std can be disabled, libm support is missing so no_std doesn't
support most float functionality.
std (default feature): Uses std as the backend for float functionality.
assertions: Enables assertions in release mode. Assertions are panics that
catch invalid input and are enabled by default in debug mode.
no-assertions: Disables assertions in debug mode. Library crates should not
directly enable assertions or no-assertions and should leave the decision
to binary crates.
ggmath has no dependencies.
Licensed under either Apache License Version 2.0 or MIT license at your option.