|
SBgl 0.1.0
A graphics framework in C99
|
Single-header math library for SBgl. More...
#include <math.h>#include <stdbool.h>#include <stdint.h>

Go to the source code of this file.
Data Structures | |
| struct | sbgl_OrthoParams |
| Parameters for orthographic projection. More... | |
| union | sbgl_Vec2 |
| 2D Vector. More... | |
| union | sbgl_Vec3 |
| 3D Vector, 16-byte aligned and padded for SIMD safety. More... | |
| union | sbgl_Vec4 |
| 4D Vector, 16-byte aligned. More... | |
| union | sbgl_Quat |
| Quaternion, 16-byte aligned. More... | |
| struct | sbgl_Mat4 |
| 4x4 Matrix, 16-byte aligned, column-major. More... | |
Macros | |
| #define | SBGL_ALIGN(n) |
| #define | SBGL_PI 3.14159265358979323846f |
Functions | |
| static sbgl_Vec2 | sbgl_Vec2Set (float x, float y) |
| Creates a Vec2. | |
| static sbgl_Vec3 | sbgl_Vec3Set (float x, float y, float z) |
| Creates a Vec3, correctly padded. | |
| static sbgl_Vec4 | sbgl_Vec4Set (float x, float y, float z, float w) |
| Creates a Vec4. | |
| static sbgl_Quat | sbgl_QuatSet (float x, float y, float z, float w) |
| Creates a Quat. | |
| static float | sbgl_InvSqrt (float x) |
| Approximate Inverse Square Root algorithm. | |
| static sbgl_Vec3 | sbgl_Vec3Add (sbgl_Vec3 a, sbgl_Vec3 b) |
| Adds two Vec3 vectors. | |
| static sbgl_Vec3 | sbgl_Vec3Sub (sbgl_Vec3 a, sbgl_Vec3 b) |
| Subtracts b from a. | |
| static sbgl_Vec3 | sbgl_Vec3Mul (sbgl_Vec3 a, float s) |
| Multiplies a Vec3 by a scalar. | |
| static float | sbgl_Vec3Dot (sbgl_Vec3 a, sbgl_Vec3 b) |
| Computes the dot product of two Vec3 vectors. | |
| static sbgl_Vec3 | sbgl_Vec3Cross (sbgl_Vec3 a, sbgl_Vec3 b) |
| Computes the cross product of two Vec3 vectors. | |
| static float | sbgl_Vec3Length (sbgl_Vec3 v) |
| Returns the length of a Vec3. | |
| static sbgl_Vec3 | sbgl_Vec3Normalize (sbgl_Vec3 v) |
| Normalizes a Vec3. | |
| static sbgl_Vec4 | sbgl_Vec4Add (sbgl_Vec4 a, sbgl_Vec4 b) |
| Adds two Vec4 vectors. | |
| static sbgl_Vec4 | sbgl_Vec4Mul (sbgl_Vec4 a, float s) |
| Multiplies a Vec4 by a scalar. | |
| static sbgl_Quat | sbgl_QuatIdentity (void) |
| Returns an identity quaternion. | |
| static sbgl_Quat | sbgl_QuatMul (sbgl_Quat a, sbgl_Quat b) |
| Multiplies two quaternions. | |
| static sbgl_Quat | sbgl_QuatFromAxisAngle (sbgl_Vec3 axis, float angle_rad) |
| Creates a quaternion from an axis and an angle (in radians). | |
| static sbgl_Mat4 | sbgl_Mat4Identity (void) |
| Returns an identity matrix. | |
| static sbgl_Mat4 | sbgl_QuatToMat4 (sbgl_Quat q) |
| Converts a quaternion to a rotation matrix. | |
| static sbgl_Mat4 | sbgl_Mat4Mul (sbgl_Mat4 a, sbgl_Mat4 b) |
| Multiplies two matrices. | |
| static sbgl_Vec4 | sbgl_Mat4MulVec4 (sbgl_Mat4 m, sbgl_Vec4 v) |
| Multiplies a matrix by a Vec4. | |
| static sbgl_Mat4 | sbgl_Mat4Translate (sbgl_Vec3 v) |
| Creates a translation matrix. | |
| static sbgl_Mat4 | sbgl_Mat4Scale (sbgl_Vec3 v) |
| Creates a scaling matrix. | |
| static sbgl_Mat4 | sbgl_Mat4Perspective (float fov_y_rad, float aspect, float near, float far) |
| Creates a perspective projection matrix. | |
| static sbgl_Mat4 | sbgl_Mat4Rotate (float angle_rad, sbgl_Vec3 axis) |
| Creates a rotation matrix from axis and angle. | |
| static sbgl_Mat4 | sbgl_Mat4Orthographic (sbgl_OrthoParams p) |
| Creates an orthographic projection matrix. | |
| static sbgl_Mat4 | sbgl_Mat4LookAt (sbgl_Vec3 eye, sbgl_Vec3 center, sbgl_Vec3 up) |
| Creates a look-at view matrix. | |
Single-header math library for SBgl.
Provides SIMD-ready vector, matrix, and quaternion operations using aligned memory layouts and static inline functions.
Definition in file sbgl_math.h.
| #define SBGL_ALIGN | ( | n | ) |
Definition at line 19 of file sbgl_math.h.
| #define SBGL_PI 3.14159265358979323846f |
Definition at line 22 of file sbgl_math.h.
|
inlinestatic |
Approximate Inverse Square Root algorithm.
Uses C99-compliant union punning to avoid strict-aliasing violations.
Definition at line 114 of file sbgl_math.h.
|
inlinestatic |
Creates a look-at view matrix.
Definition at line 308 of file sbgl_math.h.
Multiplies two matrices.
Definition at line 240 of file sbgl_math.h.
|
inlinestatic |
Creates an orthographic projection matrix.
Definition at line 296 of file sbgl_math.h.
|
inlinestatic |
Creates a perspective projection matrix.
Definition at line 278 of file sbgl_math.h.
Creates a rotation matrix from axis and angle.
Definition at line 290 of file sbgl_math.h.
Creates a scaling matrix.
Definition at line 269 of file sbgl_math.h.
Creates a translation matrix.
Definition at line 260 of file sbgl_math.h.
Creates a quaternion from an axis and an angle (in radians).
Definition at line 193 of file sbgl_math.h.
|
inlinestatic |
|
inlinestatic |
Creates a Quat.
Definition at line 103 of file sbgl_math.h.
Converts a quaternion to a rotation matrix.
Definition at line 210 of file sbgl_math.h.
|
inlinestatic |
|
inlinestatic |
Normalizes a Vec3.
Definition at line 162 of file sbgl_math.h.
|
inlinestatic |
Creates a Vec3, correctly padded.
Definition at line 93 of file sbgl_math.h.
|
inlinestatic |
Creates a Vec4.
Definition at line 98 of file sbgl_math.h.