fixed multmatrix when a scaling factor is present

This commit is contained in:
Paolo Cignoni 2011-05-03 15:19:04 +00:00
parent 49a15ebd82
commit 2c15159659
1 changed files with 138 additions and 136 deletions

View File

@ -232,6 +232,7 @@ public:
/* multiply the current reference frame for the matrix passed /* multiply the current reference frame for the matrix passed
note: it is up to the caller to check the the matrix passed is a pure rototraslation note: it is up to the caller to check the the matrix passed is a pure rototraslation
the matrix can have a scaling component, but is assumed uniform over the rows
*/ */
void MultMatrix( vcg::Matrix44<S> m44) void MultMatrix( vcg::Matrix44<S> m44)
{ {
@ -239,6 +240,7 @@ public:
m44[0][3] = m44[1][3] = m44[2][3] = 0.0; //set no translation m44[0][3] = m44[1][3] = m44[2][3] = 0.0; //set no translation
const S k = m44.GetRow3(0).Norm(); //compute scaling (assumed uniform) const S k = m44.GetRow3(0).Norm(); //compute scaling (assumed uniform)
Extrinsics.rot = Extrinsics.rot * m44.transpose() * (1/k); Extrinsics.rot = Extrinsics.rot * m44.transpose() * (1/k);
Extrinsics.rot.ElementAt(3,3)=S(1.0); //fix back after scaling
} }
/* multiply the current reference frame for the similarity passed /* multiply the current reference frame for the similarity passed