//samantha petro. created 27 sept 2006. last modified 12 oct 2006 //matrix.h - headerfile for the matrix class #include #include #define _USE_MATH_DEFINES #include #define TO_RADS( degrees ) ((degrees) * (M_PI/180.0f)) using namespace std; class matrix4x4 { friend class matrix4x1; private: int col, row; //number of cols and rows in the matrix float values[4][4]; //holds the values of the matrix public: matrix4x4() {row=4; col=4; zeroOut();} void zeroOut(); //zeroes out the matrix //gets int getM() {return row;} //returns M, the number of rows int getN(); //returns N, the number of cols //transformations - translate matrix4x4 transToOrigin(matrix4x1); //returns a translation matrix from point to origin matrix4x4 transToPoint(matrix4x1); //returns a translation matrix from origin to point //transformations - scale matrix4x4 scale(float, float, float); //scales by factors Sx, Sy, Sz //transformations - rotate matrix4x4 roll(float); //rotation about the z-axis by theta degrees matrix4x4 pitch(float); //rotation about the x-axis by theta degrees matrix4x4 yaw(float); //rotation about the y-axis by theta degrees //operators: I/O friend istream &operator >> (istream &, matrix4x4 &); friend ostream &operator << (ostream &, matrix4x4 &); //outputs a matrix //operators: arithmetic matrix4x4 operator* (const matrix4x4 &); //multiplication operator matrix4x1 operator* (const matrix4x1 &); //multiplies a 4x4 by a 4x1 }; class matrix4x1 { friend class matrix4x4; private: int col, row; //number of cols and rows in the matrix float values[4][1]; //holds the values of the matrix public: matrix4x1() {col = 1; row = 4; zeroOut();} void zeroOut(); //zeroes out the matrix matrix4x1 midpoint(matrix4x1); //gets int getM() {return row;} //returns M, the number of rows int getN(); //returns N, the number of cols //operators: I/O friend istream &operator >> (istream &, matrix4x1 &); friend ostream &operator << (ostream &, matrix4x1 &); //outputs coordinates };