Home | History | Annotate | Download | only in detail
      1 ///////////////////////////////////////////////////////////////////////////////////
      2 /// OpenGL Mathematics (glm.g-truc.net)
      3 ///
      4 /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
      5 /// Permission is hereby granted, free of charge, to any person obtaining a copy
      6 /// of this software and associated documentation files (the "Software"), to deal
      7 /// in the Software without restriction, including without limitation the rights
      8 /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      9 /// copies of the Software, and to permit persons to whom the Software is
     10 /// furnished to do so, subject to the following conditions:
     11 ///
     12 /// The above copyright notice and this permission notice shall be included in
     13 /// all copies or substantial portions of the Software.
     14 ///
     15 /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16 /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17 /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     18 /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19 /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     20 /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     21 /// THE SOFTWARE.
     22 ///
     23 /// @ref core
     24 /// @file glm/core/func_matrix.hpp
     25 /// @date 2008-08-03 / 2011-06-15
     26 /// @author Christophe Riccio
     27 ///
     28 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
     29 ///
     30 /// @defgroup core_func_matrix Matrix functions
     31 /// @ingroup core
     32 ///
     33 /// For each of the following built-in matrix functions, there is both a
     34 /// single-precision floating point version, where all arguments and return values
     35 /// are single precision, and a double-precision floating version, where all
     36 /// arguments and return values are double precision. Only the single-precision
     37 /// floating point version is shown.
     38 ///////////////////////////////////////////////////////////////////////////////////
     39 
     40 #ifndef GLM_CORE_func_matrix
     41 #define GLM_CORE_func_matrix
     42 
     43 // Dependencies
     44 #include "../detail/precision.hpp"
     45 #include "../detail/setup.hpp"
     46 #include "../detail/type_mat.hpp"
     47 #include "../vec2.hpp"
     48 #include "../vec3.hpp"
     49 #include "../vec4.hpp"
     50 #include "../mat2x2.hpp"
     51 #include "../mat2x3.hpp"
     52 #include "../mat2x4.hpp"
     53 #include "../mat3x2.hpp"
     54 #include "../mat3x3.hpp"
     55 #include "../mat3x4.hpp"
     56 #include "../mat4x2.hpp"
     57 #include "../mat4x3.hpp"
     58 #include "../mat4x4.hpp"
     59 
     60 namespace glm{
     61 namespace detail
     62 {
     63 	template <typename T, precision P>
     64 	struct outerProduct_trait<T, P, tvec2, tvec2>
     65 	{
     66 		typedef tmat2x2<T, P> type;
     67 	};
     68 
     69 	template <typename T, precision P>
     70 	struct outerProduct_trait<T, P, tvec2, tvec3>
     71 	{
     72 		typedef tmat2x3<T, P> type;
     73 	};
     74 
     75 	template <typename T, precision P>
     76 	struct outerProduct_trait<T, P, tvec2, tvec4>
     77 	{
     78 		typedef tmat2x4<T, P> type;
     79 	};
     80 
     81 	template <typename T, precision P>
     82 	struct outerProduct_trait<T, P, tvec3, tvec2>
     83 	{
     84 		typedef tmat3x2<T, P> type;
     85 	};
     86 
     87 	template <typename T, precision P>
     88 	struct outerProduct_trait<T, P, tvec3, tvec3>
     89 	{
     90 		typedef tmat3x3<T, P> type;
     91 	};
     92 
     93 	template <typename T, precision P>
     94 	struct outerProduct_trait<T, P, tvec3, tvec4>
     95 	{
     96 		typedef tmat3x4<T, P> type;
     97 	};
     98 
     99 	template <typename T, precision P>
    100 	struct outerProduct_trait<T, P, tvec4, tvec2>
    101 	{
    102 		typedef tmat4x2<T, P> type;
    103 	};
    104 
    105 	template <typename T, precision P>
    106 	struct outerProduct_trait<T, P, tvec4, tvec3>
    107 	{
    108 		typedef tmat4x3<T, P> type;
    109 	};
    110 
    111 	template <typename T, precision P>
    112 	struct outerProduct_trait<T, P, tvec4, tvec4>
    113 	{
    114 		typedef tmat4x4<T, P> type;
    115 	};
    116 
    117 }//namespace detail
    118 
    119 	/// @addtogroup core_func_matrix
    120 	/// @{
    121 
    122 	/// Multiply matrix x by matrix y component-wise, i.e.,
    123 	/// result[i][j] is the scalar product of x[i][j] and y[i][j].
    124 	///
    125 	/// @tparam matType Floating-point matrix types.
    126 	///
    127 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/matrixCompMult.xml">GLSL matrixCompMult man page</a>
    128 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
    129 	template <typename T, precision P, template <typename, precision> class matType>
    130 	GLM_FUNC_DECL matType<T, P> matrixCompMult(matType<T, P> const & x, matType<T, P> const & y);
    131 
    132 	/// Treats the first parameter c as a column vector
    133 	/// and the second parameter r as a row vector
    134 	/// and does a linear algebraic matrix multiply c * r.
    135 	///
    136 	/// @tparam matType Floating-point matrix types.
    137 	///
    138 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/outerProduct.xml">GLSL outerProduct man page</a>
    139 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
    140 	///
    141 	/// @todo Clarify the declaration to specify that matType doesn't have to be provided when used.
    142 	template <typename T, precision P, template <typename, precision> class vecTypeA, template <typename, precision> class vecTypeB>
    143 	GLM_FUNC_DECL typename detail::outerProduct_trait<T, P, vecTypeA, vecTypeB>::type outerProduct(vecTypeA<T, P> const & c, vecTypeB<T, P> const & r);
    144 
    145 	/// Returns the transposed matrix of x
    146 	///
    147 	/// @tparam matType Floating-point matrix types.
    148 	///
    149 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/transpose.xml">GLSL transpose man page</a>
    150 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
    151 #	if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC11))
    152 		template <typename T, precision P, template <typename, precision> class matType>
    153 		GLM_FUNC_DECL typename matType<T, P>::transpose_type transpose(matType<T, P> const & x);
    154 #	endif
    155 
    156 	/// Return the determinant of a squared matrix.
    157 	///
    158 	/// @tparam valType Floating-point scalar types.
    159 	///
    160 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
    161 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
    162 	template <typename T, precision P, template <typename, precision> class matType>
    163 	GLM_FUNC_DECL T determinant(matType<T, P> const & m);
    164 
    165 	/// Return the inverse of a squared matrix.
    166 	///
    167 	/// @tparam valType Floating-point scalar types.
    168 	///
    169 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
    170 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
    171 	template <typename T, precision P, template <typename, precision> class matType>
    172 	GLM_FUNC_DECL matType<T, P> inverse(matType<T, P> const & m);
    173 
    174 	/// @}
    175 }//namespace glm
    176 
    177 #include "func_matrix.inl"
    178 
    179 #endif//GLM_CORE_func_matrix
    180