[SDL] "Perfect" circles
David Olofson
david at olofson.net
Wed Nov 8 03:01:12 PST 2006
On Tuesday 31 October 2006 22:01, xEsk PiV wrote:
> Hello!
>
> Somebody knows why this code does not make "perfect" circles? How I
> can improve the precision? I have tested this same code in Delphi
> and works perfectly. Can it be problem of the SDL_Rect? I'm using
> C++.
What do you mean by "perfect"? (There are many definitions, some of
which are irrelevant in this context.)
[...]
> pos.x = pos.x + static_cast<Sint16>(units * pre_cos[ang]);
> pos.y = pos.y + static_cast<Sint16>(units * pre_sin[ang]);
[...]
Rounding before you center the circle is probably a bad idea, unless
you ensure that the rounding is done the exact way you intend. You'll
get different results depending on whether rounding is done towards
minus infinity or towards zero.
//David Olofson - Programmer, Composer, Open Source Advocate
.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
'-- http://www.reologica.se - Rheology instrumentation --'
More information about the SDL
mailing list