Mail Archives: djgpp/1998/10/09/06:04:14
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 -