[DEBUG] Some equation correction of the vector
This commit is contained in:
parent
0b2050cf68
commit
df8a54b55a
@ -76,14 +76,14 @@ namespace etk
|
|||||||
* + operator
|
* + operator
|
||||||
*****************************************************/
|
*****************************************************/
|
||||||
Vector3D<T> operator+ (const Vector3D<T>& obj) {
|
Vector3D<T> operator+ (const Vector3D<T>& obj) {
|
||||||
Vector3D<T> tmpp(x,y,y);
|
Vector3D<T> tmpp(x,y,z);
|
||||||
tmpp.x += (T)obj.x;
|
tmpp.x += (T)obj.x;
|
||||||
tmpp.y += (T)obj.y;
|
tmpp.y += (T)obj.y;
|
||||||
tmpp.z += (T)obj.z;
|
tmpp.z += (T)obj.z;
|
||||||
return tmpp;
|
return tmpp;
|
||||||
}
|
}
|
||||||
Vector3D<T> operator+ (const float val) {
|
Vector3D<T> operator+ (const float val) {
|
||||||
Vector3D<T> tmpp(x,y,y);
|
Vector3D<T> tmpp(x,y,z);
|
||||||
tmpp.x += val;
|
tmpp.x += val;
|
||||||
tmpp.y += val;
|
tmpp.y += val;
|
||||||
tmpp.z += val;
|
tmpp.z += val;
|
||||||
@ -108,14 +108,14 @@ namespace etk
|
|||||||
* - operator
|
* - operator
|
||||||
*****************************************************/
|
*****************************************************/
|
||||||
Vector3D<T> operator- (const Vector3D<T>& obj) {
|
Vector3D<T> operator- (const Vector3D<T>& obj) {
|
||||||
Vector3D<T> tmpp(x,y,y);
|
Vector3D<T> tmpp(x,y,z);
|
||||||
tmpp.x -= (T)obj.x;
|
tmpp.x -= (T)obj.x;
|
||||||
tmpp.y -= (T)obj.y;
|
tmpp.y -= (T)obj.y;
|
||||||
tmpp.z -= (T)obj.z;
|
tmpp.z -= (T)obj.z;
|
||||||
return tmpp;
|
return tmpp;
|
||||||
}
|
}
|
||||||
Vector3D<T> operator- (const float val) {
|
Vector3D<T> operator- (const float val) {
|
||||||
Vector3D<T> tmpp(x,y,y);
|
Vector3D<T> tmpp(x,y,z);
|
||||||
tmpp.x -= val;
|
tmpp.x -= val;
|
||||||
tmpp.y -= val;
|
tmpp.y -= val;
|
||||||
tmpp.z -= val;
|
tmpp.z -= val;
|
||||||
@ -149,7 +149,7 @@ namespace etk
|
|||||||
* / operator
|
* / operator
|
||||||
*****************************************************/
|
*****************************************************/
|
||||||
Vector3D<T> operator/ (const Vector3D<T>& obj) {
|
Vector3D<T> operator/ (const Vector3D<T>& obj) {
|
||||||
Vector3D<T> tmpp(x,y,y);
|
Vector3D<T> tmpp(x,y,z);
|
||||||
if (obj.x != 0) {
|
if (obj.x != 0) {
|
||||||
tmpp.x /= (T)obj.x;
|
tmpp.x /= (T)obj.x;
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ namespace etk
|
|||||||
return tmpp;
|
return tmpp;
|
||||||
}
|
}
|
||||||
Vector3D<T> operator/ (const float val) {
|
Vector3D<T> operator/ (const float val) {
|
||||||
Vector3D<T> tmpp(x,y,y);
|
Vector3D<T> tmpp(x,y,z);
|
||||||
if (val==0) {
|
if (val==0) {
|
||||||
return tmpp;
|
return tmpp;
|
||||||
}
|
}
|
||||||
@ -190,14 +190,14 @@ namespace etk
|
|||||||
* * operator
|
* * operator
|
||||||
*****************************************************/
|
*****************************************************/
|
||||||
Vector3D<T> operator* (const Vector3D<T>& obj) {
|
Vector3D<T> operator* (const Vector3D<T>& obj) {
|
||||||
Vector3D<T> tmpp(x,y,y);
|
Vector3D<T> tmpp(x,y,z);
|
||||||
tmpp.x *= (T)obj.x;
|
tmpp.x *= (T)obj.x;
|
||||||
tmpp.y *= (T)obj.y;
|
tmpp.y *= (T)obj.y;
|
||||||
tmpp.z *= (T)obj.z;
|
tmpp.z *= (T)obj.z;
|
||||||
return tmpp;
|
return tmpp;
|
||||||
}
|
}
|
||||||
Vector3D<T> operator* (const float val) {
|
Vector3D<T> operator* (const float val) {
|
||||||
Vector3D<T> tmpp(x,y,y);
|
Vector3D<T> tmpp(x,y,z);
|
||||||
tmpp.x *= val;
|
tmpp.x *= val;
|
||||||
tmpp.y *= val;
|
tmpp.y *= val;
|
||||||
tmpp.z *= val;
|
tmpp.z *= val;
|
||||||
@ -264,7 +264,7 @@ namespace etk
|
|||||||
+ z*obj.z;
|
+ z*obj.z;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Normalize()
|
void Normalize(void)
|
||||||
{
|
{
|
||||||
float length=GetLength();
|
float length=GetLength();
|
||||||
if(length==1 || length==0) {
|
if(length==1 || length==0) {
|
||||||
@ -276,19 +276,19 @@ namespace etk
|
|||||||
z *= scalefactor;
|
z *= scalefactor;
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector3D<T> GetNormalized() const
|
Vector3D<T> GetNormalized(void) const
|
||||||
{
|
{
|
||||||
Vector3D<T> tmpp(*this);
|
Vector3D<T> tmpp(*this);
|
||||||
tmpp.Normalize();
|
tmpp.Normalize();
|
||||||
return tmpp;
|
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);
|
return (x*x)+(y*y)+(z*z);
|
||||||
};
|
};
|
||||||
@ -304,8 +304,8 @@ namespace etk
|
|||||||
if(angle==0.0) {
|
if(angle==0.0) {
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
float sinAngle=(float)sin(M_PI*angle/180);
|
float sinAngle=sinf(M_PI*angle/180);
|
||||||
float cosAngle=(float)cos(M_PI*angle/180);
|
float cosAngle=cosf(M_PI*angle/180);
|
||||||
|
|
||||||
return Vector3D<T>( x,
|
return Vector3D<T>( x,
|
||||||
y*cosAngle - z*sinAngle,
|
y*cosAngle - z*sinAngle,
|
||||||
@ -322,8 +322,8 @@ namespace etk
|
|||||||
if(angle==0.0) {
|
if(angle==0.0) {
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
float sinAngle=(float)sin(M_PI*angle/180);
|
float sinAngle=sinf(M_PI*angle/180);
|
||||||
float cosAngle=(float)cos(M_PI*angle/180);
|
float cosAngle=cosf(M_PI*angle/180);
|
||||||
return Vector3D<T>( x*cosAngle + z*sinAngle,
|
return Vector3D<T>( x*cosAngle + z*sinAngle,
|
||||||
y,
|
y,
|
||||||
-x*sinAngle + z*cosAngle);
|
-x*sinAngle + z*cosAngle);
|
||||||
@ -339,8 +339,8 @@ namespace etk
|
|||||||
if(angle==0.0) {
|
if(angle==0.0) {
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
float sinAngle=(float)sin(M_PI*angle/180);
|
float sinAngle=sinf(M_PI*angle/180);
|
||||||
float cosAngle=(float)cos(M_PI*angle/180);
|
float cosAngle=cosf(M_PI*angle/180);
|
||||||
return Vector3D<T>( x*cosAngle - y*sinAngle,
|
return Vector3D<T>( x*cosAngle - y*sinAngle,
|
||||||
x*sinAngle + y*cosAngle,
|
x*sinAngle + y*cosAngle,
|
||||||
z);
|
z);
|
||||||
@ -358,8 +358,8 @@ namespace etk
|
|||||||
}
|
}
|
||||||
Vector3D<T> u=axis.GetNormalized();
|
Vector3D<T> u=axis.GetNormalized();
|
||||||
Vector3D<T> rotMatrixRow0, rotMatrixRow1, rotMatrixRow2;
|
Vector3D<T> rotMatrixRow0, rotMatrixRow1, rotMatrixRow2;
|
||||||
float sinAngle=(float)sin(M_PI*angle/180);
|
float sinAngle=sinf(M_PI*angle/180);
|
||||||
float cosAngle=(float)cos(M_PI*angle/180);
|
float cosAngle=cosf(M_PI*angle/180);
|
||||||
float MinusCosAngle=1.0f-cosAngle;
|
float MinusCosAngle=1.0f-cosAngle;
|
||||||
rotMatrixRow0.x=(u.x)*(u.x) + cosAngle*(1-(u.x)*(u.x));
|
rotMatrixRow0.x=(u.x)*(u.x) + cosAngle*(1-(u.x)*(u.x));
|
||||||
rotMatrixRow0.y=(u.x)*(u.y)*(MinusCosAngle) - sinAngle*u.z;
|
rotMatrixRow0.y=(u.x)*(u.y)*(MinusCosAngle) - sinAngle*u.z;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user