CMSC23700 Common Code Library
Support code for CS23700 programming projects
cs237-mat3x3.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_MAT3X3_HXX_
14 #define _CS237_MAT3X3_HXX_
15 
16 #ifndef _CS237_HXX_
17 #error "c237-mat3x3.hxx should not be included directly"
18 #endif
19 
20 namespace cs237 {
21 
22  namespace __detail {
23 
25  template <typename T>
26  struct mat3x3 {
27  vec3<T> cv[3]; // column vectors
28 
30  mat3x3 () {}
32  mat3x3 (mat3x3 const &m);
34  explicit mat3x3 (
35  T m00, T m10, T m20, // first column
36  T m01, T m11, T m21, // second column
37  T m02, T m12, T m22); // third column
39  explicit mat3x3 (vec3<T> const &c0, vec3<T> const &c1, vec3<T> const &c2);
41  explicit mat3x3 (mat4x4<T> const &mm);
43  explicit mat3x3 (mat3x4<T> const &mm);
45  explicit mat3x3 (mat4x3<T> const &mm);
47  explicit mat3x3 (T const &x);
48 
51  vec3<T> & operator[] (unsigned int const &i);
52  vec3<T> const & operator[] (unsigned int const &i) const;
54 
55  mat3x3 & operator= (mat3x3 const &mm);
56 
57  mat3x3 & operator+= (T const &s);
58  mat3x3 & operator+= (mat3x3 const &mm);
59 
60  mat3x3 & operator-= (T const &s);
61  mat3x3 & operator-= (mat3x3 const &mm);
62 
63  mat3x3 & operator*= (T const &s);
64  mat3x3 & operator*= (mat3x3 const &mm);
65 
67  mat3x3 inverse() const;
68 
70  mat3x3 transpose() const;
71 
73  T determinant() const;
74  };
75 
79  template <typename T>
80  std::ostream& operator<< (std::ostream& s, mat3x3<T> const &m);
81 
82  } /* _namespace __detail */
83 
89  typedef mat3x3f mat3f;
91  typedef mat3x3d mat3d;
92 
93 } /* namespace cs237 */
94 
95 #endif /* !_CS237_MAT3X3_HXX_ */
mat3x3 & operator*=(T const &s)
Definition: cs237-mat3x3.inl:142
__detail::mat3x3< float > mat3x3f
Single-precision 3x3 matrices.
Definition: cs237-mat3x3.hxx:85
mat3x3 transpose() const
return the transpose of this matrix
Definition: cs237-mat3x3.inl:173
mat3x3 inverse() const
return the inverse of this matrix
Definition: cs237-mat3x3.inl:189
mat3x3f mat3f
Single-precision 3x3 matrices (the same as mat3x3f)
Definition: cs237-mat3x3.hxx:89
mat3x3 & operator=(mat3x3 const &mm)
Definition: cs237-mat3x3.inl:95
vec3< T > cv[3]
Definition: cs237-mat3x3.hxx:27
mat3x3()
create an uninitialized matrix
Definition: cs237-mat3x3.hxx:30
vec3< T > & operator[](unsigned int const &i)
return the i'th column vector
Definition: cs237-mat3x3.inl:81
Definition: cs237-types.hxx:37
template class for 3x3 matrices
Definition: cs237-mat3x3.hxx:26
__detail::mat3x3< double > mat3x3d
Double-precision 3x3 matrices.
Definition: cs237-mat3x3.hxx:87
mat3x3d mat3d
Double-precision 3x3 matrices (the same as mat3x3f)
Definition: cs237-mat3x3.hxx:91
T determinant() const
return the determiniant of this matrix
Definition: cs237-mat3x3.inl:182
mat3x3 & operator+=(T const &s)
Definition: cs237-mat3x3.inl:104
Definition: cs237-aabb.hxx:18
template class for 4x4 matrices
Definition: cs237-mat4x4.hxx:26
template class for three-element vectors
Definition: cs237-types.hxx:26
Definition: cs237-types.hxx:35
mat3x3 & operator-=(T const &s)
Definition: cs237-mat3x3.inl:123