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