linalg/small
fixed-size concrete helpers: vec2/vec3/vec4, mat4
vec2
(defstruct vec2 [])
2D vector (float32)
vec3
(defstruct vec3 [])
3D vector (float32)
vec4
(defstruct vec4 [])
4D vector (float32)
mat2
(defstruct mat2 [])
2x2 matrix (float32, column-major)
mat3
(defstruct mat3 [])
3x3 matrix (float32, column-major)
mat4
(defstruct mat4 [])
4x4 matrix (float32, column-major to match OpenGL)
vec2
(vec2 [x y] :vec2)
vec2 constructor
vec3
(vec3 [x y z] :vec3)
vec3 constructor
vec4
(vec4 [x y z w] :vec4)
vec4 constructor
mat4-identity
(mat4-identity :mat4)
create 4x4 identity matrix
vec2-dot
(vec2-dot [a b] :float)
dot product of two vec2
vec3-dot
(vec3-dot [a b] :float)
dot product of two vec3
vec3-cross
(vec3-cross [a b] :vec3)
cross product of two vec3
vec3-length
(vec3-length [v] :float)
length (norm) of a vec3
vec3-normalize
(vec3-normalize [v] :vec3)
normalize a vec3 to unit length
mat4-mul
(mat4-mul [a b] :mat4)
multiply two mat4 matrices (column-major)
mat4-mul-vec4
(mat4-mul-vec4 [m v] :vec4)
multiply mat4 by vec4
mat4-transpose
(mat4-transpose [m] :mat4)
transpose a mat4
mat4-inv
(mat4-inv [m] :mat4)
compute inverse of a mat4
mat4-translate
(mat4-translate [v] :mat4)
create translation matrix
mat4-scale
(mat4-scale [v] :mat4)
create scaling matrix
mat4-rotate-x
(mat4-rotate-x [angle] :mat4)
create rotation matrix around x-axis
mat4-rotate-y
(mat4-rotate-y [angle] :mat4)
create rotation matrix around y-axis
mat4-rotate-z
(mat4-rotate-z [angle] :mat4)
create rotation matrix around z-axis
mat4-rotate
(mat4-rotate [axis angle] :mat4)
create rotation matrix around arbitrary axis
mat4-perspective
(mat4-perspective [fovy aspect near far] :mat4)
create perspective projection matrix
mat4-ortho
(mat4-ortho [l r b t near far] :mat4)
create orthographic projection matrix
mat4-look-at
(mat4-look-at [eye center up] :mat4)
create view matrix (camera transformation)
mat4-ptr
(mat4-ptr [m] :int)
get pointer to mat4 data (for OpenGL uniform uploads)
vec3-ptr
(vec3-ptr [v] :int)
get pointer to vec3 data
Internal definitions
mat2-identity-- create 2x2 identity matrixmat3-identity-- create 3x3 identity matrixvec3->vec4-- Helper: create vec4 from vec3 with w=1.0vec3-sub-- Helper functions for vec3 arithmetic (needed for look-at)vec4-dot-- vec3-dot (already defined above)