All Projects → felselva → Mathc

felselva / Mathc

Licence: zlib
Pure C math library for 2D and 3D programming

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Mathc

Spatialmath Python
Create, manipulate and convert representations of position and orientation in 2D or 3D using Python
Stars: ✭ 78 (-84.52%)
Mutual labels:  graphics, 3d, 2d, math
Sophus
C++ implementation of Lie Groups using Eigen.
Stars: ✭ 1,048 (+107.94%)
Mutual labels:  graphics, 3d, 2d, math
Unitymathreference
Math reference for games and more. All visualized in Unity3D.
Stars: ✭ 166 (-67.06%)
Mutual labels:  3d, 2d, math
Aardvark.base
Aardvark is an open-source platform for visual computing, real-time graphics and visualization. This repository is the basis for most platform libraries and provides basic functionality such as data-structures, math and much more.
Stars: ✭ 117 (-76.79%)
Mutual labels:  graphics, math, matrices
Mathnet Spatial
Math.NET Spatial
Stars: ✭ 246 (-51.19%)
Mutual labels:  3d, 2d, math
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (-69.84%)
Mutual labels:  graphics, 3d, 2d
Spritejs
A cross platform high-performance graphics system.
Stars: ✭ 4,712 (+834.92%)
Mutual labels:  3d, 2d
Von Grid
Hexagonal & square tile grid system with three.js
Stars: ✭ 336 (-33.33%)
Mutual labels:  3d, 2d
Software
DeepValueNetwork is a peer-to-peer database network managed and hosted by its community. It contains a browser to render 2D/3D content and allow the creation of scripted applications built on top of the p2p database network and managed by its creators, without intermediary platform.
Stars: ✭ 357 (-29.17%)
Mutual labels:  3d, 2d
Beam
✨ Expressive WebGL
Stars: ✭ 383 (-24.01%)
Mutual labels:  graphics, 3d
Webgl Fundamentals
WebGL lessons that start with the basics
Stars: ✭ 3,315 (+557.74%)
Mutual labels:  3d, math
Tinyraytracer
A brief computer graphics / rendering course
Stars: ✭ 3,971 (+687.9%)
Mutual labels:  graphics, 3d
Cpp 3d Game Tutorial Series
C++ 3D Game Tutorial Series is a YouTube tutorial series, whose purpose is to help all those who want to take their first steps in the game development from scratch.
Stars: ✭ 400 (-20.63%)
Mutual labels:  graphics, 3d
Magnum
Lightweight and modular C++11 graphics middleware for games and data visualization
Stars: ✭ 3,728 (+639.68%)
Mutual labels:  graphics, 3d
React Particles Webgl
🔆 A 2D/3D particle library built on React, Three.js and WebGL
Stars: ✭ 330 (-34.52%)
Mutual labels:  3d, 2d
Vue Babylonjs
A ready-to-go 3d environment for Vue.js using Babylon.js
Stars: ✭ 356 (-29.37%)
Mutual labels:  graphics, 3d
Medpy
Medical image processing in Python
Stars: ✭ 321 (-36.31%)
Mutual labels:  3d, 2d
Libgdx
Desktop/Android/HTML5/iOS Java game development framework
Stars: ✭ 19,420 (+3753.17%)
Mutual labels:  3d, 2d
Lume
Create CSS3D/WebGL applications declaratively with HTML. Give regular DOM elements shadow and lighting.
Stars: ✭ 445 (-11.71%)
Mutual labels:  graphics, 3d
Vue Gl
Vue.js components rendering 3D WebGL graphics reactively with three.js
Stars: ✭ 434 (-13.89%)
Mutual labels:  graphics, 3d

MATHC

MATHC is a simple math library for 2D and 3D programming.

Features

  • Vectors (2D, 3D and 4D) (integer type and floating-point type)
  • Quaternions
  • Matrices (2×2, 3×3, and 4×4)
  • Easing functions

Contributions and Development

You can help with the development of MATHC testing the library, sending in-scope math functions, reporting errors and giving feedback.

I work little on the library nowadays, but I am always open to suggestions and contributions.

