Path: chuka.playstation.co.uk!news From: "pal" Newsgroups: scee.yaroze.freetalk.english Subject: Re: Daft Question Date: 20 Aug 2001 14:03:46 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 25 Message-ID: <01c1297e$8cb6e8a0$LocalHost@pal-s-omnibook> References: <9loc6a$p3k2@www.netyaroze-europe.com> <9loeu8$p3k3@www.netyaroze-europe.com> NNTP-Posting-Host: nas-cbv-6-11-21.dial.proxad.net X-Newsreader: Microsoft Internet News 4.70.1155 Coincidence... I just implemented that in Invs yesterday! After a bit of research, here is what I finally found out: Use atan2. It's designed for that. angleInPslibDegrees = (4096 * 180/PI) * atan2(x2 - x1, y1 - y2) with PI ~= 3.141592 - beware of the inverted y axis (on the screen it goes downwards while in math it usually goes upwards). - beware of the direction of the original sprite. This formula works with the original sprite pointing up (I'm not sure why). - if x2 == x1 and y2 == y1 can happen, be sure to remember and keep the angle before that step, as these values are not allowed (you'd get zero, which is normally not what you want). - as the whole calculus (including conversion to pslib degrees) ends up being far too long, I recommend using a precalculated table. I wrote a precalculator for Invs; let me know if you want to have a look at it. Hope this helps, pal