Mercurial > Math
changeset 17:f49d8ba063ca
Perspective matrix functions and soem Doxygen docs
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Mon, 27 May 2013 00:53:55 -0500 |
parents | 2ac83ae9129b |
children | f9fb659509e1 |
files | include/Math.h include/Transform.h |
diffstat | 2 files changed, 40 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- a/include/Math.h Sun May 19 23:30:28 2013 -0500 1.2 +++ b/include/Math.h Mon May 27 00:53:55 2013 -0500 1.3 @@ -134,7 +134,13 @@ 1.4 1.5 ////////////////////////////////////////////////////////////////////////// 1.6 1.7 + /** \brief Converts degrees to radians 1.8 + */ 1.9 inline double deg_to_rad(double deg) { return deg * PI_DIV_180; }; 1.10 + 1.11 + 1.12 + /** \brief Converts radians to degrees. 1.13 + */ 1.14 inline double rad_to_deg(double rad) { return rad * INV_PI_DIV_180; }; 1.15 1.16 } // namespace Math
2.1 --- a/include/Transform.h Sun May 19 23:30:28 2013 -0500 2.2 +++ b/include/Transform.h Mon May 27 00:53:55 2013 -0500 2.3 @@ -4,6 +4,8 @@ 2.4 // Needs Vector.h and Matrix.h, but this file is not intended to be included 2.5 // directly. Just include Math.h and everything will be set up correctly. 2.6 2.7 +#include <iostream> 2.8 + 2.9 namespace arda 2.10 { 2.11 namespace Math 2.12 @@ -54,6 +56,12 @@ 2.13 template <typename T> 2.14 void get_ortho_mat44(arda::Math::Matrix44<T> & M, T near, T far, T left, T right, T bottom, T top); 2.15 2.16 + template <typename T> 2.17 + void get_persp_mat44(arda::Math::Matrix44<T> & M, T near, T far, T left, T right, T bottom, T top); 2.18 + 2.19 + template <typename T> 2.20 + void get_persp_inf_mat44(arda::Math::Matrix44<T> & M, T near, T far, T left, T right, T bottom, T top); 2.21 + 2.22 } // namespace Math 2.23 2.24 } // namespace arda 2.25 @@ -215,5 +223,31 @@ 2.26 2.27 } 2.28 2.29 +//////////////////////////////////////////////////////////////////////////////// 2.30 +template <typename T> 2.31 +void arda::Math::get_persp_mat44(arda::Math::Matrix44<T> & M, T near, T far, T left, T right, T bottom, T top) 2.32 + { 2.33 + M.assign( 2.34 + (2 * near) / (right - left), T(0), T(0), T(0), 2.35 + T(0), (2 * near) / (top - bottom), T(0), T(0), 2.36 + (right + left) / (right - left), (top + bottom) / (top - bottom), - (far + near) / (far - near), T(-1), 2.37 + T(0), T(0), - (2 * near * far) / (far - near), T(0) 2.38 + ); 2.39 + 2.40 + } 2.41 + 2.42 +//////////////////////////////////////////////////////////////////////////////// 2.43 +template <typename T> 2.44 +void arda::Math::get_persp_inf_mat44(arda::Math::Matrix44<T> & M, T near, T far, T left, T right, T bottom, T top) 2.45 + { 2.46 + M.assign( 2.47 + (2 * near) / (right - left), T(0), T(0), T(0), 2.48 + T(0), (2 * near) / (top - bottom), T(0), T(0), 2.49 + (right + left) / (right - left), (top + bottom) / (top - bottom), T(-1), T(-1), 2.50 + T(0), T(0), - 2 * near, T(0) 2.51 + ); 2.52 + 2.53 + } 2.54 + 2.55 2.56 #endif