Versioning

Starting on version 2, the development of MATHC uses calendar versioning, with a tag YYYY.MM.DD.MICRO for each stable release. If a release breaks backward compatibility, then it is mentioned in the release notes.

Configuring

MATHC can be configured using these preprocessors:

  • MATHC_NO_INT: disable implementations using mint_t.
  • MATHC_USE_INT8: define mint_t as int8_t.
  • MATHC_USE_INT16: define mint_t as int16_t.
  • MATHC_USE_INT32: define mint_t as int32_t. This is the default.
  • MATHC_USE_INT64: define mint_t as int64_t.
  • MATHC_INT_TYPE: set a custom type for mint_t.
  • MATHC_NO_FLOATING_POINT: disable implementations using mfloat_t.
  • MATHC_USE_SINGLE_FLOATING_POINT: define mfloat_t as float. This is the default.
  • MATHC_USE_DOUBLE_FLOATING_POINT: define mfloat_t as double.
  • MATHC_FLOATING_POINT_TYPE: set a custom type for mfloat_t.
  • MATHC_USE_UNIONS: define anonymous unions inside structures.
  • MATHC_NO_POINTER_STRUCT_FUNCTIONS: don't define the functions that take pointer to structures.
  • MATHC_NO_STRUCT_FUNCTIONS: don't define the functions that take structures as value.
  • MATHC_NO_EASING_FUNCTIONS: don't define the easing functions.

You can define these preprocessors using the compiler's option -D or using the compiler's option -include to include a configuration header with the configuration preprocessors inside it.

Example of a configuration header that makes mint_t a int16_t, mfloat_t a GLfloat and uses the standard math functions with double floating-point precision:

#include <gl.h>

#define MATHC_USE_INT16
#define MATHC_FLOATING_POINT_TYPE GLfloat
#define MATHC_USE_DOUBLE_FLOATING_POINT

Types

By default, vectors, quaternions and matrices can be declared as arrays of mint_t, arrays of mfloat_t, or structures.

Functions

By default, MATHC has functions that take as argument arrays of mint_t, arrays of mfloat_t, structures as value, or pointer to structures. Functions that take structure as value have a prefix s. Functions that take structure pointer have a prefix ps.

Easing Functions

The easing functions are an implementation of the functions presented in easings.net, useful particularly for animations.

Easing functions take a value inside the range 0.0-1.0 and usually will return a value inside that same range.

Usage

Creating a "look at" view matrix, useful for 3D programming:

mfloat_t position[VEC3_SIZE];
mfloat_t target[VEC3_SIZE];
mfloat_t up[VEC3_SIZE];
mfloat_t view[MAT4_SIZE];

mat4_look_at(view,
	vec3(position, 0.0, 0.0, 10.0),
	vec3(target, 0.0, 0.0, 0.0),
	vec3(up, 0.0, 1.0, 0.0));

Creating a perspective projection matrix:

mfloat_t perspective[MAT4_SIZE];

mat4_perspective(perspective, to_radians(60.0), 1.0, 0.1, 100.0);

Creating a model matrix:

mfloat_t position[VEC3_SIZE];
mfloat_t scaling[VEC3_SIZE];
struct {
	mfloat_t position[MAT4_SIZE];
	mfloat_t rotation[MAT4_SIZE];
	mfloat_t scaling[MAT4_SIZE];
	mfloat_t model[MAT4_SIZE];
} matrices;

/* Position */
mat4_identity(matrices.position);
mat4_translation(matrices.position,
	vec3(position, 0.0, 0.0, 0.0));

/* Rotation */
mat4_identity(matrices.rotation);
mat4_rotation_x(matrices.rotation, to_radians(30.0));

/* Scaling */
mat4_identity(matrices.scaling);
mat4_translation(matrices.scaling,
	vec3(scaling, 1.0, 1.0, 1.0));

/* Model matrix */
mat4_multiply(matrices.model, matrices.scaling, matrices.rotation);
mat4_multiply(matrices.model, matrices.position, matrices.model);

License

Copyright © 2018 Felipe Ferreira da Silva

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].