# HG changeset patch # User Eris Caffee # Date 1369024228 18000 # Node ID 2ac83ae9129becfac892c9fdb037824a6351daf5 # Parent ea32c94fc4951219e35efb91306d26045eb36b2b Added get_ortho_mat44() diff -r ea32c94fc495 -r 2ac83ae9129b include/Matrix.h --- a/include/Matrix.h Sun May 19 20:17:16 2013 -0500 +++ b/include/Matrix.h Sun May 19 23:30:28 2013 -0500 @@ -818,7 +818,7 @@ ////////////////////////////////////////////////////////////////////////// // Matrix functions // TODO: The determinant functions suffer from some bad round off error. - // If it significant? I don't know. None of the other game engines + // Is it significant? I don't know. None of the other game engines // I've checked bother to do anything to calculate det more accurately. // So maybe it just doesn't matter enough for game purposes. diff -r ea32c94fc495 -r 2ac83ae9129b include/Transform.h --- a/include/Transform.h Sun May 19 20:17:16 2013 -0500 +++ b/include/Transform.h Sun May 19 23:30:28 2013 -0500 @@ -39,14 +39,21 @@ // (x = 0, y = 1, z = 2) template void get_shear_mat44(arda::Math::Matrix44 & M, int i, int j, float s); - + + // Transformation matrix for combination of translation by d and rotation by angle around v. template void get_transform_mat44(arda::Math::Matrix44 & M, float angle, arda::Math::Vector3 v, arda::Math::Vector3 d); // Rotate by angle around v with center of rotation p. template void get_rot_about_point_mat44(arda::Math::Matrix33 & M, float angle, arda::Math::Vector3 v, arda::Math::Vector3 p); - + + //////////////////////////////////////// + // Projection matrices + + template + void get_ortho_mat44(arda::Math::Matrix44 & M, T near, T far, T left, T right, T bottom, T top); + } // namespace Math } // namespace arda @@ -196,4 +203,17 @@ M[15] = T(1); } +//////////////////////////////////////////////////////////////////////////////// +template +void arda::Math::get_ortho_mat44(arda::Math::Matrix44 & M, T near, T far, T left, T right, T bottom, T top) + { + M.assign( + 2 / (right - left), T(0), T(0), T(0), + T(0), 2 / (top - bottom), T(0), T(0), + T(0), T(0), - 2 / (far - near), T(0), + - (right + left) / (right - left), - (top + bottom) / (top - bottom), - (far + near) / (far - near), T(1) ); + + } + + #endif