Need some Math help please!


Hey guys, I'm playing with DirectX and I am trying to make a ship fly from nav point to nav point. Which seems to work from the origin to any point I place, the ship flies to it. But if I start the ship at some point other than 0,0,0 my ship behaves like it's being flown by a drunken pilot.

Basically I am trying to calculate the angle between the ships direction vector, and the nav point to decide how many radians to turn the ship on that plane. Can any of you guys spot why the acos function doesn't return a 90 degree angle?

Knowing that vDirX is (1,0), vNavX is (0,0) and vDirY is (0, 0) and vNavY is (0,0):


float anglex = acos( ((vNavX.y * vDirX.y)+(vNavX.x * vDirX.x)) / (D3DXVec2Length(&vNavX) * D3DXVec2Length(&vDirX)) );

float angley = acos( ((vNavY.y * vDirY.y)+(vNavY.x * vDirY.x)) / (D3DXVec2Length(&vNavY) * D3DXVec2Length(&vDirY)) );

Why is acos returning me -1.#IND000 for both angles?

Thanks a lot guys if you can help me....
Never mind, I was dividing by 0... Ughh hehe. :o

:) reminds me of sitting in my C Programming for Engineers class...


"You missed a letter in your second variable"

"..........oh......STUPID COMPUTER...."

"The computer didn't make you screw that up"

".....well...yeah......SHUT UP!"
At least some of the newer vs c++ compiler notices some wacky stuff. Like once in my IF i was doing a = instead of == and it actually throws an error... unlike before it'd just work and you could spend days trying to figure out why the it's not doing what you want hehe.