All Projects → kooparse → zalgebra

kooparse / zalgebra

Licence: MIT license
Linear algebra library for games and real-time graphics.

Programming Languages

Zig
133 projects

Projects that are alternatives of or similar to zalgebra

abacus
📐 C# cross precision 3D maths library.
Stars: ✭ 35 (-72.87%)
Mutual labels:  math, matrix, quaternion, vectors
hlml
vectorized high-level math library
Stars: ✭ 42 (-67.44%)
Mutual labels:  math, matrix, quaternion
Tensor
A library and extension that provides objects for scientific computing in PHP.
Stars: ✭ 146 (+13.18%)
Mutual labels:  math, matrix, linear-algebra
Mathnet Numerics
Math.NET Numerics
Stars: ✭ 2,688 (+1983.72%)
Mutual labels:  math, matrix, linear-algebra
Notecalc3
NoteCalc is a handy calculator trying to bring the advantages of Soulver to the web.
Stars: ✭ 879 (+581.4%)
Mutual labels:  math, matrix, linear-algebra
Numphp
Mathematical PHP library for scientific computing
Stars: ✭ 120 (-6.98%)
Mutual labels:  math, matrix, linear-algebra
Mathematics for Machine Learning
Learn mathematics behind machine learning and explore different mathematics in machine learning.
Stars: ✭ 28 (-78.29%)
Mutual labels:  math, matrix, linear-algebra
Math Php
Powerful modern math library for PHP: Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra
Stars: ✭ 2,009 (+1457.36%)
Mutual labels:  math, matrix, linear-algebra
SCNMathExtensions
Math extensions for SCNVector3, SCNQuaternion, SCNMatrix4
Stars: ✭ 32 (-75.19%)
Mutual labels:  math, matrix, quaternion
linalg
Linear algebra library based on LAPACK
Stars: ✭ 42 (-67.44%)
Mutual labels:  matrix, linear-algebra
mathcore
Advanced .NET math library (.NET Standard).
Stars: ✭ 24 (-81.4%)
Mutual labels:  math, linear-algebra
SKLinearAlgebra
Swift extensions for Linear Algebra with SceneKit
Stars: ✭ 53 (-58.91%)
Mutual labels:  linear-algebra, vectors
PyGLM
Fast OpenGL Mathematics (GLM) for Python
Stars: ✭ 167 (+29.46%)
Mutual labels:  matrix, quaternion
eigen
Owl's OCaml Interface to Eigen3 C++ Library
Stars: ✭ 30 (-76.74%)
Mutual labels:  matrix, linear-algebra
matrixgl
Yet another matrix library for WebGL
Stars: ✭ 25 (-80.62%)
Mutual labels:  math, matrix
eigen-js
⚡ Eigen-js is a port of the Eigen C++ linear algebra library
Stars: ✭ 78 (-39.53%)
Mutual labels:  matrix, linear-algebra
Tutorials
AI-related tutorials. Access any of them for free → https://towardsai.net/editorial
Stars: ✭ 204 (+58.14%)
Mutual labels:  math, linear-algebra
topologic
Visualiser for basic geometric primitives and fractals in arbitrary-dimensional spaces
Stars: ✭ 39 (-69.77%)
Mutual labels:  math, linear-algebra
zlm
Zig linear mathemathics
Stars: ✭ 67 (-48.06%)
Mutual labels:  linear-algebra, ziglang
Linear-Algebra-and-Its-Applications-notes
《线性代数及其应用》笔记
Stars: ✭ 196 (+51.94%)
Mutual labels:  math, linear-algebra

zalgebra

CI

Linear algebra library for games and computer graphics.

The goal is to become as complete and useful as the Unity one. I'm currently using it for my projects and will continue to update it as new needs are coming.

If you would like to contribute, don't hesitate! :)

Note: Zig 0.10.x is required.

Examples

const za = @import("zalgebra");
const Vec3 = za.Vec3;
const Mat4 = za.Mat4;

pub fn main () void {
  var projection = za.perspective(45.0, 800.0 / 600.0, 0.1, 100.0);
  var view = za.lookAt(Vec3.new(0.0, 0.0, -3.), Vec3.zero(), Vec3.up());
  var model = Mat4.fromTranslate(Vec3.new(0.2, 0.5, 0.0));

  var mvp = Mat4.mul(projection, view.mul(model));
}

Quick reference

Aliases

Type Description
Vec2 Two dimensional vector for f32
Vec2_f64 Two dimensional vector for f64
Vec2_i32 Two dimensional vector for i32
Vec2_usize Two dimensional vector for usize
Vec3 Three dimensional vector for f32
Vec3_f64 Three dimensional vector for f64
Vec3_i32 Three dimensional vector for i32
Vec3_usize Three dimensional vector for usize
Vec4 Four dimensional vector for f32
Vec4_f64 Four dimensional vector for f64
Vec4_i32 Four dimensional vector for i32
Vec4_usize Four dimensional vector for usize
Mat4 4x4 matrix for f32
Mat4_f64 4x4 matrix for f64
Quat Quaternion for f32
Quat_f64 Quaternion for f64
perspective Perspective function for f32 4x4 mat4
orthographic Orthographic function for f32 4x4 mat4
lookAt LookAt function for f32 4x4 mat4

