www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/15/09:52:39

Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE37421FD@probe-2.acclaim-euro.net>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: sin(acos((float)i/1024))*0x10000L
Date: Mon, 15 Mar 1999 14:51:55 -0000
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.0.1460.8)
Reply-To: djgpp AT delorie DOT com

The Beyonder writes:
> after visiting a site on how to draw primitive shapes to the screen, 
> I decided to try this circle technique. It said to first generate a
> trigonomitry table full of sin_acos info?

I can't comment on why this doesn't work (as someone else said, it 
looks like an FPU emulation bug), but I'd just like to point out that
this is not a good method for drawing circles. Trig calls are the
obvious but uncool way to do it, and suffer from a lot of problems 
like rounding errors causing ugly blobs around the perimeter, and 
having to overdraw the same pixel several times (this is slow, and 
will cause major problems if you ever want to use an XOR or 
translucent drawing mode).

The Bresenham circle algorithm works entirely in integer units, with
perfect accuracy and no pixel overdraw. For details, see
http://www.heim2.tu-clausthal.de/PROJEKT/PRG/PCGAMES/bres.html,
or the do_circle() function from the Allegro source file gfx.c.


	Shawn Hargreaves.

- Raw text -


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