CMSC23700 Common Code Library
Support code for CS23700 programming projects
cs237-mat4x4.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_MAT4X4_HXX_
14 #define _CS237_MAT4X4_HXX_
15 
16 #ifndef _CS237_HXX_
17 #error "c237-mat4x4.hxx should not be included directly"
18 #endif
19 
20 namespace cs237 {
21 
22  namespace __detail {
23 
25  template <typename T>
26  struct mat4x4 {
27  vec4<T> cv[4]; // column vectors
28 
30  mat4x4 () {}
32  mat4x4 (mat4x4 const &m);
34  explicit mat4x4 (
35  T m00, T m10, T m20, T m30, // first column
36  T m01, T m11, T m21, T m31, // second column
37  T m02, T m12, T m22, T m32, // third column
38  T m03, T m13, T m23, T m33); // fourth column
40  explicit mat4x4 (vec4<T> const &c0, vec4<T> const &c1, vec4<T> const &c2, vec4<T> const &c3);
42  explicit mat4x4 (T const &x);
43 
46  vec4<T> & operator[] (unsigned int const &i);
47  vec4<T> const & operator[] (unsigned int const &i) const;
49 
50  mat4x4 & operator= (mat4x4 const &mm);
51 
52  mat4x4 & operator+= (T const &s);
53  mat4x4 & operator+= (mat4x4 const &mm);
54 
55  mat4x4 & operator-= (T const &s);
56  mat4x4 & operator-= (mat4x4 const &mm);
57 
58  mat4x4 & operator*= (T const &s);
59  mat4x4 & operator*= (mat4x4 const &mm);
60 
62  mat4x4 inverse() const;
63 
65  mat4x4 transpose() const;
66 
68  T determinant() const;
69 
72  mat3x3<T> normalMatrix() const;
73  };
74 
78  template <typename T>
79  std::ostream& operator<< (std::ostream& s, mat4x4<T> const &m);
80 
81  } /* _namespace __detail */
82 
88  typedef mat4x4f mat4f;
90  typedef mat4x4d mat4d;
91 
92 } /* namespace cs237 */
93 
94 #endif /* !_CS237_MAT4X4_HXX_ */
__detail::mat4x4< float > mat4x4f
Single-precision 4x4 matrices.
Definition: cs237-mat4x4.hxx:84
mat3x3< T > normalMatrix() const
mat4x4 transpose() const
return the transpose of this matrix
Definition: cs237-mat4x4.inl:173
vec4< T > cv[4]
Definition: cs237-mat4x4.hxx:27
mat4x4d mat4d
Double-precision 4x4 matrices (the same as mat4x4d)
Definition: cs237-mat4x4.hxx:90
mat4x4()
create an uninitialized matrix
Definition: cs237-mat4x4.hxx:30
mat4x4 inverse() const
return the inverse of this matrix
vec4< T > & operator[](unsigned int const &i)
return the i'th column vector
Definition: cs237-mat4x4.inl:66
template class for four-element vectors
Definition: cs237-types.hxx:27
template class for 3x3 matrices
Definition: cs237-mat3x3.hxx:26
mat4x4 & operator=(mat4x4 const &mm)
Definition: cs237-mat4x4.inl:80
mat4x4 & operator-=(T const &s)
Definition: cs237-mat4x4.inl:111
Definition: cs237-aabb.hxx:18
template class for 4x4 matrices
Definition: cs237-mat4x4.hxx:26
mat4x4 & operator+=(T const &s)
Definition: cs237-mat4x4.inl:90
__detail::mat4x4< double > mat4x4d
Double-precision 4x4 matrices.
Definition: cs237-mat4x4.hxx:86
T determinant() const
return the determiniant of this matrix
mat4x4f mat4f
Single-precision 4x4 matrices (the same as mat4x4f)
Definition: cs237-mat4x4.hxx:88
mat4x4 & operator*=(T const &s)
Definition: cs237-mat4x4.inl:132