diff --git a/src/base.cpp b/src/base.cpp index bd263d8..9b62b11 100755 --- a/src/base.cpp +++ b/src/base.cpp @@ -214,6 +214,27 @@ Matrix::invert(Matrix *dst, Matrix *src) return dst; } +// transpose the 3x3 submatrix, pos is set to 0 +Matrix* +Matrix::transpose(Matrix *dst, Matrix *src) +{ + if(src->flags & IDENTITY) + *dst = *src; + dst->right.x = src->right.x; + dst->up.x = src->right.y; + dst->at.x = src->right.z; + dst->right.y = src->up.x; + dst->up.y = src->up.y; + dst->at.y = src->up.z; + dst->right.z = src->at.x; + dst->up.z = src->at.y; + dst->at.z = src->at.z; + dst->pos.x = 0.0; + dst->pos.y = 0.0; + dst->pos.z = 0.0; + return dst; +} + Matrix* Matrix::rotate(V3d *axis, float32 angle, CombineOp op) { diff --git a/src/rwbase.h b/src/rwbase.h index 1889139..86ab804 100644 --- a/src/rwbase.h +++ b/src/rwbase.h @@ -227,6 +227,7 @@ struct Matrix void update(void) { flags &= ~(IDENTITY|TYPEMASK); } static Matrix *mult(Matrix *dst, Matrix *src1, Matrix *src2); static Matrix *invert(Matrix *m1, Matrix *m2); + static Matrix *transpose(Matrix *m1, Matrix *m2); Matrix *rotate(V3d *axis, float32 angle, CombineOp op); Matrix *rotate(const Quat &q, CombineOp op); Matrix *translate(V3d *translation, CombineOp op); @@ -240,10 +241,6 @@ struct Matrix static Matrix *invertGeneral(Matrix *dst, Matrix *src); static void makeRotation(Matrix *dst, V3d *axis, float32 angle); static void makeRotation(Matrix *dst, const Quat &q); -/* - bool32 isIdentity(void); - static void transpose(Matrix *m1, Matrix *m2); -*/ private: float32 normalError(void); float32 orthogonalError(void);