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/type_mat4x4.hpp
     25 /// @date 2005-01-27 / 2011-06-15
     26 /// @author Christophe Riccio
     27 ///////////////////////////////////////////////////////////////////////////////////
     28 
     29 #ifndef glm_core_type_mat4x4
     30 #define glm_core_type_mat4x4
     31 
     32 #include "../fwd.hpp"
     33 #include "type_vec4.hpp"
     34 #include "type_mat.hpp"
     35 #include <limits>
     36 #include <cstddef>
     37 
     38 namespace glm{
     39 namespace detail
     40 {
     41 	template <typename T, precision P>
     42 	struct tmat4x4
     43 	{
     44 		enum ctor{_null};
     45 		typedef T value_type;
     46 		typedef std::size_t size_type;
     47 		typedef tvec4<T, P> col_type;
     48 		typedef tvec4<T, P> row_type;
     49 		typedef tmat4x4<T, P> type;
     50 		typedef tmat4x4<T, P> transpose_type;
     51 
     52 		GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
     53 
     54 		template <typename U, precision Q>
     55 		friend tvec4<U, Q> operator/(tmat4x4<U, Q> const & m, tvec4<U, Q> const & v);
     56 		template <typename U, precision Q>
     57 		friend tvec4<U, Q> operator/(tvec4<U, Q> const & v, tmat4x4<U, Q> const & m);
     58 
     59 	private:
     60 		/// @cond DETAIL
     61 		col_type value[4];
     62 
     63 	public:
     64 		// Constructors
     65 		GLM_FUNC_DECL tmat4x4();
     66 		GLM_FUNC_DECL tmat4x4(tmat4x4<T, P> const & m);
     67 		template <precision Q>
     68 		GLM_FUNC_DECL tmat4x4(tmat4x4<T, Q> const & m);
     69 
     70 		GLM_FUNC_DECL explicit tmat4x4(
     71 			ctor Null);
     72 		GLM_FUNC_DECL explicit tmat4x4(
     73 			T const & x);
     74 		GLM_FUNC_DECL tmat4x4(
     75 			T const & x0, T const & y0, T const & z0, T const & w0,
     76 			T const & x1, T const & y1, T const & z1, T const & w1,
     77 			T const & x2, T const & y2, T const & z2, T const & w2,
     78 			T const & x3, T const & y3, T const & z3, T const & w3);
     79 		GLM_FUNC_DECL tmat4x4(
     80 			col_type const & v0,
     81 			col_type const & v1,
     82 			col_type const & v2,
     83 			col_type const & v3);
     84 
     85 		//////////////////////////////////////
     86 		// Conversions
     87 
     88 		template <
     89 			typename X1, typename Y1, typename Z1, typename W1,
     90 			typename X2, typename Y2, typename Z2, typename W2,
     91 			typename X3, typename Y3, typename Z3, typename W3,
     92 			typename X4, typename Y4, typename Z4, typename W4>
     93 		GLM_FUNC_DECL tmat4x4(
     94 			X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1,
     95 			X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2,
     96 			X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3,
     97 			X4 const & x4, Y4 const & y4, Z4 const & z4, W4 const & w4);
     98 
     99 		template <typename V1, typename V2, typename V3, typename V4>
    100 		GLM_FUNC_DECL tmat4x4(
    101 			tvec4<V1, P> const & v1,
    102 			tvec4<V2, P> const & v2,
    103 			tvec4<V3, P> const & v3,
    104 			tvec4<V4, P> const & v4);
    105 
    106 		// Matrix conversions
    107 		template <typename U, precision Q>
    108 		GLM_FUNC_DECL explicit tmat4x4(tmat4x4<U, Q> const & m);
    109 
    110 		GLM_FUNC_DECL explicit tmat4x4(tmat2x2<T, P> const & x);
    111 		GLM_FUNC_DECL explicit tmat4x4(tmat3x3<T, P> const & x);
    112 		GLM_FUNC_DECL explicit tmat4x4(tmat2x3<T, P> const & x);
    113 		GLM_FUNC_DECL explicit tmat4x4(tmat3x2<T, P> const & x);
    114 		GLM_FUNC_DECL explicit tmat4x4(tmat2x4<T, P> const & x);
    115 		GLM_FUNC_DECL explicit tmat4x4(tmat4x2<T, P> const & x);
    116 		GLM_FUNC_DECL explicit tmat4x4(tmat3x4<T, P> const & x);
    117 		GLM_FUNC_DECL explicit tmat4x4(tmat4x3<T, P> const & x);
    118 
    119 		// Accesses
    120 		GLM_FUNC_DECL col_type & operator[](length_t i);
    121 		GLM_FUNC_DECL col_type const & operator[](length_t i) const;
    122 
    123 		// Unary updatable operators
    124 		GLM_FUNC_DECL tmat4x4<T, P> & operator=  (tmat4x4<T, P> const & m);
    125 		template <typename U>
    126 		GLM_FUNC_DECL tmat4x4<T, P> & operator=  (tmat4x4<U, P> const & m);
    127 		template <typename U>
    128 		GLM_FUNC_DECL tmat4x4<T, P> & operator+= (U s);
    129 		template <typename U>
    130 		GLM_FUNC_DECL tmat4x4<T, P> & operator+= (tmat4x4<U, P> const & m);
    131 		template <typename U>
    132 		GLM_FUNC_DECL tmat4x4<T, P> & operator-= (U s);
    133 		template <typename U>
    134 		GLM_FUNC_DECL tmat4x4<T, P> & operator-= (tmat4x4<U, P> const & m);
    135 		template <typename U>
    136 		GLM_FUNC_DECL tmat4x4<T, P> & operator*= (U s);
    137 		template <typename U>
    138 		GLM_FUNC_DECL tmat4x4<T, P> & operator*= (tmat4x4<U, P> const & m);
    139 		template <typename U>
    140 		GLM_FUNC_DECL tmat4x4<T, P> & operator/= (U s);
    141 		template <typename U>
    142 		GLM_FUNC_DECL tmat4x4<T, P> & operator/= (tmat4x4<U, P> const & m);
    143 
    144 		//////////////////////////////////////
    145 		// Increment and decrement operators
    146 
    147 		GLM_FUNC_DECL tmat4x4<T, P> & operator++ ();
    148 		GLM_FUNC_DECL tmat4x4<T, P> & operator-- ();
    149 		GLM_FUNC_DECL tmat4x4<T, P> operator++(int);
    150 		GLM_FUNC_DECL tmat4x4<T, P> operator--(int);
    151 	};
    152 
    153 	template <typename T, precision P>
    154 	GLM_FUNC_DECL tmat4x4<T, P> compute_inverse_mat4(tmat4x4<T, P> const & m);
    155 
    156 	// Binary operators
    157 	template <typename T, precision P>
    158 	GLM_FUNC_DECL tmat4x4<T, P> operator+ (
    159 		tmat4x4<T, P> const & m,
    160 		T const & s);
    161 
    162 	template <typename T, precision P>
    163 	GLM_FUNC_DECL tmat4x4<T, P> operator+ (
    164 		T const & s,
    165 		tmat4x4<T, P> const & m);
    166 
    167 	template <typename T, precision P>
    168 	GLM_FUNC_DECL tmat4x4<T, P> operator+ (
    169 		tmat4x4<T, P> const & m1,
    170 		tmat4x4<T, P> const & m2);
    171 
    172 	template <typename T, precision P>
    173 	GLM_FUNC_DECL tmat4x4<T, P> operator- (
    174 		tmat4x4<T, P> const & m,
    175 		T const & s);
    176 
    177 	template <typename T, precision P>
    178 	GLM_FUNC_DECL tmat4x4<T, P> operator- (
    179 		T const & s,
    180 		tmat4x4<T, P> const & m);
    181 
    182 	template <typename T, precision P>
    183 	GLM_FUNC_DECL tmat4x4<T, P> operator- (
    184 		tmat4x4<T, P> const & m1,
    185 		tmat4x4<T, P> const & m2);
    186 
    187 	template <typename T, precision P>
    188 	GLM_FUNC_DECL tmat4x4<T, P> operator* (
    189 		tmat4x4<T, P> const & m,
    190 		T const & s);
    191 
    192 	template <typename T, precision P>
    193 	GLM_FUNC_DECL tmat4x4<T, P> operator* (
    194 		T const & s,
    195 		tmat4x4<T, P> const & m);
    196 
    197 	template <typename T, precision P>
    198 	GLM_FUNC_DECL typename tmat4x4<T, P>::col_type operator* (
    199 		tmat4x4<T, P> const & m,
    200 		typename tmat4x4<T, P>::row_type const & v);
    201 
    202 	template <typename T, precision P>
    203 	GLM_FUNC_DECL typename tmat4x4<T, P>::row_type operator* (
    204 		typename tmat4x4<T, P>::col_type const & v,
    205 		tmat4x4<T, P> const & m);
    206 
    207 	template <typename T, precision P>
    208 	GLM_FUNC_DECL tmat2x4<T, P> operator* (
    209 		tmat4x4<T, P> const & m1,
    210 		tmat2x4<T, P> const & m2);
    211 
    212 	template <typename T, precision P>
    213 	GLM_FUNC_DECL tmat3x4<T, P> operator* (
    214 		tmat4x4<T, P> const & m1,
    215 		tmat3x4<T, P> const & m2);
    216 
    217 	template <typename T, precision P>
    218 	GLM_FUNC_DECL tmat4x4<T, P> operator* (
    219 		tmat4x4<T, P> const & m1,
    220 		tmat4x4<T, P> const & m2);
    221 
    222 	template <typename T, precision P>
    223 	GLM_FUNC_DECL tmat4x4<T, P> operator/ (
    224 		tmat4x4<T, P> const & m,
    225 		T const & s);
    226 
    227 	template <typename T, precision P>
    228 	GLM_FUNC_DECL tmat4x4<T, P> operator/ (
    229 		T const & s,
    230 		tmat4x4<T, P> const & m);
    231 
    232 	template <typename T, precision P>
    233 	GLM_FUNC_DECL typename tmat4x4<T, P>::col_type operator/ (
    234 		tmat4x4<T, P> const & m,
    235 		typename tmat4x4<T, P>::row_type const & v);
    236 
    237 	template <typename T, precision P>
    238 	GLM_FUNC_DECL typename tmat4x4<T, P>::row_type operator/ (
    239 		typename tmat4x4<T, P>::col_type & v,
    240 		tmat4x4<T, P> const & m);
    241 
    242 	template <typename T, precision P>
    243 	GLM_FUNC_DECL tmat4x4<T, P> operator/ (
    244 		tmat4x4<T, P> const & m1,
    245 		tmat4x4<T, P> const & m2);
    246 
    247 	// Unary constant operators
    248 	template <typename T, precision P>
    249 	GLM_FUNC_DECL tmat4x4<T, P> const operator-  (
    250 		tmat4x4<T, P> const & m);
    251 
    252 }//namespace detail
    253 }//namespace glm
    254 
    255 #ifndef GLM_EXTERNAL_TEMPLATE
    256 #include "type_mat4x4.inl"
    257 #endif//GLM_EXTERNAL_TEMPLATE
    258 
    259 #endif//glm_core_type_mat4x4
    260