getting correct? Is something strange happening with the coding or am I
just doing something wrong?

OK, the critical thing for you to understand is that tan is continuous between -pi/2 and pi/2, so when you take the arctan of something it will only give you a value in this range. SO, when you're looking for an angle, you need to be aware of what quadrant your vector (x,y) is in: for example when (x,y)=(-3/2 , 3√3/2) , you are in the second quadrant. Arctan will give you an angle in the fourth quadrant though corresponding to the coordinates (x,y)=(3/2,-3√3/2) instead, which will be -pi/3. The angle *you* need though is pi-pi/3=2pi/3. Likewise when (x,y)=(-3/2 , -3√3/2), you are in the third quadrant, arctan will give you an angle corresponding to (x,y)=(3/2 , 3√3/2) or pi/3, while you need pi+pi/3=4pi/3
No comments:
Post a Comment