kontra icon indicating copy to clipboard operation
kontra copied to clipboard

angleToTarget returns incorrect angle

Open straker opened this issue 1 year ago • 1 comments

I seem to have gotten my trig wrong and thought the way to calculate x,y from an angle was:

x = Math.sin(angle)
y = -Math.cos(angle)

When in reality it should be reversed.

x = Math.cos(angle)
y = -Math.sin(angle)

This made me incorrectly add a quarter rotation to angleToTarget to get the movement correct. I need to remove the quarter rotation, and then the angle will be correct.

straker avatar Aug 30 '22 01:08 straker

This also affects other helper functions like movePoint so need to do a one over on the code to make sure I find everything this affects.

straker avatar Aug 30 '22 04:08 straker