Path: chuka.playstation.co.uk!news From: john.j@netway.at Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: animation, collision detection, backgrounds Date: Mon, 19 Jul 1999 21:25:33 +0200 Organization: PlayStation Net Yaroze (SCEE) Lines: 39 Message-ID: <37937BAC.50F308A1@netway.at> References: <3786FE72.1BE9@hotmail.com> <7m8sug$dq823@chuka.playstation.co.uk> <379245BF.76BC9046@chowfam.demon.co.uk> NNTP-Posting-Host: t2p094.at-732.netway.at Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5 [de] (Win95; I) X-Accept-Language: de,en,nl > If x1, y1 and r1 are centre and radius of sphere 1, > and similarly for sphere 2 x2, y2, r2. > Then, > if ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) < ((r1 - r2) * (r1 - r2)) > have collision > > Whatever you do - don't square root! That eats cycles like no tomorrow... Maybe this one isn't interesting for you, but it has something to do with sqrt and 2bfast... (it's generally referred to z80 assembly): >Task: approximation in assembler to >-> a = sqrt ( b*b + c*c ) let's call it sentence of p... > >Well, I need a _FAST_ approximation. >The simpliest is: a+b >(I know, it is NO real approx., but it is simple...) there's another fun approx, it's very rough though: p:= max(a,b)+0.25*min(a,b) note: the 0.25* can be calculated by srl commands... -> srl a :shift right logical -> inc a : to minimize the error -> srl a :shift right logical I know - it's assembly on a intruction-poor cpu, and you won't need it, but I found it very interesting! (and the ng is sooooo silent) ;) (source: Cas C.) greetz obiWAN -- I hate bugs! - I like Starship Troopers...