Skip to main content
Known Participant
February 24, 2015
Answered

Math.sin(Math.PI) strange result

  • February 24, 2015
  • 1 reply
  • 3373 views

Hi,

In my AE expression Math.sin(Math.PI) gives a result of 1.22E-16, in stead of the expected zero.

Does anyone know why?

This topic has been closed for replies.
Correct answer Dan Ebberts

Hi, Mylenium, thanks for your reply. I am using the latest version (who doesn't since CC... :-)

The current version number is 13.2.0.49

Can you confirm the issue?

Interesting background, you give. Thanks for that.

(Don't understand it completely, since Pi in decimal is not between 0 and 1, and 360º is 2π, so not in between 0 and 1 either.)

Still no reason to have such a strange deviation, in my opinion - every calculator will give 0 for the sine of π radians.

Fortunately the rotation tools and parameters work with degrees,

so it's clear that the software is able to convert the Radians to Degrees somewhere along ;-)


Sounds like it's JavaScript, not AE's implementation:

Javascript Math.cos and Math.sin are inaccurate. Is there any solution? - Stack Overflow

Dan

1 reply

-Jaydude-Author
Known Participant
February 24, 2015

Just contacted Adobe by chat. They will answer this asap.

-Jaydude-Author
Known Participant
February 24, 2015

Got a hint from MotionScript.com - 1.22E-16 is pretty close to zero.

That's true, and it will work like that in most cases. Thanks for this insight, Dan!

But why can't this be exact? Even the simple MacOSX-calculator knows what to do with Pi as a constant: It returns 0 for Sin(Pi).

I always wonder why computer people like to calculate in Radians rather than in Degrees.

I thought that by taking Pi as a unit, at least 1*Pi, 2*Pi etc would be exact...

Thought it would be more accurate, but that’s obviously not the reason!

It seems AE calculates Pi back to decimals.

I’m gonna ask to give us the option to calculate in Degrees, just like the rest of AE.

Mylenium
Legend
February 24, 2015

I always wonder why computer people like to calculate in Radians rather than in Degrees.

Why would anyone not? You need to see the bigger picture here: A lot of computer graphics operates based on vectors, matrices and quarternions and their ranges are for all intents and purposes always normalized between 0 and 1, including any Euler angle decompositions derived therefrom. The rest is obscure, but could of course be a specific bug. Since you haven't even told us your version of AE nor any other details we have no way of verifying anything.

Mylenium