CMSC23700 Common Code Library
Support code for CS23700 programming projects
cs237-mat2x2.hxx
Go to the documentation of this file.
1 
8 /*
9  * COPYRIGHT (c) 2013 John Reppy (http://cs.uchicago.edu/~jhr)
10  * All rights reserved.
11  */
12 
13 #ifndef _CS237_MAT2X2_HXX_
14 #define _CS237_MAT2X2_HXX_
15 
16 #ifndef _CS237_HXX_
17 #error "c237-mat2x2.hxx should not be included directly"
18 #endif
19 
20 namespace cs237 {
21 
22  namespace __detail {
23 
25  template <typename T>
26  struct mat2x2 {
27  vec2<T> cv[2]; // column vectors
28 
30  mat2x2 () {}
32  mat2x2 (mat2x2 const &m);
34  explicit mat2x2 (
35  T m00, T m10, // first column
36  T m01, T m11); // second column
38  explicit mat2x2 (vec2<T> const &c0, vec2<T> const &c1);
40  explicit mat2x2 (mat3x3<T> const &mm);
42  explicit mat2x2 (mat2x3<T> const &mm);
44  explicit mat2x2 (mat3x2<T> const &mm);
46  explicit mat2x2 (T const &x);
47 
50  vec2<T> & operator[] (unsigned int const &i);
51  vec2<T> const & operator[] (unsigned int const &i) const;
53 
54  mat2x2 & operator= (mat2x2 const &mm);
55 
56  mat2x2 & operator+= (T const &s);
57  mat2x2 & operator+= (mat2x2 const &v);
58 
59  mat2x2 & operator-= (T const &s);
60  mat2x2 & operator-= (mat2x2 const &v);
61 
62  mat2x2 & operator*= (T const &s);
63  mat2x2 & operator*= (mat2x2 const &m);
64 
66  mat2x2 inverse() const;
67 
69  mat2x2 transpose() const;
70 
72  T determinant() const;
73  };
74 
78  template <typename T>
79  std::ostream& operator<< (std::ostream& s, mat2x2<T> const &m);
80 
81  } /* _namespace __detail */
82 
88  typedef mat2x2f mat2f;
90  typedef mat2x2d mat2d;
91 
92 } /* namespace cs237 */
93 
94 #endif /* !_CS237_MAT2X2_HXX_ */
mat2x2 & operator+=(T const &s)
Definition: cs237-mat2x2.inl:96
T determinant() const
return the determiniant of this matrix
Definition: cs237-mat2x2.inl:161
__detail::mat2x2< float > mat2x2f
Single-precision 2x2 matrices.
Definition: cs237-mat2x2.hxx:84
mat2x2()
create an uninitialized matrix
Definition: cs237-mat2x2.hxx:30
mat2x2 inverse() const
return the inverse of this matrix
Definition: cs237-mat2x2.inl:167
mat2x2d mat2d
Double-precision 2x2 matrices (the same as mat2x2d)
Definition: cs237-mat2x2.hxx:90
__detail::mat2x2< double > mat2x2d
Double-precision 2x2 matrices.
Definition: cs237-mat2x2.hxx:86
mat2x2 & operator=(mat2x2 const &mm)
Definition: cs237-mat2x2.inl:88
template class for 2x3 matrices
Definition: cs237-mat2x3.hxx:26
template class for 3x3 matrices
Definition: cs237-mat3x3.hxx:26
vec2< T > cv[2]
Definition: cs237-mat2x2.hxx:27
mat2x2f mat2f
Single-precision 2x2 matrices (the same as mat2x2f)
Definition: cs237-mat2x2.hxx:88
Definition: cs237-aabb.hxx:18
mat2x2 transpose() const
return the transpose of this matrix
Definition: cs237-mat2x2.inl:153
mat2x2 & operator*=(T const &s)
Definition: cs237-mat2x2.inl:130
vec2< T > & operator[](unsigned int const &i)
return the i'th column vector
Definition: cs237-mat2x2.inl:74
template class for two-element vectors
Definition: cs237-types.hxx:25
mat2x2 & operator-=(T const &s)
Definition: cs237-mat2x2.inl:113
template class for 2x2 matrices
Definition: cs237-mat2x2.hxx:26
template class for 3x2 matrices
Definition: cs237-mat3x2.hxx:26