Why does sin(180) not return 0? [SOLVED]

Omniso

  • Posts: 185
When using trigonometry to move actors around a circle, I've noticed that their X,Y coordinates are always slightly off from the expected result (mainly because they're attached to other actors with contrasting colors). Let's take two actors (Actor A, Actor B) for example, and say that the math in the code dictates that:

Actor A's  Y coordinate should be [ 735 + Sin(0) ],
and
Actor B's Y coordinate should be [ 735 + Sin(180) ].

Both should be at 735 since Sin(180) and Sin(0) are 0, but the actual result is that Actor B's Y coordinate is 734 and Actor A's Y coordinate is 735. When you throw cosine into the mix for determining the X coordinate, the same thing happens for the angles 90 and 270. This creates a scenario where actors can slightly shift out of place and look somewhat floaty while moving around the circle.  When I printed the value of Sin(180), the value wasn't 0, but it was "-9.293710953857782e-14". That's so close, but still off to distort the actor's coordinates. Why does this happen?

Edit: Nevermind. I understand now.

« Last Edit: March 19, 2020, 04:23:34 pm by Omniso »