From 499b368150c708170be4ff7f403b89d0eadaa4e9 Mon Sep 17 00:00:00 2001 From: ponchio Date: Tue, 9 Mar 2004 20:54:57 +0000 Subject: [PATCH] Double - float conversions. --- vcg/math/quaternion.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/vcg/math/quaternion.h b/vcg/math/quaternion.h index 385f318d..87889f9f 100644 --- a/vcg/math/quaternion.h +++ b/vcg/math/quaternion.h @@ -164,32 +164,32 @@ template void Quaternion::ToMatrix(Matrix44 &m) const { ///warning m deve essere una matrice di rotazione pena il disastro. template void Quaternion::FromMatrix(Matrix44 &m) { - double Sc; - double t = (m[0] + m[5] + m[10] + 1); + S Sc; + S t = (m[0] + m[5] + m[10] + (S)1.0); if(t > 0) { - Sc = 0.5 / sqrt(t); - V(0) = 0.25 / Sc; + Sc = (S)0.5 / math::Sqrt(t); + V(0) = (S)0.25 / Sc; V(1) = ( m[9] - m[6] ) * Sc; V(2) = ( m[2] - m[8] ) * Sc; V(3) = ( m[4] - m[1] ) * Sc; } else { if(m[0] > m[5] && m[0] > m[10]) { - Sc = sqrt( 1.0 + m[0] - m[5] - m[10] ) * 2; - V(1) = 0.5 / Sc; + Sc = math::Sqrt( (S)1.0 + m[0] - m[5] - m[10] ) * (S)2.0; + V(1) = (S)0.5 / Sc; V(2) = (m[1] + m[4] ) / Sc; V(3) = (m[2] + m[8] ) / Sc; V(0) = (m[6] + m[9] ) / Sc; } else if( m[5] > m[10]) { - Sc = sqrt( 1.0 + m[5] - m[0] - m[10] ) * 2; + Sc = math::Sqrt( (S)1.0 + m[5] - m[0] - m[10] ) * (S)2.0; V(1) = (m[1] + m[4] ) / Sc; - V(2) = 0.5 / Sc; + V(2) = (S)0.5 / Sc; V(3) = (m[6] + m[9] ) / Sc; V(0) = (m[2] + m[8] ) / Sc; } else { - Sc = sqrt( 1.0 + m[10] - m[0] - m[5] ) * 2; + Sc = math::Sqrt( (S)1.0 + m[10] - m[0] - m[5] ) * (S)2.0; V(1) = (m[2] + m[8] ) / Sc; V(2) = (m[6] + m[9] ) / Sc; - V(3) = 0.5 / Sc; + V(3) = (S)0.5 / Sc; V(0) = (m[1] + m[4] ) / Sc; } }