Mercurial > Math
changeset 16:2ac83ae9129b
Added get_ortho_mat44()
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Sun, 19 May 2013 23:30:28 -0500 |
parents | ea32c94fc495 |
children | f49d8ba063ca |
files | include/Matrix.h include/Transform.h |
diffstat | 2 files changed, 23 insertions(+), 3 deletions(-) [+] |
line diff
1.1 --- a/include/Matrix.h Sun May 19 20:17:16 2013 -0500 1.2 +++ b/include/Matrix.h Sun May 19 23:30:28 2013 -0500 1.3 @@ -818,7 +818,7 @@ 1.4 ////////////////////////////////////////////////////////////////////////// 1.5 // Matrix functions 1.6 // TODO: The determinant functions suffer from some bad round off error. 1.7 - // If it significant? I don't know. None of the other game engines 1.8 + // Is it significant? I don't know. None of the other game engines 1.9 // I've checked bother to do anything to calculate det more accurately. 1.10 // So maybe it just doesn't matter enough for game purposes. 1.11
2.1 --- a/include/Transform.h Sun May 19 20:17:16 2013 -0500 2.2 +++ b/include/Transform.h Sun May 19 23:30:28 2013 -0500 2.3 @@ -39,14 +39,21 @@ 2.4 // (x = 0, y = 1, z = 2) 2.5 template <typename T> 2.6 void get_shear_mat44(arda::Math::Matrix44<T> & M, int i, int j, float s); 2.7 - 2.8 + 2.9 + // Transformation matrix for combination of translation by d and rotation by angle around v. 2.10 template <typename T> 2.11 void get_transform_mat44(arda::Math::Matrix44<T> & M, float angle, arda::Math::Vector3<T> v, arda::Math::Vector3<T> d); 2.12 2.13 // Rotate by angle around v with center of rotation p. 2.14 template <typename T> 2.15 void get_rot_about_point_mat44(arda::Math::Matrix33<T> & M, float angle, arda::Math::Vector3<T> v, arda::Math::Vector3<T> p); 2.16 - 2.17 + 2.18 + //////////////////////////////////////// 2.19 + // Projection matrices 2.20 + 2.21 + template <typename T> 2.22 + void get_ortho_mat44(arda::Math::Matrix44<T> & M, T near, T far, T left, T right, T bottom, T top); 2.23 + 2.24 } // namespace Math 2.25 2.26 } // namespace arda 2.27 @@ -196,4 +203,17 @@ 2.28 M[15] = T(1); 2.29 } 2.30 2.31 +//////////////////////////////////////////////////////////////////////////////// 2.32 +template <typename T> 2.33 +void arda::Math::get_ortho_mat44(arda::Math::Matrix44<T> & M, T near, T far, T left, T right, T bottom, T top) 2.34 + { 2.35 + M.assign( 2.36 + 2 / (right - left), T(0), T(0), T(0), 2.37 + T(0), 2 / (top - bottom), T(0), T(0), 2.38 + T(0), T(0), - 2 / (far - near), T(0), 2.39 + - (right + left) / (right - left), - (top + bottom) / (top - bottom), - (far + near) / (far - near), T(1) ); 2.40 + 2.41 + } 2.42 + 2.43 + 2.44 #endif