Path: chuka.playstation.co.uk!news From: James Shaughnessy Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: Bresenham, [Desmond] Lynham and their mates.... Date: Sat, 30 Jan 1999 01:38:47 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 149 Message-ID: <36B262A6.BEACFA04@manc.u-net.com> References: <36B1FF9D.B55ED267@cwcom.net> NNTP-Posting-Host: manc.u-net.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------789C96C875E4A7EEBCF4AEFC" X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: en --------------789C96C875E4A7EEBCF4AEFC Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Aah indeed, the equation of a circle. The equation that, er, is quite round. And also indeed pythagoras' theorum. Here's the maths: (r = radius, and ^2 means to the power of 2 of course) r^2 = x^2 + y^2 [or] r = ± sqrt(x^2 + y^2) so.. x = cx ± sqrt( r^2 - y^2 ) y = cy ± sqrt( r^2 - x^2 ) ..where cx and cy are the centre coordinates of the circle ( 0 and 0 in your case) It's gonna be slow on the PSX, so if the circle is always the same size it's best to use pre-calculated LUTs obviously. The problem is though that there is still an "unknown", ie. x and y are meaningless without an angle Ø or knowing at least one of x or y already. If you know the angle then use basic trig (sin() cos() etc using SOHCAHTOA*) otherwise use one of the second two equations in LUT form. Which is nice. * SOHCAHTOA - "Sex On Horseback Can Always Have Two Obvious /| Advantages" as my maths teacher always said! H/ |O SOH -> Sin(Ø) = Opposite / Hypotenuse /Ø_| CAH -> Cos(Ø) = Adjacent / Hypotenuse A TOA -> Tan(Ø) = Opposite / Adjacent Jim "Putting me in jail for attempted murder! I mean honestly -- do they give you a Nobel Prize for attempted Chemistry?" - Bob Tones wrote: > Hi! > > Quick question..... > > I have a circle at point 0,0, with a radius of 10 (example). OK, a > bit like this :(Use fixed width font!) > > > xBx > xx xn <----Point n > x x > x x > x c x - Sposed to be 10 high, but I'm crap at > this! > x x > x x > xx xx > xxx > > Here is my problem. If point 'c' is at 0,0, how do I calculate where > point n is (ie what is it's x and y values?) from point c. > > The idea is, when the user presses 'right', the line start off from > 0,0 to point B, and goes right to point n. (from c) > > I hope you get what I mean - I spose the nearest example would be a > clock!!!! > > Cheers! > > Tones 8) --------------789C96C875E4A7EEBCF4AEFC Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Aah indeed, the equation of a circle.  The equation that, er, is quite round.  And also indeed pythagoras' theorum.

Here's the maths: (r = radius, and ^2 means to the power of 2 of course)

r^2 = x^2 + y^2     [or]    r = ± sqrt(x^2 + y^2)

so..

x = cx ± sqrt( r^2 - y^2 )
y = cy ± sqrt( r^2 - x^2 )

..where cx and cy are the centre coordinates of the circle ( 0 and 0 in your case)
It's gonna be slow on the PSX, so if the circle is always the same size it's best to use pre-calculated LUTs obviously.

The problem is though that there is still an "unknown", ie. x and y are meaningless without an angle Ø or knowing at least one of x or y already.  If you know the angle then use basic trig (sin() cos() etc using SOHCAHTOA*) otherwise use one of the second two equations in LUT form.  Which is nice.

* SOHCAHTOA - "Sex On Horseback Can Always Have Two Obvious
    /|         Advantages" as my maths teacher always said!
  H/ |O          SOH -> Sin(Ø) = Opposite / Hypotenuse
  /Ø_|           CAH -> Cos(Ø) = Adjacent / Hypotenuse
   A             TOA -> Tan(Ø) = Opposite / Adjacent

Jim

"Putting me in jail for attempted murder!  I mean honestly -- do they give you a Nobel Prize for attempted Chemistry?" - Bob
 

Tones wrote:

Hi!

Quick question.....

I have a circle at point 0,0, with a radius of 10 (example).  OK, a bit like this :(Use fixed width font!)
 

                    xBx
                  xx   xn    <----Point n
                 x       x
                x         x
                x    c    x    - Sposed to be 10 high, but I'm crap at this!
                x         x
                 x       x
                  xx   xx
                    xxx

Here is my problem.  If point 'c' is at 0,0, how do I calculate where point n is (ie what is it's x and y values?) from point c.

The idea is, when the user presses 'right', the line start off from 0,0 to point B, and goes right to point n. (from c)

I hope you get what I mean - I spose the nearest example would be a clock!!!!

Cheers!

Tones 8)

--------------789C96C875E4A7EEBCF4AEFC--