Lasse Svensson wrote:
> My question is a mathematical one, here we go:
> 
> As you can see here "    angle2 = (atan((y2pos-ypos) /
> (x2pos-xpos)))/(PI/180)" I determined the angle of the second object by
> calculating the angle between the two objects. It works as long as
> angle2 is less than 90 or more than 270, but if it gets between there it
> breaks away.

Compare Math.atan and Math.atan2. Math.atan2 relieves you from doing a 
manual branching depending on the angle.

Regards
Stefan
-- 
Posted via http://www.ruby-forum.com/.