xo-math is an open source single header file module for optimized game math. C++11 or newer required.
xo-math is designed to be as fast as possible on your target platform, and thoroughly tested for performance against other alternatives.
xo-math is designed to be future-looking. We push simd math past what currently adopted platforms support and build solutions for the up and coming.
xo-math is designed to be friendly. Easy to use and easy to understand, xo-math has built it's license and API for mere mortals to comprehend. You should be able to understand what we're all about in 10 minutes or less, drag and drop xo-math.h into your project and start coding in just minutes more.
If you feel I've failed my mission here, please let me know.
Download xo-math.h, xo-math.cpp and xo-math-config.h from the root of the repo, include them in your project and you're good to go.
#include <iostream>
#include "xo-math.h"
using namespace std;
using namespace xo;
int main() {
Vector3 vec = Vector3::RandomOnConeRadians(Vector3::Up, HalfPI/2.0f);
cout << "random 45 degree cone vector from Vector3::Up: " << vec << endl;
if(vec == 1.0f) {
cout << "The vector is normalized." << endl;
}
Matrix4x4 tilt = Matrix4x4::RotationXDegrees(-90.0f);
tilt.Transform(vec);
cout << "Now rotated -90 degrees by the x axis: " << vec << endl;
float x, y, z;
vec.Get(x, y, z);
cout << "Extracted vector elements. x:" << x << " y:" << y << " z:" << z << endl;
return 0;
}
Here's what I know about compiler/platform support:
Compiler Name | Version | Supported? |
---|---|---|
clang++ | >=3.3 | Yes! |
g++ | >=4.8 | Yes! |
msvc | >=2012 | Yes! |
apple llvm | >=7.3 | Yes! |
apple llvm | >=5 | Probably? |
intel | >= 11.1 | Unknown.*** |
For inquires about closed platform support such as PlayStation 4, XBox One and Wii: please get in touch.
*** You can help: I'm accepting donations for intel paralell studio to ensure proper support of this compiler by xo-math. The fundraiser is on crowdrise here.
Documentation is hosted by Read The Docs: xo-math.rtfd.io