Maxwellkid
- 69
- 0
why is there a lack of accuracy in this subsitution?
\frac{sin\phi}{cos\phi} = tan\phi
\frac{sin\phi}{cos\phi} = tan\phi
The discussion revolves around the accuracy of the substitution of sine and cosine functions to define the tangent function, particularly in the context of solving equations and its implications in programming, such as calculating angles in game development.
Participants express differing views on the accuracy of the tangent function substitution, with some asserting its correctness while others highlight potential pitfalls in its application, particularly in solving equations and programming contexts. The discussion remains unresolved regarding the initial claim of inaccuracy.
Participants note that the perceived inaccuracies may stem from specific applications or manipulations of the trigonometric functions rather than the definitions themselves. There is also mention of the periodic nature of the tangent function affecting angle calculations.
Maxwellkid said:why is there a lack of accuracy in this subsitution?
Tac-Tics said:This reminds me of a problem I had back when I was interested in programming games. Given an object at position (x, y) with a velocity (dx, dy), what is the angle the object is moving at with relation to the x-axis?
What you find out is that arc tangent isn't quite what you need. Because tangent is periodic with a period of pi, the arc tangent function won't distinguish between the correct direction and the direction exactly opposite it.
Because of this, most computer languages implement a function called atan2. By taking dx and dy as two separate parameters (as opposed to taking their ration, dy/dx as the parameter), atan2 can distinguish between the two cases and can provide you the correct angle of motion for your object.