Matrix44F BaseTransform::space() const { Matrix44F s; s.setTranslation(m_translation); Matrix33F r = orientation(); s.translate(m_rotatePivotTranslate); s.translate(m_rotatePivot); s.translate(r.transform(m_rotatePivot.reversed())); s.translate(r.transform(m_scalePivotTranslate)); s.translate(r.transform(m_scalePivot)); Vector3F displaceByScaling = m_scalePivot.reversed(); displaceByScaling = displaceByScaling * m_scale; s.translate(r.transform(displaceByScaling)); Matrix33F scaleMatrix; *scaleMatrix.m(0, 0) = m_scale.x; *scaleMatrix.m(1, 1) = m_scale.y; *scaleMatrix.m(2, 2) = m_scale.z; r = scaleMatrix * r; s.setRotation(r); return s; }
Matrix33F Matrix44F::rotation() const { Matrix33F r; *r.m(0, 0) = M(0, 0); *r.m(0, 1) = M(0, 1); *r.m(0, 2) = M(0, 2); *r.m(1, 0) = M(1, 0); *r.m(1, 1) = M(1, 1); *r.m(1, 2) = M(1, 2); *r.m(2, 0) = M(2, 0); *r.m(2, 1) = M(2, 1); *r.m(2, 2) = M(2, 2); return r; }