| Jackson Marie (462) | |||
|
I have to do some calculations. In short, the math exercise is :
Suppose a man is standing at position xCurrentPt, yCurrentPt and with angle "Angle". Now he want to move to position xTargetPt, yTargetPt. Before walking he must rotate himself to a proper angle value. He'll continue to walk with his speed 'fSpeed' until he's reached the Target position (xTargetPt, yTargetPt) The problem is I can't get the new right angle when the target has been changed. Eg :
How to get the angle (or radian) between the current point and the target point? What the function is used to do this? Help please... | |||
|
Last edited on
|
|||
| AleaIactaEst (99) | |||
|
This might help you: http://en.wikipedia.org/wiki/Triangle#Computing_the_sides_and_angles As the length of the triangle sides you should use the x and y distance of the man to the target. For example:
Now all you need to do is to calculate the angle between those two lines (think of it as a triangle, which means, connect the end of the horizontalLine with the end of the verticalLine). It probably helps to make a sketch. By the way: You get all the trigonometric functions you need through the cmath ( http://www.cplusplus.com/reference/clibrary/cmath/ ) library. | |||
|
Last edited on
|
|||