I'm using x + (distance * Math.cos(orientation * Math.PI))
and y + (distance * Math.sin(orientation * Math.PI))
to calculate xx
and yy
respectively.
50 + (20 * Math.sin(1 * Math.PI))
and 50 + (20 * Math.cos(0.5 * Math.PI))
equal 50
but
50 + (20 * Math.sin(2 * Math.PI))
and 50 + (20 * Math.cos(1.5 * Math.PI))
equal 49.99999999999999
?
I expected 50
here too. Is it a javascript quirk I need to use Math.ceil()
with (calculating coords on a canvas)?