Path: chuka.playstation.co.uk!news From: "Martin Keates" Newsgroups: scee.yaroze.freetalk.english Subject: Re: Sprite direction Date: Thu, 30 Aug 2001 21:53:25 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 24 Message-ID: <9mm8vh$h6i11@www.netyaroze-europe.com> References: <9mlnpu$h6i2@www.netyaroze-europe.com> <9mlooj$h6i3@www.netyaroze-europe.com> <9mlpsn$h6i4@www.netyaroze-europe.com> <9mlu56$h6i5@www.netyaroze-europe.com> <9mm072$h6i6@www.netyaroze-europe.com> <9mm1bn$h6i7@www.netyaroze-europe.com> NNTP-Posting-Host: modem-907.bass.dialup.pol.co.uk X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 > But tan is still a really bad function to use as you will end up with divide > by zero errors with dx/dy, use cos / arcCos. Or, just use atan2 which takes 2 arguments and gives an unambigious angle. double atan2(double x, double y); atan2(x,y) will give you an angle in the range -pi to pi with 0 at 12 o'clock and the angle increasing clockwise. If you're more mathematically minded, then use atan2(y,x) which gives 0 at 3 o'clock and the angle increasing anticlockwise. The only domain error with it is if x and y are both 0, which would be madness anyway. :) Martin.