felselva/mathc logo

felselva/mathc

Free

Pure C math library for 2D and 3D programming

FreeFree tier
Type
Open Source

About felselva/mathc

MATHC is a simple pure C math library designed for 2D and 3D programming. It provides vectors (2D, 3D, and 4D) with both integer and floating-point types, quaternions, matrices (2×2, 3×3, and 4×4), and easing functions based on easings.net. The library can be configured via preprocessor macros to adjust integer and floating-point types, enable/disable features, and control structure representation (arrays or structs). Example usage includes creating look-at view matrices, perspective projection matrices, and model matrices for 3D graphics. The main repository is on GitHub under the MIT license (implied).

Key Features

Vectors (2D, 3D, 4D) with integer and floating-point types
Quaternions for rotation representation
Matrices (2×2, 3×3, 4×4) for transformations
Easing functions (from easings.net) for animations
Configurable via preprocessor macros (type size, union support, optional features)
Supports both array and struct representations
Functions accept arrays, structs by value, or pointer to structs
Provides look-at and perspective projection functions for 3D graphics

Pros & Cons

Pros
  • Lightweight and simple – no external dependencies
  • Configurable integer and floating-point precision
  • Supports both integer and floating-point vectors (2D, 3D, 4D)
  • Includes easing functions for animations
  • Open source (MIT license) and free to use
  • Functions available for arrays and structs (by value and by pointer)
Cons
  • Limited to basic linear algebra – no advanced features like SIMD
  • Maintainer notes current limited activity ('I work little on the library nowadays')
  • Documentation is limited to the README
  • No official package manager distribution (manual integration required)

Best For

3D graphics programming (view, projection, model matrices)Game development (vector math, transformations, animations)Animation easing functions for smooth interpolationComputer graphics math operations in C/C++ projects

FAQ

What is MATHC?
MATHC is a pure C math library for 2D and 3D programming. It provides vectors, quaternions, matrices, and easing functions.
What features does MATHC provide?
MATHC includes vectors (2D, 3D, 4D) with integer and floating-point types, quaternions, matrices (2×2, 3×3, 4×4), and easing functions. It can be configured via preprocessor macros.
How do I configure MATHC?
You can define preprocessor macros such as MATHC_USE_INT16, MATHC_USE_DOUBLE_FLOATING_POINT, or MATHC_NO_EASING_FUNCTIONS to adjust types and features. These can be passed via the compiler -D option or a configuration header.
Is MATHC actively maintained?
The maintainer notes that they work little on the library nowadays but are open to suggestions and contributions.
What are some usage examples?
Examples include creating a look-at view matrix, perspective projection matrix, and model matrix for 3D graphics. The README provides code snippets.