-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrMatrix.h
63 lines (56 loc) · 2.12 KB
/
rMatrix.h
1
#pragma once#ifndef rMatrix_3_3hh#define rMatrix_3_3hh#include "rVector.h"#include "rPoint.h"class rMatrix_3_3 { protected: public: rVector mCol1,mCol2,mCol3; // columns of the matrix double *pt; rMatrix_3_3 () { mCol1.set (1.0,0.0,0.0);mCol2.set (0.0,1.0,0.0);mCol3.set (0.0,0.0,1.0);pt = &mCol1.x;} rMatrix_3_3 (double i,double j,double k, double l,double m,double n, double o,double p,double q) { mCol1.set (i,l,o); mCol2.set (j,m,p); mCol3.set (k,n,q); pt = &mCol1.x; } rMatrix_3_3 (rVector col1,rVector col2,rVector col3) { mCol1.x = col1.x;mCol1.y = col1.y;mCol1.z = col1.z; mCol2.x = col2.x;mCol2.y = col2.y;mCol2.z = col2.z; mCol3.x = col3.x;mCol3.y = col3.y;mCol3.z = col3.z; pt = &mCol1.x; } void dout () { std::cerr <<*this; }/* the display routine */ rMatrix_3_3& operator=(rMatrix_3_3 p) { mCol1=p.mCol1; mCol2=p.mCol2; mCol3=p.mCol3; pt = &mCol1.x;return (*this);} double& operator[] (int n) { return *(pt+n); } rVector operator*(rVector v); rVector operator*(rPoint v); double R1 () { return mCol1.x; } double R2 () { return mCol2.x; } double R3 () { return mCol3.x; } double R4 () { return mCol1.y; } double R5 () { return mCol2.y; } double R6 () { return mCol3.y; } double R7 () { return mCol1.z; } double R8 () { return mCol2.z; } double R9 () { return mCol3.z; } void set (double i,double j,double k, double l,double m,double n, double o,double p,double q) { mCol1.set (i,j,k);mCol2.set (l,m,n);mCol3.set (o,p,q); pt = &mCol1.x; } void set (rVector row1,rVector row2,rVector row3) {mCol1 = row1; mCol2 = row2; mCol3 = row3;pt = &mCol1.x;} friend std::ostream &operator << (std::ostream& os, rMatrix_3_3& p) { os <<std::endl; os << "|" <<p.mCol1.x<<" \t"<<p.mCol2.x<<" \t"<<p.mCol3.x<< "|"<<std::endl; os << "|" <<p.mCol1.y<<" \t"<<p.mCol2.y<<" \t"<<p.mCol3.y<< "|"<<std::endl; os << "|" <<p.mCol1.z<<" \t"<<p.mCol2.z<<" \t"<<p.mCol3.z<< "|"<<std::endl; return os; } /* used with cout */};#endif