Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there never a tan2?

Tags:

math

The function atan2 accepts 2 variables x and y so it can return an angle of a range of 2pi instead of pi. But why is there never tan2 which is then the exact opposite of atan2 and returns 2 values x and y based on the given angle? Is there a simpler method to get the directional vector of an angle I'm missing?

like image 605
Didii Avatar asked Nov 23 '25 19:11

Didii


2 Answers

The deep reason is probably because FORTRAN functions return a single value.

Indeed, y= sin(x), x= cos(x) is what you need. (Alternatively, y= r * sin(x), x= r * cos(x) allows you to provide a vector length.)

This lack is a frustration for both users and implementors, because it is quite frequent to need both values at the same time, while this would allow optimizing away some common computations.

Well tan2 dosent exist because there isnt a single value of x and y that satisfies tan (theta) since tan is the ratio of opposite by adjacent.

Let us say that tan2 did exist Then tan2 (60°) would return

opp=sqrt (3)    &    adj=1

Since tan(60°)= opp/adj = sqrt (3)

But it could also return

opp=3           &    adj=sqrt (3)

And that would also be equal to sqrt (3);

Since tan is a ratio it returns only one value , that is The ratio of opposide to adjacent

And also in most programming languages a function can return only one value

like image 31
DollarAkshay Avatar answered Nov 26 '25 09:11

DollarAkshay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!