A linear algebra math lib for Zig
zig fetch --save git+https://github.com/HaraldWik/numzconst numz_mod = b.dependency("numz", .{
.target = target,
.optimize = optimize,
}).module("numz");// How I recommend making the import
const nz = @import("numz");
pub fn main() !void {
const mat: nz.Mat4x4(f32) = .identity;
const a: nz.Vec3(f32) = .{ 1, 2, 3 };
const b: nz.Vec3(f32) = .{ 3, 2, 1 };
const result = a + b; // They are SIMD which makes them support operations and some functions like @abs
const arr = [3]f32{0, 1, 2};
_ = nz.vec.normalize(arr); // All vector functions also support array vectors
const c: nz.Vec2(u32) = undefined; // Support for Vec2
const d: nz.Vec4(u32) = undefined; // Support for Vec4
const e: @Vector(3, f32) = .{ 1, 2, 3 }; // Optioanly you can use this style
}- Vec2
- Vec3
- Vec4
- eql
- scale
- dot
- cross
- length
- normalize
- negate
- distance
- distanceSquared
- reflect
- mix
- forward
- forwardFromEuler
- Mat4x4 <-- Column mayor so it works with OpenGL and Vulkan
- new
- identity
- mul
- translate
- scale
- rotate Standard Rodrigues’ rotation
- perspective
- orthographic
- crossProduct3D
- lookAt
- transpose
- inverse
- fromQuaternion
- Normal idk // This will change a lot
- identity
- new
- mul
- conjugate
- fromEuler
- toEuler
Note: The quaternions are under development, I do not recommend using this math library if you really need quaternion
- 3D
- 2D
- toMat4x4
- Rgb
- Rgba
- new
- eql
- alpha
- from
- to
- fromVec
- toVec
- fromHex
- toU32
- len
- max
- min
- white
- black
- red
- green
- blue
Feel free to make feature requests; I always want to know what can be improved.
But I won’t create hyper-specific features, nor will I implement algorithms.
- More and better quaternion types
- Mat3x3
- Mat2x2
- WallensteinVR
- 3d-opengl-exemple-zig // Made by me so doesn't realy count, and it doesnt even compile since breaking changes in 1.15...