How calculate the angle between two points

I have a app which has a image sprite, and when the user clicks on the screen, the image sprite is supposed to move to the specific point that the user clicks on. I'm using the function asin(x_1-x_2/y_1-y_2), to find the correct angle, which will be the heading of the image sprite. But the function doesn't give correct angle. In short how do i find the angle of a line relative to the x or y-axis between two points.

Application file
the_app.aia (142.7 KB)

It's easier in AI2 if you use the MoveTo block, like in https://docs.google.com/document/d/1vMOewOPYmN4gzbDiXJgLeCQ1W5MzuT7ogXQqV96R0P8/edit#heading=h.e6km4ffvayf1

Regarding AI2 angles, they are measured in degrees counterclockwise from the positive x axis.

Regarding your trigonometry, what you want is atan2(dY, dX)
math_atan2
where dY is the Y difference and dX is the X difference.
Note that in AI2, y increases downwards.

1 Like

Thanks for the help, i could've done this with the PointInDirection block, but i figured i could learn a bit more by doing it with trig functions, its not as efficient but as least i know how this stuff works now.