#### Topic: Rotation formula

Me and SilverstepP have been working on a rotation formula for setting the angle of an object. We've run into an issue though; we can't get it to work from anywhere but the top-left quadrent in relation to the player.

Here's our formula:

```
let "$p_xpos_snapshot = player_xpos()"
let "$p_ypos_snapshot = player_ypos()"
//determining squared sides
let "$x2 = ($p_xpos_snapshot - xpos())^2"
let "$y2 = ($p_ypos_snapshot - ypos())^2"
//therefore
let "$h = sqrt($x2 + $y2)" //hypotenuse
let "$x = $p_xpos_snapshot - xpos()" //x value
let "$y = $$p_ypos_snapshot - ypos()" //y value
//from there we must determine the angle and direction to get rotation right
let "$top_angle = rad2deg(asin($x/$h)-pi()/2)"
set_angle "$top_angle"
```

This works every time from the top left, but never from any other direction. I'm lost at this point, if anyone know's what's going on please post.

thanks,

-lunarrush

*Last edited by lunarrush (2011-07-16 18:51:21)*