Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BanchouBoo/algae
Zig math library focused on game development
https://github.com/BanchouBoo/algae
Last synced: 29 days ago
JSON representation
Zig math library focused on game development
- Host: GitHub
- URL: https://github.com/BanchouBoo/algae
- Owner: BanchouBoo
- License: unlicense
- Created: 2021-06-09T01:26:30.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-19T23:27:03.000Z (almost 3 years ago)
- Last Synced: 2024-08-03T23:23:43.897Z (4 months ago)
- Language: Zig
- Size: 82 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - BanchouBoo/algae
README
# Algae
Math library with a focus on game development, currently primarily focused on linear algebra but with plans to eventually include other things useful for game dev as I encounter needs for them such as fast RNG implementations, noise, 1D tranformations, etc.Inspired by [zlm](https://github.com/ziglibs/zlm).
## Usage
### Linear Algebra
Current types available:
* Vec2
* Vec3
* Vec4
* Quaternion
* MatricesLinear algebra is imported with a numeric type and has config options, example with default config options:
```zig
algae.lin_alg.WithType(f32, .{
.use_degrees = false, // angles will be passed into and returned as degrees if true
.integer_division_behavior = .truncate, // how division operations work when the underlying type is an integer
.auto_normalize_quaternions = true, // ensure quaternions are normalized for operations that require it if true
.extern_types = true, // Vector and Matrix types will be extern structs instead of regular structs if true
});
```Matrices are generic on their rows and columns, and if the rows and columns are the same length it will have an `identity` constant. Additionally, there is a pre-defined 4x4 matrix type with various functions for creating translations, rotations, scaling, and perspective and orthographic projections.
Vectors can do arithmetic with other struct types and with arrays so long as the length and types match, as can matrices, example:
```zig
const vec = vec2(1, 2).add([_]f32{3, 4}); // returns vec2(4, 6)
```### Float
Offers the following:
* `toDegrees` and `toRadians` to convert angles
* `lerp`
* A variety of easing functions