How to convert radians to degrees while using Math..asin

Participant ,
Sep 27, 2021 Sep 27, 2021

Copy link to clipboard

Copied

If


     trace(Math.sin((Math.PI/6)));          //          .499999       Correct

     trace(Math.asin((.499999)));          //          .523597        Correct

 

but


     trace(Math.sin(30*Math.PI/180));          //          0.49999        Correct

      trace(Math.asin(.49999*Math.PI/180));          //          0.008726        Wrong

 

else

 

      trace(Math.asin(.49999*180/Math.PI));          //          30.000        Correct ?

 

My Math.asin function should use the radian to degrees conversion factor of  Math.PI/180 but appears to be 180/Math.PI.

Can anyone explain why this is?

 

TOPICS
Code , How to

Views

98

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Sep 27, 2021 Sep 27, 2021
the trig functions are the inverse of the arc trig functions. the trig functions have an argument that's an angle (in radians) and yield a number.  the arc functions have a number for an argument and yield an angle (in radians). so yes, if you want the sin of 30 degrees, use: Math.sin(30*Math.PI/180);  // converted angle to radians if you want the angle (in degrees) whose sin is .5, use: Math.asin(.5)*180/Math.PI and while our brains are perfectly capable of working with radians withou...

Likes

Translate

Translate
Adobe Community Professional ,
Sep 27, 2021 Sep 27, 2021

Copy link to clipboard

Copied

to convert rad to deg, multiply by 180/Math.PI

 

Math.asin(.5)*180/Math.PI;  // should be 30 (degrees)

 

i don't know if you have typos in this forum (ie, your parenthesis are misplaced), but some of what you posted (adjusting the argument in asin) is non-sense from a mathematical point of view.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 27, 2021 Sep 27, 2021

Copy link to clipboard

Copied

Thanks for the reply, it is interesting the code I posted has always worked for sin, cos, and tan, but maybe there's something funny about the parenthesis as you suggest.

If anyone could elaborate on this, I don't see exactly what is wrong.

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 27, 2021 Sep 27, 2021

Copy link to clipboard

Copied

LATEST

the trig functions are the inverse of the arc trig functions. the trig functions have an argument that's an angle (in radians) and yield a number.  the arc functions have a number for an argument and yield an angle (in radians).

 

so yes, if you want the sin of 30 degrees, use:

 

Math.sin(30*Math.PI/180);  // converted angle to radians

 

if you want the angle (in degrees) whose sin is .5, use:

 

Math.asin(.5)*180/Math.PI

 

and while our brains are perfectly capable of working with radians without degree conversion, when it comes to digital computers, that doesn't work so well.  a digital computer isn't go to tell you asin(PI/4) = sqrt(2)/2.  and while i've seen the decimal output of that so many times, i know .707...is sqrt(2)/2, i would not recognize the radian equivalent of 35 degrees.  (and i have a phd in math.)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines