Hard time converting radians to angles?
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
i belive what you are looking to use are the acos() , asin() , and atan() functions.
for instance: tan() returns the ratio of the sides (y/x or opposite/adjacent) when given the angle in radians as the argument .... whereas atan() returns the angle in radians, when given the ratio of the sides ( y/x or opposite/adjacent) as the argument.
('arctan' -- called 'atan' here -- is the inverse function of 'tan'. it is the one that is actually used when you use the 2nd key on your calculator in conjunction with 'tan'. And as mentioned, angles are in radians. to convert to degrees, muliply the radian value by 180/pi)
[edit] the functions are called as "atan"... not "arctan" as i originally typed. sorry[/edit]
.
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
sorry, i made a typing mistake .. in C/C++ the functions are actually called as "asin()", "acos()" and "atan()"
follow the links i provided above and you'll see the prototypes.
the header is still the same (aka )
.
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
Cant you just convert the radians to degrees?
jbennet
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
Cant you just convert the radians to degrees?
he said he wanted the function thatreturns an angle, "like when you press 2nd then sin on a calculator"
the only functions that *return* angles are the arcsin, arccos, and arctan functions -- the inverse trigonometric functions.
the standard functions (sin, cos, tan) require you to already know the angle, give it as an argument, then the functions return a ratio.
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
Well, you could try using the derived maths functions:[TEX]\sin^{-1}x = atan(\frac{x}{\sqrt{1-x^{2}}})[/TEX]
[TEX]\cos^{-1}x = 2 * atan(1) - atan(\frac{x}{\sqrt{1-x^{2}}})[/TEX]
:)
Edit:: Sorry jephthah, I didn't read your post carefully :(
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
>Well, you could try using the derived maths functions:
Why would he when he already have asin and acos?
Besides why did you complicated the formula for acos(x) which is simply:
[tex]acos(x) = \frac{\pi}{2}-asin(x)[/tex]
siddhant3s
Practically a Posting Shark
816 posts since Oct 2007
Reputation Points: 1,486
Solved Threads: 140
>Why would he when he already have asin and acos?
That's what I meant with:
Edit:: Sorry jephthah, I didn't read your post carefully :(
Besides that, the answer I gave wasn't wrong, only a bit sluggish if there are already functions likeasin and acos in the standard function library.
So, there's no other possibility left then completely agree with you :)
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243