delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/09/06:04:14

From: Bill Currie <bill AT taniwha DOT tssc DOT co DOT nz>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Movement Revisited
Date: Fri, 09 Oct 1998 22:37:55 +1300
Organization: NetLink Wellington, New Zealand.
Lines: 25
Message-ID: <361DD973.9061DCEB@taniwha.tssc.co.nz>
References: <361cc01b DOT 1648816 AT ct-news DOT iafrica DOT com>
NNTP-Posting-Host: nzlu02.tssc.co.nz
Mime-Version: 1.0
X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.1.117 i486)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Marc Brooker wrote:
> 
> Hello All,
> 
> Firstly, thanks for the help of all those who posted replys to my
> message about tank movement.
> At about three o' clock yesterday i came up with a much better
> solution to that problem and thought some of you might be interested,
> here is the entire function, note no trig functions needed. Pity about
> wasting speed with doubles but it is the best way to do it.

I don't know if this has been suggested (I didn't read the original
thread), but you might want to look into Bresenham's line algorithm to
avoid fp (any good graphics text should have it, check the graphics faq
(comp.graphics??) and see if it can be applied to your problem.  It
might also eliminate the need to fudge a unit vector as it appears you
were doing in your code.

Oh, one important thing: fp is notoriously inaccurate (eg 0.1 is NOT
representable) and you really should never compare directly with 0 but
with -e..+e (e is epsilon, some small value).

Bill
-- 
Leave others their otherness.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019