CMU462 Library Documentation  1.0
15-462/15-662: Computer Graphics (Fall 2015)
matrix3x3.h
1 #ifndef CMU462_MATRIX3X3_H
2 #define CMU462_MATRIX3X3_H
3 
4 #include <iosfwd>
5 
6 #include "vector3D.h"
7 
8 namespace CMU462 {
9 
14 class Matrix3x3 {
15 
16  public:
17 
21  void zero(double val = 0.0 );
22 
26  double det( void ) const;
27 
31  double norm( void ) const;
32 
36  static Matrix3x3 identity( void );
37 
41  static Matrix3x3 crossProduct( const Vector3D& u );
42 
46  Vector3D& column( int i );
47  const Vector3D& column( int i ) const;
48 
52  Matrix3x3 T( void ) const;
53 
57  Matrix3x3 inv( void ) const;
58 
59  // accesses element (i,j) of A using 0-based indexing
60  double& operator()( int i, int j );
61  const double& operator()( int i, int j ) const;
62 
63  // accesses the ith column of A
64  Vector3D& operator[]( int i );
65  const Vector3D& operator[]( int i ) const;
66 
67  // increments by B
68  void operator+=( const Matrix3x3& B );
69 
70  // returns -A
71  Matrix3x3 operator-( void ) const;
72 
73  // returns A-B
74  Matrix3x3 operator-( const Matrix3x3& B ) const;
75 
76  // returns c*A
77  Matrix3x3 operator*( double c ) const;
78 
79  // returns A*B
80  Matrix3x3 operator*( const Matrix3x3& B ) const;
81 
82  // returns A*x
83  Vector3D operator*( const Vector3D& x ) const;
84 
85  // divides each element by x
86  void operator/=( double x );
87 
88  protected:
89 
90  // column vectors
91  Vector3D entries[3];
92 
93 }; // class Matrix3x3
94 
95 // returns the outer product of u and v
96 Matrix3x3 outer( const Vector3D& u, const Vector3D& v );
97 
98 // returns c*A
99 Matrix3x3 operator*( double c, const Matrix3x3& A );
100 
101 // prints entries
102 std::ostream& operator<<( std::ostream& os, const Matrix3x3& A );
103 
104 } // namespace CMU462
105 
106 #endif // CMU462_MATRIX3X3_H
double det(void) const
Returns the determinant of A.
Definition: matrix3x3.cpp:31
Definition: color.cpp:10
Defines 3D vectors.
Definition: vector3D.h:12
static Matrix3x3 identity(void)
Returns the 3x3 identity matrix.
Definition: matrix3x3.cpp:181
Vector3D & column(int i)
Returns the ith column.
Definition: matrix3x3.cpp:234
static Matrix3x3 crossProduct(const Vector3D &u)
Returns a matrix representing the (left) cross product with u.
Definition: matrix3x3.cpp:191
Matrix3x3 inv(void) const
Returns the inverse of A.
Definition: matrix3x3.cpp:157
Matrix3x3 T(void) const
Returns the transpose of A.
Definition: matrix3x3.cpp:144
void zero(double val=0.0)
Sets all elements to val.
Definition: matrix3x3.cpp:26
Defines a 3x3 matrix.
Definition: matrix3x3.h:14
double norm(void) const
Returns the Frobenius norm of A.
Definition: matrix3x3.cpp:39