10#define PI 3.14159265359f
11#define DEG_2_RAD (PI / 180.0f)
12#define RAD_2_DEG (180.0f / PI)
14#define MAT4_IDENTITY \
17 1.0f, 0.0f, 0.0f, 0.0f, \
18 0.0f, 1.0f, 0.0f, 0.0f, \
19 0.0f, 0.0f, 1.0f, 0.0f, \
20 0.0f, 0.0f, 0.0f, 1.0f \
23#define QUATERNION_IDENTITY \
24 (Quaternion) { 0.0f, 0.0f, 0.0f, 1.0f }
114float clamp(
float value,
float min,
float max);
121float lerp(
float lhs,
float rhs,
float t);
float vec3_distance(Vec3 lhs, Vec3 rhs)
Get the distance between two vectors.
Mat4 mat4_projectionPerspective(float aspectRatio, float fieldOfView, float near, float far)
Construct a perspective projection matrix.
Vec3 vec3_mul(Vec3 lhs, Vec3 rhs)
Componentwise-mutiply two vectors.
float vec2_lengthSq(Vec2 v)
Get the squared length of a vector.
Vec3 vec3_cross(Vec3 lhs, Vec3 rhs)
Compute the cross product of the given vectors.
Quaternion quat_mul(Quaternion lhs, Quaternion rhs)
Multiply two quaternions together.
Vec2 vec2_mul(Vec2 lhs, Vec2 rhs)
Componentwise-mutiply two vectors.
float vec3_distanceSq(Vec3 lhs, Vec3 rhs)
Get the squared distance between two vectors.
void mat4_loadSIMD(const Mat4 *mat)
Load a matrix into the SIMD matrix register.
Vec3 vec3_lerp(Vec3 lhs, Vec3 rhs, float t)
Linearly interpolate between two values.
Vec2 vec2_lerp(Vec2 lhs, Vec2 rhs, float t)
Linearly interpolate between two values.
Vec4 vec4_lerp(Vec4 lhs, Vec4 rhs, float t)
Linearly interpolate between two values.
float vec2_distance(Vec2 lhs, Vec2 rhs)
Get the distance between two vectors.
float vec4_dot(Vec4 lhs, Vec4 rhs)
Compute the dot product of the given vectors.
void vec4_normalize(Vec4 *v)
Normalize the given vector.
Vec4 vec4_mul(Vec4 lhs, Vec4 rhs)
Componentwise-mutiply two vectors.
Vec4 vec4_sub(Vec4 lhs, Vec4 rhs)
Subtract two vectors.
Mat4 mat4_translate(Vec3 translation)
Construct a matrix from the given translation.
Mat4 mat4_projectionOrtho(float left, float right, float top, float bottom, float near, float far)
Construct an orthographic projection matrix.
float clamp(float value, float min, float max)
Clamp the value between a minimum and maximum.
Vec2 vec2_div(Vec2 lhs, Vec2 rhs)
Divide two vectors.
float vec2_dot(Vec2 lhs, Vec2 rhs)
Compute the dot product of the given vectors.
Vec3 vec3_add(Vec3 lhs, Vec3 rhs)
Add two vectors.
Vec4 vec4_add(Vec4 lhs, Vec4 rhs)
Add two vectors.
void quat_normalize(Quaternion *q)
Normalize the given quaternion.
float vec2_distanceSq(Vec2 lhs, Vec2 rhs)
Get the squared distance between two vectors.
void mat4_transformSIMD(const Vec4 *invec, Vec4 *outvec, uint32_t count, uint32_t stride)
Transform a list of input Vec4s using the SIMD matrix unit.
float vec3_length(Vec3 v)
Get the length of a vector.
float vec3_lengthSq(Vec3 v)
Get the squared length of a vector.
Vec3 vec3_transformQuat(Quaternion q, Vec3 v)
Rotate a vector by a quaternion.
Quaternion quat_fromEuler(Vec3 eulerAngles)
Construct a quaternion from rotation around each axis.
void vec3_normalize(Vec3 *v)
Normalize the given vector.
Mat4 mat4_mul(Mat4 lhs, Mat4 rhs)
Multiply two matrices together manually without the aid of the SIMD matrix unit.
void mat4_mulSIMD(const Mat4 *mat)
Multiply internal SIMD matrix register with the given matrix.
Mat4 mat4_projectionOrthoAspect(float aspectRatio, float scale, float near, float far)
Construct an orthographic projection matrix.
Vec3 vec3_div(Vec3 lhs, Vec3 rhs)
Divide two vectors.
Vec3 vec3_sub(Vec3 lhs, Vec3 rhs)
Subtract two vectors.
Vec2 vec2_sub(Vec2 lhs, Vec2 rhs)
Subtract two vectors.
void mat4_storeSIMD(Mat4 *mat)
Store the value in the SIMD matrix register to the given matrix.
Vec4 vec4_div(Vec4 lhs, Vec4 rhs)
Divide two vectors.
void vec2_normalize(Vec2 *v)
Normalize the given vector.
Vec4 vec4_transform(Mat4 mat, Vec4 vec)
Transform a single vector with a matrix without the aid of the SIMD matrix unit.
float vec2_length(Vec2 v)
Get the length of a vector.
float lerp(float lhs, float rhs, float t)
Linearly interpolate between two values.
Mat4 mat4_scale(Vec3 scale)
Construct a matrix from the given scale.
float vec3_dot(Vec3 lhs, Vec3 rhs)
Compute the dot product of the given vectors.
Mat4 mat4_rotation(Quaternion rotation)
Construct a matrix from the given rotation.
void mat4_loadIdentitySIMD()
Load identity matrix into the SIMD matrix register.
void quat_invert(Quaternion *q)
Invert the given quaternion.
Vec2 vec2_add(Vec2 lhs, Vec2 rhs)
Add two vectors.
A three-component vector.