ashstampede
Programmer
I'm very lost in the fact that acos is returning ?-1.#IND000
What i am trying to calculate is a angle from two vectors.
now my
"float dot" is a negative number so my assumtion is "that must be why it is returing dived by zero".
the functions normal dotProduct are from [link] [/url]
the subtractVector is a function the subtract each individuall point ie. vec1.x - vec2.x as i didnt know how to overload the - sign for my structure.
thanks in advance.
What i am trying to calculate is a angle from two vectors.
now my
"float dot" is a negative number so my assumtion is "that must be why it is returing dived by zero".
Code:
//Get the Tanks current Location
Vector2D Alien = Vector2D();
Alien.x = m_tank->GetX();
Alien.z = m_tank->GetZ();
// Get the Heading of the Tanks turret to a new vector
Vector2D Heading = Vector2D();
Heading.x = cursor->GetX();
Heading.z = cursor->GetZ();
//location of the Targeted Tank is the Target variable
//We need to calculate the angle to turn to be centred with
//the target.
//What is the direction Vector of the target
//first subtract the vector
Vector2D TargetPos = subtractVector(Target,Alien);
//the normalize it
normal(TargetPos);
float dot = dotProduct(TargetPos,Heading);
//the angle of rotation needed
float theta = acos(dot);
//convert to degrees.
ToDegrees(theta);
the functions normal dotProduct are from [link] [/url]
the subtractVector is a function the subtract each individuall point ie. vec1.x - vec2.x as i didnt know how to overload the - sign for my structure.
thanks in advance.