Quote:
Originally posted by Zach L.
There are a couple problems I found with that particular function. The trivial ones: a missing semi-colon, and a return statement with no value.
There are a couple of other problems, however. You call normalize. This cannot be done from the angleBetween function because that function is const, and you can't modify the class from a const function. Regardless, you really don't want to change the user's vector without their knowledge (i.e. determining the angle between two vectors should not change either).
The other thing still relates to the vector dot product. The dot product is:
u*v = |u| |v| cos a
cos a = u*v / (|u| |v|)
Therefore, you have to divide by both their magnitudes to get the angle (which requires checking to see if both are 0 magnitude vectors).
Already fixed all of the problems :D .