Home | History | Annotate | Download | only in gtx
      1 ///////////////////////////////////////////////////////////////////////////////////////////////////
      2 // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
      3 ///////////////////////////////////////////////////////////////////////////////////////////////////
      4 // Created : 2009-08-29
      5 // Updated : 2009-08-29
      6 // Licence : This source is under MIT License
      7 // File    : glm/gtx/matrix_operation.inl
      8 ///////////////////////////////////////////////////////////////////////////////////////////////////
      9 
     10 namespace glm
     11 {
     12 	template <typename T, precision P>
     13 	GLM_FUNC_QUALIFIER detail::tmat2x2<T, P> diagonal2x2
     14 	(
     15 		detail::tvec2<T, P> const & v
     16 	)
     17 	{
     18 		detail::tmat2x2<T, P> Result(static_cast<T>(1));
     19 		Result[0][0] = v[0];
     20 		Result[1][1] = v[1];
     21 		return Result;
     22 	}
     23 
     24 	template <typename T, precision P>
     25 	GLM_FUNC_QUALIFIER detail::tmat2x3<T, P> diagonal2x3
     26 	(
     27 		detail::tvec2<T, P> const & v
     28 	)
     29 	{
     30 		detail::tmat2x3<T, P> Result(static_cast<T>(1));
     31 		Result[0][0] = v[0];
     32 		Result[1][1] = v[1];
     33 		return Result;
     34 	}
     35 
     36 	template <typename T, precision P>
     37 	GLM_FUNC_QUALIFIER detail::tmat2x4<T, P> diagonal2x4
     38 	(
     39 		detail::tvec2<T, P> const & v
     40 	)
     41 	{
     42 		detail::tmat2x4<T, P> Result(static_cast<T>(1));
     43 		Result[0][0] = v[0];
     44 		Result[1][1] = v[1];
     45 		return Result;
     46 	}
     47 
     48 	template <typename T, precision P>
     49 	GLM_FUNC_QUALIFIER detail::tmat3x2<T, P> diagonal3x2
     50 	(
     51 		detail::tvec2<T, P> const & v
     52 	)
     53 	{
     54 		detail::tmat3x2<T, P> Result(static_cast<T>(1));
     55 		Result[0][0] = v[0];
     56 		Result[1][1] = v[1];
     57 		return Result;
     58 	}
     59 
     60 	template <typename T, precision P>
     61 	GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> diagonal3x3
     62 	(
     63 		detail::tvec3<T, P> const & v
     64 	)
     65 	{
     66 		detail::tmat3x3<T, P> Result(static_cast<T>(1));
     67 		Result[0][0] = v[0];
     68 		Result[1][1] = v[1];
     69 		Result[2][2] = v[2];
     70 		return Result;
     71 	}
     72 
     73 	template <typename T, precision P>
     74 	GLM_FUNC_QUALIFIER detail::tmat3x4<T, P> diagonal3x4
     75 	(
     76 		detail::tvec3<T, P> const & v
     77 	)
     78 	{
     79 		detail::tmat3x4<T, P> Result(static_cast<T>(1));
     80 		Result[0][0] = v[0];
     81 		Result[1][1] = v[1];
     82 		Result[2][2] = v[2];
     83 		return Result;
     84 	}
     85 
     86 	template <typename T, precision P>
     87 	GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> diagonal4x4
     88 	(
     89 		detail::tvec4<T, P> const & v
     90 	)
     91 	{
     92 		detail::tmat4x4<T, P> Result(static_cast<T>(1));
     93 		Result[0][0] = v[0];
     94 		Result[1][1] = v[1];
     95 		Result[2][2] = v[2];
     96 		Result[3][3] = v[3];
     97 		return Result;		
     98 	}
     99 
    100 	template <typename T, precision P>
    101 	GLM_FUNC_QUALIFIER detail::tmat4x3<T, P> diagonal4x3
    102 	(
    103 		detail::tvec3<T, P> const & v
    104 	)
    105 	{
    106 		detail::tmat4x3<T, P> Result(static_cast<T>(1));
    107 		Result[0][0] = v[0];
    108 		Result[1][1] = v[1];
    109 		Result[2][2] = v[2];
    110 		return Result;		
    111 	}
    112 
    113 	template <typename T, precision P>
    114 	GLM_FUNC_QUALIFIER detail::tmat4x2<T, P> diagonal4x2
    115 	(
    116 		detail::tvec2<T, P> const & v
    117 	)
    118 	{
    119 		detail::tmat4x2<T, P> Result(static_cast<T>(1));
    120 		Result[0][0] = v[0];
    121 		Result[1][1] = v[1];
    122 		return Result;		
    123 	}
    124 }//namespace glm
    125