LinearAlgebra
|
Copyright 2004-2016 Karljohan LundinThis file is a part of KJs Algebra 3D Package.
KJs Algebra 3D Package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
KJs Algebra 3D Package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with KJs Algebra 3D Package; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
I started developing this package because I needed a linear algebra package for the IRIX platform and found that the available packages does not focus on what I want — usability through intuitive use of operators.
This is an extendable template-based package for 3D linear algebra. As many operators as possible are overloaded for easy use and the code is kept simple and portable for easy deployment on any platform. For easy debugging and tests the print operators (<<) are also overloaded. This package is NOT optimized for speed.
The extensive implementation of operators and casting makes this package very effective for use with OpenGL. There are a number of especially nice notations that I will show here.
For example the matrix classes have data stored in column-major order for effective interfacing with OpenGL. Thus, fetching the projection matrix is a one row command:
a3d::Matrix4f Mm; glGetFloatv( GL_MODELVIEW_MATRIX, Mm );
This can also be done with vectors, for example colour.
Primarily this package is developed for simple notation. Vector and matrix operators are all implemented as operators. Also the cross product is implemented, here using the modulus operator (%) for nice looking code.
A side effect of the template structure of this package is that any type can be used as base for the algebra types. Algebra types using floating point data in single and double precision are typedefed, but fixed point data or complex types can also be used.
Another functionality that is nice in 3D environments is the fromScreenPosition
, that calculates the 3D position of a screen position and also the vector that points inwards at that point.
The A3D linear algebra package is only one single header file with all functions inline. This is required for correct template handling, however it also means that all you have to do is download a header file and included it to your C++ files.
The header file can be downloaded from http://www.itn.liu.se/~karlu20/div/A3D/bin
The latest version of this package is provided under GNU GPL. That means that any derived work, work that use the package or modified versions of this package must also be released as GNU GPL if it is released at all. You may keep both the source and binaries for yourself if you like. Contact me if you want to buy a license that does not force you to release your source code.