Vectors

Methods Description
new Construct a vector from 2 to 4 components
x Return first component
y Return second component
z Return third component (only for vec3, vec4)
w Return fourth component (only for vec4)
at Return component from given index
set Set all components to the same given value
negate Scale all components by -1
cast Cast a type to another type
fromSlice Construct new vectors from slice
zero Shorthand for (0, 0, 0)
one Shorthand for (1, 1, 1)
up Shorthand for (0, 1, 0)
down Shorthand for (0, -1, 0)
right Shorthand for (1, 0, 0)
left Shorthand for (-1, 0, 0)
forward Shorthand for (0, 0, 1) (only for vec3 and vec4)
back Shorthand for (0, 0, -1) (only for vec3 and vec4)
toArray Return an array of same size.
getAngle Return angle in degrees between two vectors (only for vec2 and vec3)
length Return the magnitude of the current vector
distance Return the distance between two points
norm Construct a new normalized vector based on the given one
eql Return true if two vectors are equals
sub Construct new vector resulting from the substraction between two vectors
add Construct new vector resulting from the addition between two vectors
mul Construct new vector resulting from the multiplication between two vectors
scale Construct new vector after multiplying each components by a given scalar
cross Construct the cross product (as vector) from two vectors (only for vec3)
dot Return the dot product between two vectors
lerp Linear interpolation between two vectors
min Construct vector from the min components between two vectors
max Construct vector from the max components between two vectors

Matrices

Note: All matrices are column-major.

Methods Description
identity Construct an identity matrix
set Set all matrix values to given value
fromSlice Construct new matrix from given slice of data
getData Return a pointer to the inner data
transpose Return the transpose matrix
negate Scale all components by -1
cast Cast a type to another type
eql Return true if two matrices are equals
mulByVec4 Multiply a given vec4 by matrix (only for mat4)
fromTranslate Construct a translation matrix
translate Construct a translation from the given matrix according to given axis (vec3)
fromRotation Construct a rotation matrix
fromEulerAngles Construct a rotation matrix from pitch/yaw/roll in degrees (X * Y * Z)
rotate Construct a rotation from the given matrix according to given axis (vec3)
fromScale Construct a scale matrix
scale Construct a scale from the given matrix according to given axis (vec3)
extractTranslation Return a vector with proper translation
orthoNormalize Ortho normalize the given matrix.
extractEulerAngles Return a vector with Euler angles in degrees (pitch/yaw/roll)
extractScale Return a vector with proper scale
perspective Construct a perspective matrix from given fovy, aspect ratio, near/far inputs
orthographic Construct an orthographic matrix from given left, right, bottom, top, near/far inputs
lookAt Construct a right-handed lookAt matrix from given position (eye) and target
mul Multiply two matrices
inv Inverse the given matrix
recompose Return matrix from given translation, rotation and scale components
decompose Return components translation, rotation and scale from given matrix.
debugPrint Print the matrix data for debug purpose

Quaternions

Methods Description
new Construct new quat from given floats
identity Construct quat as (1, 0, 0, 0)
set Set all components to the same given value
cast Cast a type to another type
fromSlice Construct new quaternion from slice
fromVec3 Construct quaternion from vec3
eql Return true if two quaternions are equal
norm Normalize given quaternion
length Return the magniture of the given quaternion
inv Construct inverse quaternion
sub Construct quaternion resulting from the subtraction of two given ones
add Construct quaternion resulting from the addition of two given ones
mul Construct quaternion resulting from the multiplication of two given ones
scale Construct new quaternion resulting from the multiplication of all components by a given scalar
dot Return the dot product between two quaternions
toMat4 Convert given quat to rotation 4x4 matrix
fromEulerAngles Construct quaternion from Euler angles
fromAxis Construct quat from angle around specified axis
extractAxisAngles Get the rotation angle and axis for a given quaternion
extractRotation Get euler angles from given quaternion
rotateVec Rotate given vector

Utilities

Methods Description
toRadians Convert degrees to radians
toDegrees Convert radians to degrees
lerp Linear interpolation between two floats

Contributing to the project

Don’t be shy about shooting any questions you may have. If you are a beginner/junior, don’t hesitate, I will always encourage you. It’s a safe place here. Also, I would be very happy to receive any kind of pull requests, you will have (at least) some feedback/guidance rapidly.

Behind screens, there are human beings, living any sort of story. So be always kind and respectful, because we all sheer to learn new things.

Thanks

This project is inspired by Handmade Math, nalgebra and Unity.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].