On 23.07.2011 13:03, sam.hacking@xxxxxxxx wrote:
Hi Sam I think your math is wrong: length_sqrd (1**2 + -1**2) returns 0 <--btw this line does not make much sense anyway, it should be length_sqrd(1, -1) this is not true, calculated correctly: 1** 2 + -1 ** 2 == 1 * 1 + -1 * -1 == 1 + 1 == 2 Your mistake basically was that you assumed that -1 ** 2 == -1 which is not. And I think the check in which quadrant the point is should be done in the get_angle method since get_length_sqrd just returns the length of a vector which does not depend on the quadrant. Using atan2 might be simpler but could not match with the angles pygame uses (besides of the potentially needed degree <-> radians translations). Hope this helps. ~DR0ID |