transpose for rwio normal xform

This commit is contained in:
aap 2017-08-22 20:23:56 +02:00
parent 8fc446f13b
commit efec4e5acc
2 changed files with 22 additions and 4 deletions

View File

@ -214,6 +214,27 @@ Matrix::invert(Matrix *dst, Matrix *src)
return dst; 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*
Matrix::rotate(V3d *axis, float32 angle, CombineOp op) Matrix::rotate(V3d *axis, float32 angle, CombineOp op)
{ {

View File

@ -227,6 +227,7 @@ struct Matrix
void update(void) { flags &= ~(IDENTITY|TYPEMASK); } void update(void) { flags &= ~(IDENTITY|TYPEMASK); }
static Matrix *mult(Matrix *dst, Matrix *src1, Matrix *src2); static Matrix *mult(Matrix *dst, Matrix *src1, Matrix *src2);
static Matrix *invert(Matrix *m1, Matrix *m2); static Matrix *invert(Matrix *m1, Matrix *m2);
static Matrix *transpose(Matrix *m1, Matrix *m2);
Matrix *rotate(V3d *axis, float32 angle, CombineOp op); Matrix *rotate(V3d *axis, float32 angle, CombineOp op);
Matrix *rotate(const Quat &q, CombineOp op); Matrix *rotate(const Quat &q, CombineOp op);
Matrix *translate(V3d *translation, CombineOp op); Matrix *translate(V3d *translation, CombineOp op);
@ -240,10 +241,6 @@ struct Matrix
static Matrix *invertGeneral(Matrix *dst, Matrix *src); static Matrix *invertGeneral(Matrix *dst, Matrix *src);
static void makeRotation(Matrix *dst, V3d *axis, float32 angle); static void makeRotation(Matrix *dst, V3d *axis, float32 angle);
static void makeRotation(Matrix *dst, const Quat &q); static void makeRotation(Matrix *dst, const Quat &q);
/*
bool32 isIdentity(void);
static void transpose(Matrix *m1, Matrix *m2);
*/
private: private:
float32 normalError(void); float32 normalError(void);
float32 orthogonalError(void); float32 orthogonalError(void);