Hypatia
|
The fastest way to get started is to grab the header file. It's self-contained. The file is called hypatia.h
Hypatia, a Greek mathematician, 355-415 C.E. Considered by many to be the first female mathematician of note.
Hypatia is a single-file-header, pure-C math library. It is almost 100% C89/C90 compliant. This library is intended for use in 2d/3d graphics program (such as games). Since it is not a general purpose math library, but a library meant for 3d graphics, certain opinions have been expressed in its design. One of those design choices, intended to help with speed, is that all objects (quaternions, matrices, vectors) are mutable. (That means that the objects change their values.) This was a purposeful design choice. Construct your program around this choice.
The entire library is self-contained in this one header file. The file can be used in a header mode or implementation mode. The header mode is used by default and is what you are using when you simple #include
this file. It does not compile-in the actual implementation. To compile-in the actual implementation, you need to also use implmentation mode. The implementation mode requires the macro HYPATIA_IMPLEMENTATION
exist in one .c/.cpp file in your project before an #include <hypatia.h>
.
Like so:
A great way to learn how to use the library is to review the unit tests.
View the official documentation here.
A goal of the unit tests is to test each function against HYP_EPSILON which is defined in hypatia.h, currently as 1E-5. A number of functions do not yet have unit tests proving 1E-5, but more are coming.
Hypatia uses verbose names. In pure-C code, math-related function names seem to end up either cryptic (m4mul), verbose (matrix4_multiplym4) or ambiguous (multiply). C++ is a little better in this respect, because there is operator and function overloading (gracefully allows for ambiguous names). When Hypatia was shown around before its release, the chief complaint was "it has verbose names".
As an experiment, some #defines have been added to alias the verbose names. (mat4, vec3, vec4, quat, etc) At this point, the primary API is the verbose names and the experimental API has some of the shorter, cryptic names. In fact, only a small portion of the entire API has been aliased in this way. My intention to keep one and toss the other. I would like your feedback about that.
make -f check.mak
Mathematical bug fixes should have a unit test with 1 or more test cases indicating what the problem was and now ensuring that it is fixed.
This project accepts and welcomes contributions.
The rules are pretty simple:
1) if you can certify the below: (Borrowed from the Linux Kernel Project)
2) then you just add a line saying:
You must use your real name.
This will be done for you automatically if you use git commit -s
.
Along the way, I found that some of the terminology used concerning quaternions was not consistent. For example, there is confusion about the difference between a quaternion's "norm", "normalizing a quaternion" and the quaternion's "magnitude". Not having a formal background in linear algebra, I found things like this very confusing. Part of the reason that I wanted to build this library was to finally learn all of this material for myself; once having done that, share it with others.
Matrix and Quaternion FAQ
The Matrix-Quaternion FAQ was extremely helpful as far as teaching me the math. I originally came upon that document a long time ago as a student (late 1990's) and had forgotten about it until a friend (Jason Hughes) reintroduced me to it. At that reintroduction, I got the feeling hat this document was in danger of being lost at the bottom of the Internet. At the time, it was rather hard to find. I decided to "save it" by including it in this library in the "docs" folder. If the original authors do not appreciate this, I am happy to remove it. Keep in mind however that the doc does say: "Feel free to distribute or copy this FAQ as you please." I credit it as a source for some of the routines used in Hypatia and I hereby thank its authors for their hardwork in its creation.
Web Sites
When I read through the Mat-Quat FAQ, I found the notes about corrections that were made, but I still found that there were differences between what the doc says, various pages around the Internet say and some math books that I assumed were reliable texts. I would like to credit some of those reliable sources here:
People
As I went a long, I also found that I needed help from people willing to talk to me about this. I credit those kind people here:
Author
The hypatia math library is primarily the work of one author: