N.A.N value ---SOLVED---
Code: Select all
#define Magn(x, y, Mag) Mag = ((x)*(x) + (y)*(y))
namespace Math
{
namespace Vector
{
class Vector_Calculator
{
public:
Containers::Base::XYZ Vector_Calculation( float GotoY, float GotoX, float X, float Y, float Speed )
{
Containers::Base::XYZ A;
//Calculate Magnitude.//
GotoX -= X;
GotoY -= Y;
float Magnitude;
Magn(GotoX, GotoY, Magnitude);
Magnitude *= Magnitude;
A.setX(GotoX);
A.setY(GotoY);
//Normilise//
Magnitude = sqrt(Magnitude);
GotoX /= Magnitude;
GotoY /= Magnitude;
//Go The Desired Speed.//
GotoX *= Speed;
GotoY *= Speed;
A.setX(GotoX);
A.setY(GotoY);
return A;
}
};
}
}
( How to detect a N.A.N value )
Code: Select all
bool Is_NAN( float Value )
{
//IEEE designed its floating point to make this statement false
//if it is nan.//
if( Value != Value )
return true;
//Since it passed the if condition we now know the value is not
//N.A.N therefore we return false saying that the statement "This value is N.A.N" is false.//
return false;
}
P.s I know I can sometimes be unclear as to my purpose, if my purpose is unclear and further clarification is needed please let me know.