vmath
Quick nav
News
- 15. July 2018 - fixed Matrix4<T>::createFrustum (thanks to Julian.Zhu)
- 3. November 2016 - matrix multiplication made reentrant (thanks to Julian.Zhu)
- 26. October 2014 - added Aabb3<T> class for axes-aligned bounding-box (inspired by vmath modification by Allen King)
- 20. November 2011 - added Matrix4<T>::createLookAt() method, thanks to Edward Woolhouse
- 10. July 2011 - multiple fixes around quaternions, matrix operator() accessor thanks to Davide Bacchet, added some static Matrix4<T> creators
- 24. April 2011 - fixed inverse of Matrix4<T>, added inverse and determinant for Matrix3<T> thanks to Rober Green
- 9. November 2009 - length() and lengthSq() marked as constant methods — thanks to Kyle McDonald
- 22. January 2008 - Fixed finding of ivnersion matrix (4x4 only)
- 7. November 2007 - Fixed quaternion multiplication, added unary operators for negation and quaternion conjugation
- 6. August 2007 - Finally I fixed quaternion to matrix conversion, thanks to Charles
- 27. November 2006 - Added conversion constructors and operator='s, see Features
- 17. September 2006 - as LGPL license seems to be pruposed only for dynamicly linked libraries,
I decided to change vmath license to BSD license (new, modified - it means compatible with GNU/GPL)
- 12. September 2006 - small fixes, vmath clearly declared to be licensed under GNU/LGPL license
- 23. June 2006 - fixed Quaternuin<T> rotMatrix() and transform() methods
- 21. June 2006 - fixed multiplaction of Matrix3<T> by Vector2<T>
- 5. February 2006 - fixed operator!= bugs
Intro
vmath is set of C++ classes for Vector and Matrix algebra used in computer graphics. The library consits of these classes:
- Vector2 - two dimensional vector for 2D vertices and texture coordinates
- Vector3 - three dimensional vector for 3D vertices, normals and texture coordinates and also for color
- Vector4 - four dimensional vector for 3D vertices, normals, texture coordinates and color with alpha channell.
- Matrix3 - matrix 3x3 for rotation (used in ODE)
- Matrix4 - matrix 4x4 for general geometrix transformations
- Quaternion - quaternion re 3x im, for rotation
- Aabb3 - axes-aligned bounding box
Note that this library is set of C++ class that has all(!) method inlined. (for performance reasons)
Features
- basic aritemetic operations - using operators
- basic linear algebra operations - such as transpose, dot product, etc.
- aliasis for vertex coordinates - it means:
Vector3f v;
// use vertex coordinates
v.x = 1; v.y = 2; v.z = -1;
// use texture coordinates
v.s = 0; v.t = 1; v.u = 0.5;
// use color coordinates
v.r = 1; v.g = 0.5; v.b = 0;
- conversion constructor and assign operators - so you can assign a value of Vector3<T1> type
to a variable of Vector3<T2> type for any convertable T1, T2 type pairs. In other words, you can do this:
Vector3f f3; Vector3d d3 = f3;
...
f3 = d3;
Status
- Classes Vector2<T>, Vector3<T>, Vector4<T> are supposed to be stable. I have been using these libraries for
two or three years.
- Classes Matrix3<T>, Matrix4<T> were tested for barely all operations and seems to be everything OK.
- Class Quaternion<T> was tested for barely all operations and seems to be good.
Tricks
You can pass vector or matrix class directly as argument appropriate OpenGL function,
Vector2f t;
Vector3f n,v;
Matrix4f transform;
glMultiMatrixf(transform);
glTexCoord2fv(t);
glNormal3fv(n);
glVertex3fv(v);
Todo
- add Quternion class for rotation [ DONE ]
- solve finding inversion matrix for Matrix4 [ DONE ]
- add inversion of matrix for Matirx3 [ DONE ]
- Proper testing [ DONE ]