From df8a54b55a24afbbda666956ca729f404381945c Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 18 Dec 2012 22:11:33 +0100 Subject: [PATCH] [DEBUG] Some equation correction of the vector --- etk/math/Vector3D.h | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/etk/math/Vector3D.h b/etk/math/Vector3D.h index 5c85110..c9210fe 100644 --- a/etk/math/Vector3D.h +++ b/etk/math/Vector3D.h @@ -76,14 +76,14 @@ namespace etk * + operator *****************************************************/ Vector3D operator+ (const Vector3D& obj) { - Vector3D tmpp(x,y,y); + Vector3D tmpp(x,y,z); tmpp.x += (T)obj.x; tmpp.y += (T)obj.y; tmpp.z += (T)obj.z; return tmpp; } Vector3D operator+ (const float val) { - Vector3D tmpp(x,y,y); + Vector3D tmpp(x,y,z); tmpp.x += val; tmpp.y += val; tmpp.z += val; @@ -108,14 +108,14 @@ namespace etk * - operator *****************************************************/ Vector3D operator- (const Vector3D& obj) { - Vector3D tmpp(x,y,y); + Vector3D tmpp(x,y,z); tmpp.x -= (T)obj.x; tmpp.y -= (T)obj.y; tmpp.z -= (T)obj.z; return tmpp; } Vector3D operator- (const float val) { - Vector3D tmpp(x,y,y); + Vector3D tmpp(x,y,z); tmpp.x -= val; tmpp.y -= val; tmpp.z -= val; @@ -149,7 +149,7 @@ namespace etk * / operator *****************************************************/ Vector3D operator/ (const Vector3D& obj) { - Vector3D tmpp(x,y,y); + Vector3D tmpp(x,y,z); if (obj.x != 0) { tmpp.x /= (T)obj.x; } @@ -162,7 +162,7 @@ namespace etk return tmpp; } Vector3D operator/ (const float val) { - Vector3D tmpp(x,y,y); + Vector3D tmpp(x,y,z); if (val==0) { return tmpp; } @@ -190,14 +190,14 @@ namespace etk * * operator *****************************************************/ Vector3D operator* (const Vector3D& obj) { - Vector3D tmpp(x,y,y); + Vector3D tmpp(x,y,z); tmpp.x *= (T)obj.x; tmpp.y *= (T)obj.y; tmpp.z *= (T)obj.z; return tmpp; } Vector3D operator* (const float val) { - Vector3D tmpp(x,y,y); + Vector3D tmpp(x,y,z); tmpp.x *= val; tmpp.y *= val; tmpp.z *= val; @@ -264,7 +264,7 @@ namespace etk + z*obj.z; }; - void Normalize() + void Normalize(void) { float length=GetLength(); if(length==1 || length==0) { @@ -276,19 +276,19 @@ namespace etk z *= scalefactor; }; - Vector3D GetNormalized() const + Vector3D GetNormalized(void) const { Vector3D tmpp(*this); tmpp.Normalize(); return tmpp; }; - float GetLength() const + float GetLength(void) const { - return (float)sqrt((x*x)+(y*y)+(z*z)); + return sqrtf((x*x)+(y*y)+(z*z)); }; - float GetSquaredLength() const + float GetSquaredLength(void) const { return (x*x)+(y*y)+(z*z); }; @@ -304,8 +304,8 @@ namespace etk if(angle==0.0) { return (*this); } - float sinAngle=(float)sin(M_PI*angle/180); - float cosAngle=(float)cos(M_PI*angle/180); + float sinAngle=sinf(M_PI*angle/180); + float cosAngle=cosf(M_PI*angle/180); return Vector3D( x, y*cosAngle - z*sinAngle, @@ -322,8 +322,8 @@ namespace etk if(angle==0.0) { return (*this); } - float sinAngle=(float)sin(M_PI*angle/180); - float cosAngle=(float)cos(M_PI*angle/180); + float sinAngle=sinf(M_PI*angle/180); + float cosAngle=cosf(M_PI*angle/180); return Vector3D( x*cosAngle + z*sinAngle, y, -x*sinAngle + z*cosAngle); @@ -339,8 +339,8 @@ namespace etk if(angle==0.0) { return (*this); } - float sinAngle=(float)sin(M_PI*angle/180); - float cosAngle=(float)cos(M_PI*angle/180); + float sinAngle=sinf(M_PI*angle/180); + float cosAngle=cosf(M_PI*angle/180); return Vector3D( x*cosAngle - y*sinAngle, x*sinAngle + y*cosAngle, z); @@ -358,8 +358,8 @@ namespace etk } Vector3D u=axis.GetNormalized(); Vector3D rotMatrixRow0, rotMatrixRow1, rotMatrixRow2; - float sinAngle=(float)sin(M_PI*angle/180); - float cosAngle=(float)cos(M_PI*angle/180); + float sinAngle=sinf(M_PI*angle/180); + float cosAngle=cosf(M_PI*angle/180); float MinusCosAngle=1.0f-cosAngle; rotMatrixRow0.x=(u.x)*(u.x) + cosAngle*(1-(u.x)*(u.x)); rotMatrixRow0.y=(u.x)*(u.y)*(MinusCosAngle) - sinAngle*u.z;