marted? 03 luglio owner-sdl at lokigames.com ha scritto:
ok, consider one of the two to be the origin, so you have
Sender: owner-sdl at lokigames.com
Precedence: bulko-----(x)
(y) X in (x, y)x = cos ( alpha )
y = sin ( alpha )tan ( alpha ) = sin / cos = y / x
alpha = atan ( y / x )
but there is still 2 problem:
y coul be 0
atan return either alpha or alpha + PIso =>
if( !x ) alpha = sign ( y ) * PI / 2
else alpha = atan ( y / x ) + ( x > 0 ? 0 : PI )
I will suggest you to
check also the C function "atan2"
that do the zero check and
the right angle adjustment.
So your code becomes simple:
alpha = atan2 (y,x)
Bye,
Enzo.> Reply-To: sdl at lokigames.com