[37] | 1 | /* |
---|
| 2 | |
---|
| 3 | Brian Curless |
---|
| 4 | |
---|
| 5 | Computer Graphics Laboratory |
---|
| 6 | Stanford University |
---|
| 7 | |
---|
| 8 | --------------------------------------------------------------------- |
---|
| 9 | |
---|
| 10 | Copyright (1997) The Board of Trustees of the Leland Stanford Junior |
---|
| 11 | University. Except for commercial resale, lease, license or other |
---|
| 12 | commercial transactions, permission is hereby given to use, copy, |
---|
| 13 | modify this software for academic purposes only. No part of this |
---|
| 14 | software or any derivatives thereof may be used in the production of |
---|
| 15 | computer models for resale or for use in a commercial |
---|
| 16 | product. STANFORD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND |
---|
| 17 | CONCERNING THIS SOFTWARE. No support is implied or provided. |
---|
| 18 | |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | #ifndef _MATRIX4F_ |
---|
| 23 | #define _MATRIX4F_ |
---|
| 24 | |
---|
| 25 | #include "Vec3f.h" |
---|
| 26 | #include "Matrix3f.h" |
---|
| 27 | #include "defines.h" |
---|
| 28 | |
---|
| 29 | class Matrix4f { |
---|
| 30 | public: |
---|
| 31 | float m[4][4]; |
---|
| 32 | |
---|
| 33 | Matrix4f() {} |
---|
| 34 | Matrix4f(const Matrix4f &a) {setValue(a);} |
---|
| 35 | Matrix4f(float a[][4]) {setValue(a);} |
---|
| 36 | Matrix4f(float *a0, float *a1, float *a2, float *a3) |
---|
| 37 | {setValue(a0, a1, a2, a3);} |
---|
| 38 | Matrix4f(float a00, float a01, float a02, float a03, |
---|
| 39 | float a10, float a11, float a12, float a13, |
---|
| 40 | float a20, float a21, float a22, float a23, |
---|
| 41 | float a30, float a31, float a32, float a33) |
---|
| 42 | { setValue(a00, a01, a02, a03, |
---|
| 43 | a10, a11, a12, a13, |
---|
| 44 | a20, a21, a22, a23, |
---|
| 45 | a30, a31, a32, a33); } |
---|
| 46 | |
---|
| 47 | void clear() {setValue(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);} |
---|
| 48 | void setValue(const Matrix4f &a); |
---|
| 49 | void setValue(float a[][4]); |
---|
| 50 | void setValue(float *a0, float *a1, float *a2, float *a3); |
---|
| 51 | void setValue(float a00, float a01, float a02, float a03, |
---|
| 52 | float a10, float a11, float a12, float a13, |
---|
| 53 | float a20, float a21, float a22, float a23, |
---|
| 54 | float a30, float a31, float a32, float a33); |
---|
| 55 | void setValue(float *a); |
---|
| 56 | void getValue(float *a); |
---|
| 57 | void multVec(const Vec3f &src, Vec3f &dst); |
---|
| 58 | void multVecHomog(const Vec3f &src, Vec3f &dst); |
---|
| 59 | void multDir(const Vec3f &src, Vec3f &dst); |
---|
| 60 | float elem(int i, int j) {return m[i][j];} |
---|
| 61 | void setElem(int i, int j, float val) {m[i][j] = val;} |
---|
| 62 | void makeIdentity(); |
---|
| 63 | Matrix4f & multRight(const Matrix4f &m); |
---|
| 64 | Matrix4f & multLeft(const Matrix4f &m); |
---|
| 65 | Matrix4f & multLeft(const Matrix3f &a); |
---|
| 66 | void setScale(float s); |
---|
| 67 | void setScale(float sx, float sy, float sz); |
---|
| 68 | void setScale(const Vec3f &s); |
---|
| 69 | void setRotateX(float theta); |
---|
| 70 | void setRotateY(float theta); |
---|
| 71 | void setRotateZ(float theta); |
---|
| 72 | void setTranslate(Vec3f t); |
---|
| 73 | void setTranslate(float tx, float ty, float tz); |
---|
| 74 | void scale(float s); |
---|
| 75 | void scale(float sx, float sy, float sz); |
---|
| 76 | void scale(const Vec3f &s); |
---|
| 77 | void rotateX(float theta); |
---|
| 78 | void rotateY(float theta); |
---|
| 79 | void rotateZ(float theta); |
---|
| 80 | void translate(Vec3f t); |
---|
| 81 | void translate(float tx, float ty, float tz); |
---|
| 82 | Matrix4f inverse() const; |
---|
| 83 | void transpose(); |
---|
| 84 | //void freeNR(float **in) const; |
---|
| 85 | //void toNR(Matrix4f &in, float **nrmat) const; |
---|
| 86 | int operator==(const Matrix4f &); |
---|
| 87 | int operator!=(const Matrix4f &); |
---|
| 88 | void print(); |
---|
| 89 | void write(FILE *fp); |
---|
| 90 | void read(FILE *fp); |
---|
| 91 | /* |
---|
| 92 | Matrix4f & operator *=(const Matrix4f &m); |
---|
| 93 | friend Matrix4f operator *(const Matrix4f &m1, const Matrix4f &m2); |
---|
| 94 | */ |
---|
| 95 | }; |
---|
| 96 | |
---|
| 97 | #endif |
---|