Game Math and Geometry Library
My C++ library for 3D mathematics and geometry manipulation.
If you do not like my library, then perhaps one of these packages works for you better. This list has been collected from the names I have seen pop up at GameDev discussion forums. These are the ones that people are probably using the most. Note that this page is not trying to argue that any of these libraries are bad, but only compares them to my library, and tries to explain the reasons why I did not want to use them.
From their homepage: "Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms." There is a huge development team behind Eigen. It can do generic N-by-M matrices and N-vectors, using a custom type T as scalar, which this library cannot do. It can also be used for 2D and 3D operations, see the handy typedefs page. Eigen has a very powerful set of solvers and algorithms for different matrix decompositions, which I do not care about. It also contains the Geometry module, which has classes AlignedBox (AABB in my library) and Quaternion. Eigen uses doxygen for its reference documentation, and I found it difficult to browse (see e.g. here). They do have an extensive set of tutorials however. It lacks other geometry classes found in my library, and I didn't want to base my library on templates, so I had to pass on it. Eigen is dual-licensed under LGPL3+ and GPL2+.
From their homepage: "The CML (Configurable Math Library) is a free C++ math library for games and graphics." This library uses templates extensively, both for vector/matrix sizes and scalar types. It contains classes vector, matrix and quaternion. They also template based on row/column major storage and the M*v or v*M convention. CML has some utility functions similar to my Frustum class (point projection, picking, frustum management), but apart from that, it does not contain functionality for geometric objects, therefore it was not the library I was looking for. CML is licensed under the Boost Software License.
From their homepage: "OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specification." It organizes its development similar to OpenGL - using an extension registry for new features. GLM has classes for matrix, vector and quaternion, but nothing for geometry manipulation. I did not like the template-based implementation, and there is nothing for geometric objects, so I decided to pass. GLM is licensed under the MIT license.
The Qt toolkit also comes with classes for linear algebra. They have classes QVector2D, QVector3D, QVector4D, QQuaternion, QGenericMatrix and QMatrix4x4. The Qt documentation is quite usable compared to doxygen output. I regard their implementation of QMatrix4x4 having somewhat questionableoptimizations (comparisons aren't exactly free!), and their lack of using fuzzy comparisons is more than a bit fishy. The provided functionality on the vector and matrix classes is somewhat lacking for 3D games purposes, and they don't have any geometric objects either. I decided to leave this be as well. Qt is licensed under LGPL.
The Ogre3D rendering engine (MIT License) also comes with its own math and geometry routines. There are basic math classes Vector2, Vector3, Vector4, Matrix3 (3x3 matrix), Matrix4 (4x4 matrix) and Quaternion. For geometric operations, it has the classes AxisAlignedBox, Ray, Frustum (not strictly a value type), Polygon, Plane, PlaneBoundedVolume (convex polyhedron) and Sphere. This is the most comprehensive set of functionality I have found for my purpose, and for a while I was using Ogre exactly because of this, but after a hands-on experience, I felt unsatisfied due to poor documentation, unwritten conventions and missing functionality.
Irrlicht is another open source engine (zlib/libpng license). They have classes irr::core::aabbox3d<T> (AABB), irr::core::CMatrix4<T>, irr::core::line2d<T>, irr::core::line3d<T>, irr::core::plane3d<T>, irr::core::quaternion, irr::core::triangle3d<T>, irr::core::vector2d<T> and irr::core::vector3d<T>. Overall, this library is better documented than Ogre, but they have fewer geometric object types. Their wording is a bit odd in places (e.g. 1, 2, 3) and I did not like their handling of Eulerrotations. The lack of geometric types and the use of templates had me look elsewhere.
If you are on Windows, you can utilize the Microsoft D3DX library, which is a utility DLL that ships with the DirectX package. It has classes D3DXVECTOR2, D3DXVECTOR3, D3DXVECTOR4, D3DXQUATERNION, D3DXMATRIX (4x4 matrix) and D3DXPLANE. It has an extensive set of operations available for matrices, vectors and quaternions, but only a single geometric function D3DXPlaneIntersectLine. The documentation for D3DX is excellent and clean, but I did not like the C API, and using D3DX would have meant a Windows-only library. Pass.
Boost.Geometry and Boost.Polygon
Of course, Boost has its own libraries for the purpose: Boost.Geometry and Boost.Polygon. It should naturally be expected that Boost comes filled with template machinery, and these libraries are surely no exception. Looking at the Boost.Geometry introduction page, it has chapter headers like: Using Templates, Using Traits, Dimension Agnosticism, Coordinate Type, Coordinate System, Point Concept. The summary of the same page says "In this design rationale, Boost.Geometry is step by step designed using tag dispatching, concepts, traits, and metaprogramming.". The documentation contains a reference matrix for the contents Boost.Geometry. Interestingly, very much from what I would have expected, it does not have a single three-dimensional geometric object built in to it (but I'm sure it can be extended to do so). Boost.Polygon is a library solely intended for managing 2D polygons.
The whole Boost library has become to me a paragon of genericity, extensibility, and unfortunately, incomprehensibility and sub-par reference documentation. For an example, this is how Boost.Geometry defines an AABB. Skip. Skip!
The Wykobi library is something I stumbled upon at very random, while trying to search for help related to Eigen SSE optimizations. I don't know anyone who is using this library, but looking at their Features page, I like it! However, Wykobi is licensed under GPL2, which I do not approve, and therefore I have not put further interest into it.
The CGAL library is a beast. It probably has all the functionality one might need for professional grade geometry library, but their licensing page is unclear, and does not directly specify what is licensed under LGPL and what is under the more restrictive QPL. The library also uses templates extensively. Here is an example of how to compute 3D sphere intersections. Trying to follow their manual, I tried to figure out how to do a Frustum-Sphere intersection with that library, but had to give up. It is obvious that the library is too much for me to handle.
Wild Magic 5.6
David Eberly maintains a webpage that is a companion for the books he has (co-)authored. This site is a treasure trove of information, and several implementations of the algorithms in my library are based on their book Geometric Tools for Computer Graphics. The website has a downloadable package of the Wild Magic 5.6 library, released under the Boost license, but I don't like the code provided on the site, mainly because of the heavy use of templates, namespacing and name decoration. I heartily recommend their books, but avoid the code myself.
I also ran into the following libraries, but for some reason, discarded them rather quickly from consideration (inactive, not enough features, undocumented, bad license, too unwieldy, different purpose, etc.):
- Steve's Portable Game Library.
- Andrew Aye's Teikitu Gaming System.
- Geometros sgCore solid modeling library.
- GNU Triangulated Surface Library (GTS).
Write Your Own
You looked at my source code, and laughed your ass off? "What a POS..". Well, I hope you had a good one. Go ahead and write your own then. The realtimerendering.com object/object intersection page is probably the place to start. Also, basing your implementation on books is strongly recommended, simply because of the amount of review that (hopefully) goes into them. See realtimerendering.com books reference and GameDev.net books reference for sources. If I may place a recommendation, anything coming from Christer Ericson, David Eberly, Eric Lengyel or Wolfgang Engel is worth a buy.