| Crates.io | hexga_math |
| lib.rs | hexga_math |
| version | 0.0.11-beta.47 |
| created_at | 2025-03-28 17:48:20.227197+00 |
| updated_at | 2026-01-09 20:51:39.020294+00 |
| description | Math related crate that define number and casting, and support array programming... |
| homepage | https://github.com/Thomas-Mewily/hexga |
| repository | https://github.com/Thomas-Mewily/hexga |
| max_upload_size | |
| id | 1609921 |
| size | 319,140 |
🚧 Warning: Experimental Crate! 🚧
This crate is currently in beta and experimental. It is subject to breaking changes in future releases. Use it at your own risk, and keep in mind that the API may change in future versions.
This crate define N dimensional math stuff (2d, 3d, 4d, ... nd) like vector/point of any type (float, int, uint, or even user defined) :
Vector] (fixed size array wrapper)Rectangle]Grid]Matrix]The same common functions such as [min], [max], [mix],
[abs], and [clamp] work for
u32, i32, f32, bool, ...)Array, Vector, Color, Rectangle, Matrix, Grid, ...) that implement the [Map] / [MapWith] / [MapIntern] / [MapInternWith] traits.Any external type implementing these traits automatically gains support for these common functions.
Angle]Time],The crate also provide generic traits for casting with the same behavior as the as keyword :
CastInto], [CastFrom],Similar traits for casting remapping the range of an primitive to another primitive range also exist :
CastRangeInto], [CastRangeFrom]There are some quick typedef in the prelude :
int], [uint] and [float] : The default primitive precision used in the typedef. (can be change with the feature flags)Vec2i], [Vec3i], [Vec4i] for Vector of [int],Vec2], [Vec3], [Vec4] for Vector of [float],Rect2], [Rect3], [Rect4] for Rectangle of [float],Rect2i], [Rect3i], [Rect4i] for Rectangle of [int] (P for point),Mat2], [Mat3], [Mat4] for Matrix of [float], and [Mat2i], [Mat3i], [Mat4i] use [int],Grid2], [Grid3], [Grid3] can only be indexed by VecXi by default.If you need more control about the precision, each type have another more generic base type :
Grid] type uses a VecXi for the indexing precision, but that can be changed by using with the [hexga_math::grid::GridBase] type.Angle] and [Time] use a [float] precision that can be changed using [AngleOf] and [TimeOf]