← Back

ofxKazmath

github.com/danoli3/ofxKazmath · @danoli3
OF 0.12 Utilities Algorithms

ofxKazmath is an openFrameworks addon that provides a collection of mathematical functions and utilities for graphics programming.

1 0 Last commit 1mo ago Created 12y ago

README

ofxKazmath



openFrameworks addon wrapping kazmath โ€” a lightweight 3D math library aimed at game programming, by Luke Benstead (with contributions from Carsten Haubold).

It gives you plain-C math types with no dependencies, handy when you want to do your own matrix / vector / quaternion math without pulling in a bigger library.

ofxaddons thumbnail

Features



Bundled kazmath provides:

Installation



Copy this folder into your openFrameworks addons/ directory as ofxKazmath, then:

No external dependencies โ€” kazmath is bundled under libs/kazmath and built as C.

Usage



#include "ofxKazmath.h"

kmMat4 translation;
kmMat4Translation(&translation, pos.x, pos.y, pos.z);

kmMat4 rotation;
kmVec3 axis = { pos.x, pos.y, pos.z };
kmMat4RotationAxisAngle(&rotation, &axis, kmDegreesToRadians(35.0f));

ofMultMatrix(&translation.mat[0]);
ofMultMatrix(&rotation.mat[0]);
ofDrawBox(boxSize);


See example/ for a full demo: a noise-driven cloud of textured boxes transformed with kmMat4Translation and kmMat4RotationAxisAngle.

Converters



ofxKazmath.h also provides toKM / toOF overloads converting between openFrameworks types (ofMatrix4x4, ofMatrix3x3, ofVec2f/3f/4f, ofQuaternion) and their kazmath counterparts. oF matrices are row-major, kazmath is column-major, so matrix conversion transposes โ€” all converters are lossless round-trips:

ofMatrix4x4 ofMat = / ... /;
kmMat4 kmMat = toKM(ofMat);
ofMatrix4x4 back = toOF(kmMat); // == ofMat


Compatibility



Plain C89 code, should build anywhere openFrameworks builds (macOS, Windows, Linux). Tested with the bundled Xcode example project on macOS.

License



Get this addon

HTTPS
SSH