Are there any other trigonometric functions with 2 arguments, like $\mathrm{atan2}(x,y)$, but free from its drawbacks, like the need to adjust the range from $[-\frac{\pi}{2},\frac{\pi}{2}]$ to $[0,2\pi]$?
Asked
Active
Viewed 146 times
0
-
2I don't consider $\operatorname{atan2}$ a "trigonometric function"; it's simply a utility that returns the polar angle associated with Cartesian coordinates $(x,y)$. Despite the name, it is not some variant of $\arctan$ that has had its range "adjusted". (I believe it would be more appropriate to call the function, say, $\operatorname{arg2}$, given its association with the argument of a complex number.) – Blue Jun 08 '21 at 17:37
-
yes this is the arctangent2, only the problem persists (I'm talking about the range) – ayr Jun 08 '21 at 17:41
-
@omjoglekar can you tell me then how the map range is 0-2 pi? – ayr Jun 08 '21 at 17:41
-
1oh......havent studied that. all i know is tan^-1 (x) or the inverse tangent aka arctan (x) – Dusty_Wanderer Jun 08 '21 at 17:43
-
2@dtn: I guess I'm not clear on your question. By my reading, you were simply stating an opinion that a "drawback" of $\operatorname{atan2}$ (compared to $\operatorname{arctan}$?) is "the need to adjust the range" from $(-\pi/2,\pi/2]$ to $[0,2\pi)$ ... although the range of $\operatorname{atan2}$ is actually $(-\pi,\pi]$. (I was letting that slide.) ... Are you instead asking for a variant of $\operatorname{atan2}$ that returns angles in the range $[0,2\pi)$? (If so, then you can always just add $2\pi$ when $\operatorname{atan2}<0$.) – Blue Jun 08 '21 at 18:01
-
@omjoglekar "Are you instead asking for a variant of atan2 that returns angles in the range [0,2π)? (If so, then you can always just add 2π when atan2<0.)" yes this is what i'm looking for (alternatively) – ayr Jun 08 '21 at 18:30
-
2Side remark: $\operatorname{atan}2$ is a newcomer (invented around 40 years ago for computer needs, in particular for graphical needs). I am happy to use it but it is devoided of any theoretical interest. – Jean Marie Jun 08 '21 at 18:32
-
@JeanMarie depending on where and how to use, take if control systems - there are colossal scope for applied questions of mathematics, incl. trigonometry – ayr Jun 08 '21 at 18:37
-
1I haven't said that trigonometry is devoided of interest. I even think it a very important tool ! – Jean Marie Jun 08 '21 at 18:39
-
@JeanMarie I understood you. Atan2 originated as an auxiliary tool, but in fact there are important uses for it. – ayr Jun 08 '21 at 18:55
-
@omjoglekar please see my answer; – ayr Jun 10 '21 at 17:41
-
@Blue please see my answer; – ayr Jun 10 '21 at 17:41
-
@JeanMarie please see my answer; – ayr Jun 10 '21 at 17:41
1 Answers
0
I suggest the following solution. Use the material from here.
https://wumbo.net/formula/angle-between-two-vectors-2d/
This formula calculates the angle between two vectors in a range $[-\pi;\pi]$.
To scale to a range $[0;2\pi]$, use the modulo Mod:
$new_{\theta}=Mod[\theta+360,360]$ or $new_{\theta}=Mod[\theta+2\pi,2\pi]$, if using radians.
For a smooth approximation of the Mod, use the Does there exist a smooth approximation of $x \bmod y$?. Get a smooth atan2 that covers angles in a range $[0;2\pi]$. Simplest solution I know.
Dear experts, please check my solution.
ayr
- 793
-
1$\operatorname{Mod}[\theta+2\pi,2\pi]$, when applied to $\theta$ between $-\pi$ and $\pi$ (well, more than that, but that's all you need here), amounts to the same thing as my commented suggestion: Add $2\pi$ if $\operatorname{atan2}$ is negative. I don't really see a need to smoothe this operation, but I've been unclear about your intentions before. :) – Blue Jun 10 '21 at 17:56
-
@Blue Yes! But, your proposed solution requires the introduction of conditions that toggles the function. I don't really like that :)) As for "differentiability". In my problem, the 2-argument arctangent had to be smoothed by eliminating the discontinuities (which is achieved by changing the $\epsilon$ parameter), but I do not know how the derivative of the $Mod$ function is sought. Therefore, I tried to find its smooth and differentiable counterpart. – ayr Jun 10 '21 at 18:04
-
1
-
1