A somewhat incomplete, pure-
C implementation of a
3D Linear
Algebra
System with no dependencies, because
none existed when I started writing video game engines. It features the functions that I've needed so far, and is debugged to the degree that
I've needed so far. Work continues as the games becomes more sophisticated. Some functions have explicit wide SIMD versions for parallel processing
of sets of data.
MIT licensed, see LICENSE file. I intend to release my portions of the code under Public Domain, but there are some functions which might
have a 3rd-party MIT license depending on the legal disposition of a modified version of a C port of an MIT-licensed glsl function.
Compiling
Repos:
Github
Notabug (Currently down due to the Goddamn AI scrapers. Fuck Sam Altman.)
Gitlab
Codeberg
Symlink or copy the code into your project however you wish, #include "c3dlas/c3dlas.h",
and add c3dlas/c3dlas.c to your build files.
Return Values
Some functions return integers corresponding to the following enums, in the format C3DLAS_*:
| FALSE | False. |
| TRUE | True. |
| COPLANAR | The respective objects are coplanar but not necessarily parallel. |
| FRONT | Front-face of a triangle. |
| BACK | Back-face of a triangle. |
| INTERSECT | The two objects intersect. |
| DISJOINT | The two objects do not intersect. |
| PARALLEL | The respective objects are parallel. |
| CW | Clockwise. |
| CCW | Counter-clockwise. |
| UNKNOWN | The situation cannot be classified by ths function. |
The enum is typedefed to C3DLAS_retval_t but is not used consistently yet for historical reasons. String names of the
enums can be found in extern char const * const C3DLAS_retval__names[];.
Complete Features
These will see very little change, aside from addition of the odd helper or obscure function.
- [docs] Vector math in 2, 3, and 4 dimensions for floats, doubles, ints, and longs, with structs, typedefs,
and helper macros. All basic math functions are implemented. There are _Generic()-based macros to automatically select the correct function
based on the type of the first argument. Most functions have literal and pointer versions.
- [docs] Quaternion math for floats, with structs and typedefs. All basic basic math functions
are implemented. Quaternion is a typedef of Vector4 for mutual function compatibility.
- [docs] Matrix math in 4 dimensions, with structs and typedefs. All basic basic math functions
are implemented, as well as all the more common advanced operations used in 3D rendering.
- [docs] Bezier and Catmull-Rom splines.
Essentially Complete Features
These features have a good function coverage but may not include every useful function yet.
- [docs] 2D Polygon operations. Most operations are supported, but there are a lot of obscure, difficult
to implement, but perfectly legitimate operations that can be done on polygons.
- [docs] Matrix math in 2 and 3 dimensions.
- [docs] Miscellaneous math functions.
- [docs] PCG random number generation. 32-bit only.
Features with Sporadic Coverage
Function names in this category are not yet completely systematic and may change with no notice.
- [docs] Line functions in 2 and 3 dimensions.
- [docs] Plane functions
- [docs] Triangle functions in 2 and 3 dimensions
- [docs] Circle and sphere functions
- [docs] Rectangle and box functions
- [docs] Matrix math in 2 and 3 dimensions.
- [docs] Inertia functions for a few shapes.