Board index » delphi » the fastest algorithm for drawing a circle?
Alphone
![]() Delphi Developer |
Fri, 10 Sep 2004 11:49:05 GMT
|
Alphone
![]() Delphi Developer |
Fri, 10 Sep 2004 11:49:05 GMT
the fastest algorithm for drawing a circle?
I previously use lots of sin(..) & cos(..) calls to do that, and i'm very
unsatisfied with the performance. I believe that there must be some algorithm far better than mine, can you tell me? |
Finn Tolderlun
![]() Delphi Developer |
Fri, 10 Sep 2004 14:11:53 GMT
Re:the fastest algorithm for drawing a circle?Search the net for Bresenham's algorithm for circles and you will find what you need. -- Finn Tolderlund "Alphone" <Silf...@sohu.com> skrev i en meddelelse news:3c9e9e1d_1@dnews... Quote> I previously use lots of sin(..) & cos(..) calls to do that, and i'm very |
David J Taylo
![]() Delphi Developer |
Fri, 10 Sep 2004 19:09:36 GMT
Re:the fastest algorithm for drawing a circle?Quote"Alphone" <Silf...@sohu.com> wrote in message news:3c9e9e1d_1@dnews... the circle and use the table values. |
Michael Hanse
![]() Delphi Developer |
Fri, 10 Sep 2004 14:57:56 GMT
Re:the fastest algorithm for drawing a circle?use lookup tables (arrays) to store sin and cos Michael. Quote"Alphone" <Silf...@sohu.com> wrote in message news:3c9e9e1d_1@dnews... |
Nils
![]() Delphi Developer |
Sat, 11 Sep 2004 07:04:17 GMT
Re:the fastest algorithm for drawing a circle?You can use a table with sin and cos entries. Usually, you won't see the difference between a true circle and - say - one with about 80 line segments. This translates to a table of ONLY 20 value pairs, because, smart hehe, you You can precalculate this sin/cos table and re-use it anywhere where you If you want to draw a true circle then you can also use the sqr(x) + sqr(y) This also works ideally for painting circular areas. Just imagine a square if sqr(Xpos - Xmid) + sqr(Ypos - Ymid) < sqr(Radius) then You can optimise this by using scanlines, and precalculating sqr(Radius), Using an estimation method to find the left and right x per scanline would You can even make it neater by defining a band (Radius1 & Radius2) of a Regards, Nils QuoteAlphone <Silf...@sohu.com> wrote in message news:3c9e9e1d_1@dnews... |
Tomaz Koritni
![]() Delphi Developer |
Fri, 10 Sep 2004 21:02:17 GMT
Re:the fastest algorithm for drawing a circle?Hi Make a lookup table for results of sin and cos functions. Then, instead Tomaz Quote"Alphone" <Silf...@sohu.com> wrote in message news:3c9e9e1d_1@dnews... |
Saci
![]() Delphi Developer |
Sat, 11 Sep 2004 20:16:31 GMT
Re:the fastest algorithm for drawing a circle?Have you tried the Borland work ? Put a button on a form and put this code: Var i : Integer; "Alphone" <Silf...@sohu.com> escreveu na mensagem news:3c9e9e1d_1@dnews... Quote> I previously use lots of sin(..) & cos(..) calls to do that, and i'm very |
Volker W. Walte
![]() Delphi Developer |
Sun, 12 Sep 2004 01:56:53 GMT
Re:the fastest algorithm for drawing a circle?Quote> I previously use lots of sin(..) & cos(..) "Drawing Lines, Circles ands Ellipses in a Raster" using only (32 bit) integer arithmetic (Bresenham) I have this as PDF: 5 pages, 300 kB. There is cited Cossit; Line drawing with the NS32CG16 and drwaing circles with NS32CG16. |
Volker W. Walte
![]() Delphi Developer |
Sun, 12 Sep 2004 01:59:39 GMT
Re:the fastest algorithm for drawing a circle?see http://www.national.com/apnotes/apnotes_all_1.html AN-522 QuoteAlphone wrote: |
Andreas Koc
![]() Delphi Developer |
Sun, 12 Sep 2004 02:12:53 GMT
Re:the fastest algorithm for drawing a circle?QuoteAlphone wrote: the other points can be mirrored... -- |
Volker W. Walte
![]() Delphi Developer |
Sun, 12 Sep 2004 19:37:50 GMT
Re:the fastest algorithm for drawing a circle?Quote> There was a paper of Prof N. Wirth ETH Zrich UNIT BresPix; PROCEDURE PixelPut(x:xyPix_Rec; c:Char); PROCEDURE LineSimple(a,b:{Vw0Typ .}std_Int); PROCEDURE LineBres(a,b:{Vw0Typ .}std_Int); PROCEDURE CircleBresQuadrantHalf(r:{Vw0Typ .}std_Int); PROCEDURE EllipseBresQuadrant1(a,b:{Vw0Typ .}std_Int); BEGIN {+unit BresPix} |
Arthur E.F.Heinric
![]() Delphi Developer |
Fri, 17 Sep 2004 08:15:30 GMT
Re:the fastest algorithm for drawing a circle?There is another way to do it using rotations. Imagine the circle with center (X0, Y0) and radius R Set the initial point (R, 0) => (X0+R, Y0) var X:=R; Set the number of points to 2.Pi.R for I:=0 to Round(2*Pi*R) do The angle between each point is (2.Pi)/(2.Pi.R) = 1/R Cos(X) for small X is near 1 and Sin(X) for small X is near X and that is []s Alphone <Silf...@sohu.com> escreveu nas notcias de mensagem:3c9e9e1d_1@dnews... Quote> I previously use lots of sin(..) & cos(..) calls to do that, and i'm very |