We are about to switch to a new forum software. Until then we have removed the registration on this forum.
The p5js page for atan2 states that it works in the following way:
Calculates the angle (in radians) from a specified point to the coordinate origin as measured from the positive x-axis.
However, I would like to calculate the angle between a set of points other than the origin. Is there any way to do this, and if so, can I get a pointer towards the right track? Thanks in advance! :)
Answers
I figured out solving my problem rather quickly. Reading the documentation all the way really helps :P
can you share your result briefly please?
I realized that I could use atan2() in the form of
atan2(y2 - y1, x2 - x1)
. I then applied that to a sprite rotation (p5.play.js) by converting the radians angle to degrees (since atan2() returns an angle in radians, and p5.play's rotation method needs it in degrees). This got me my final code:I probably would have ended up asking another pointless question had I not noticed that p5.play takes the rotation in degrees, while atan2 returns an angle in radians :P