From c99138926dee6f1de18a2cc6c109b9634d9d601d Mon Sep 17 00:00:00 2001 From: maxcorsini Date: Tue, 3 Jul 2007 16:06:48 +0000 Subject: [PATCH] add DCM to Euler Angles conversion --- vcg/math/matrix44.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vcg/math/matrix44.h b/vcg/math/matrix44.h index 4297f7e0..3d388903 100644 --- a/vcg/math/matrix44.h +++ b/vcg/math/matrix44.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.32 2007/03/08 14:39:27 corsini +final fix to euler angles transformation + Revision 1.31 2007/02/06 09:57:40 corsini fix euler angles computation @@ -232,6 +235,9 @@ public: template void ToMatrix(Matrix44Type & m) const {for(int i = 0; i < 16; i++) m.V()[i]=V()[i];} + + void ToEulerAngles(T &alpha, T &beta, T &gamma); + template void FromMatrix(const Matrix44Type & m){for(int i = 0; i < 16; i++) V()[i]=m.V()[i];} void FromEulerAngles(T alpha, T beta, T gamma); @@ -442,6 +448,14 @@ template void Matrix44::operator*=( const T k ) { _a[i] *= k; } +template +void Matrix44::ToEulerAngles(T &alpha, T &beta, T &gamma) +{ + alpha = atan2(ElementAt(1,2), ElementAt(2,2)); + beta = asin(-ElementAt(0,2)); + gamma = atan2(ElementAt(0,1), ElementAt(1,1)); +} + template void Matrix44::FromEulerAngles(T alpha, T beta, T gamma) {