Skip to main content
Inspiring
May 1, 2006
Answered

Calculating arc tangent of 0.12 degrees

  • May 1, 2006
  • 2 replies
  • 799 views
ActionScript really does know to be annoyed sometimes!

I'm trying to calculate arc tangent of a number.
I'm using the following code:

arctg_mi = Math.atan(Math.PI/180 * 0.12)

As you can see, I need to calculate arc tangent of 0.12 degrees. Problem is that it just cannot be done. I'm not an expert of mathematics, but it seems that radian system does not behave like degrees system when it comes to arc tangent!
I used Windows' Calculator, and arc tangent of 0.12 in degrees system is about 6.84, which is right. But when I switch to radian system, then convert 0.12 degrees to radians, and then try to calculate, I get the wrong value. Totally wrong!
Solution? Either I am so stupid that I missed some ordinary procedure in all of this, or these two systems are not comparable.
Or do I need to convert the value I get back to degrees system somehow?

The easiest thing to do would be to switch Flash to degrees system, but that can't be done, so...

Help, please...
This topic has been closed for replies.
Correct answer Newsgroup_User
It comes out to 6.84 in Flash too, if you do it right. First off, degrees
per radian is 180/Pi not Pi/180. And you want to get the arctangent of the
value, which comes out in radians, then convert to degrees - you don't want
to take the arctangent of the degrees....

So:
var degreesPerRadian = 180.0 / Math.PI;
trace(Math.atan(0.12) * degreesPerRadian)

6.84277341263094


HTH


--
Dave -
Adobe Community Expert
www.blurredistinction.com
www.macromedia.com/support/forums/team_macromedia/


2 replies

Kolja1987Author
Inspiring
May 1, 2006
As I said, I missed an ordinary procedure. Well, not that, but I definitely screwed up!

Thanks, Dave!
Newsgroup_UserCorrect answer
Inspiring
May 1, 2006
It comes out to 6.84 in Flash too, if you do it right. First off, degrees
per radian is 180/Pi not Pi/180. And you want to get the arctangent of the
value, which comes out in radians, then convert to degrees - you don't want
to take the arctangent of the degrees....

So:
var degreesPerRadian = 180.0 / Math.PI;
trace(Math.atan(0.12) * degreesPerRadian)

6.84277341263094


HTH


--
Dave -
Adobe Community Expert
www.blurredistinction.com
www.macromedia.com/support/forums/team_macromedia/