Board index » delphi » Drawing a circle
Sean Radford
![]() Delphi Developer |
Sat, 01 Apr 2000 03:00:00 GMT
|
Sean Radford
![]() Delphi Developer |
Sat, 01 Apr 2000 03:00:00 GMT
Drawing a circleDoes anyone out there know the formula for a circle. I know you can work out the corresponding x and y value for any point given Any help gratefully received. Sean Radford |
Jawed Kari
![]() Delphi Developer |
Sat, 01 Apr 2000 03:00:00 GMT
Re:Drawing a circleQuoteSean Radford wrote in message <01bcd8ee$2303d100$9763989e@bladesys>... X^2 + Y^2 = R^2 |
Uncle Mi
![]() Delphi Developer |
Sat, 01 Apr 2000 03:00:00 GMT
Re:Drawing a circleIn article <01bcd8ee$2303d100$9763989e@bladesys>, QuoteSean Radford <s...@bladesys.demon.co.uk> wrote: the formula for a circle is x^2 + y^2 = r^2. If what you really want is to draw a circle on a pixel-map, there are more efficient ways to determine the points. Any basic graphics text should have them. Here's a procedure, lifted wholesale from the Oberon System, implementing the Bresenham algorithm. PROCEDURE circle(f: GraphicFrames.Frame; col: INTEGER; x0, y0, r: LONGINT); -- |
Invent Engineerin
![]() Delphi Developer |
Sun, 02 Apr 2000 03:00:00 GMT
Re:Drawing a circleQuoteSean Radford wrote: for d := 0 to 360 do Of course if you want a solid circle then save the previous x and y's |
Paul Bolchov
![]() Delphi Developer |
Sun, 02 Apr 2000 03:00:00 GMT
Re:Drawing a circleIn article <01bcd8ee$2303d100$9763989e@bladesys>, QuoteSean Radford <s...@bladesys.demon.co.uk> wrote: (x-a)^2 - (y-b)^2 = r^2 Paul Bolchover |
Rodney E Geraght
![]() Delphi Developer |
Sun, 02 Apr 2000 03:00:00 GMT
Re:Drawing a circleSean, Sqr(X1 - X0) + Sqr(Y1 - Y0) := Sqr(R) Where X0 and Y0 are the coords for the center and R is the radius. To solve for X1 given a value for Y1 you would use: X1 := X0 + Sqrt(Sqr(R) - Sqr(Y1-Y0)); The reason for 2 equations is that for each Y coord there will be two Also you might want to solve Sqr(R) - Sqr(Y1-Y0) first as a negative value Hope this helps! Rodney E Geraghty Sean Radford <s...@bladesys.demon.co.uk> wrote in article Quote> Does anyone out there know the formula for a circle. |
Pete Barre
![]() Delphi Developer |
Sun, 02 Apr 2000 03:00:00 GMT
Re:Drawing a circleOn Tue, 14 Oct 1997 22:13:38 GMT, "Sean Radford" <s...@bladesys.demon.co.uk> Quote>Does anyone out there know the formula for a circle. could probably look it up. Pete Barrett |
Eric Barb
![]() Delphi Developer |
Sun, 02 Apr 2000 03:00:00 GMT
Re:Drawing a circleQuoteIn article <344408A8.3FA7A...@ozonline.com.au> r...@careless.net.au writes: :for d := 0 to 360 do : x := cos(d) * radius; : y := sin(d) * radius; : plot(x,y); :end; :Of course if you want a solid circle then save the previous x and y's :and join them with a line. don't most 1anguages which offer a plot function also offer a circle function? Eric |
Toto
![]() Delphi Developer |
Sun, 02 Apr 2000 03:00:00 GMT
Re:Drawing a circleQuote101711.1...@compuserve.com (Pete Barrett) writes: bit easier to write. But the question is, why? You can SelectObject(hDC, hBitmap); -- -Thanh Lim |
David Ullric
![]() Delphi Developer |
Sun, 02 Apr 2000 03:00:00 GMT
Re:Drawing a circleQuoteInvent Engineering wrote: x := a + cos(d) * radius; if for some reason you don't want the center at the origin... -- sig.txt not found |
Uncle Mi
![]() Delphi Developer |
Sun, 02 Apr 2000 03:00:00 GMT
Re:Drawing a circleIn article <01bcd9d0$1166b560$1962420c@efgdell>, Quote
of Comp.lang.oberon. -- Lazlo's Chinese Relativity Axiom: No matter how great your triumphs or how tragic your defeats, over a billion Chinese couldn't care less. |
Earl F. Glyn
![]() Delphi Developer |
Mon, 03 Apr 2000 03:00:00 GMT
Re:Drawing a circleTotoro <tot...@netcom.com> wrote in article Quote> 101711.1...@compuserve.com (Pete Barrett) writes: Quote> >wrote: Why not just use Canvas.Ellipse and pass it a "square": For example, Canvas.Ellipse(0,0, 100,100); efg |
David Ullric
![]() Delphi Developer |
Mon, 03 Apr 2000 03:00:00 GMT
Re:Drawing a circleQuoteEarl F. Glynn wrote: not supposed to suggest easier ways to do something, because that's making assumptions about why the programmer is doing what he's doing, and you're not supposed to make assumptions like that. (Sorry, spillover from another thread. Seriously, -- sig.txt not found |
Douglas G. Danfort
![]() Delphi Developer |
Mon, 03 Apr 2000 03:00:00 GMT
Re:Drawing a circleQuoteUncle Mike wrote: PROCEDURE DrawCircle* (x, y, r: INTEGER); where Dot is any pixel drawer (with color previously set). -- |