[comp.graphics] Circle algorithms

cutter@wpi.wpi.edu (Jeffrey T LeBlanc) (08/02/89)

Hello
     Does anyone out there have an algorithm handy that, when given the
coordinates of three XY points can return the circle that would fall on
them?  Any help along those lines would be appreciated.

						Cutter

NU113738@NDSUVM1.BITNET (08/04/89)

If you're looking for a Circle algorithm and you have FTP capability
on your machine, you might want to anonymous FTP
albanycs.albany.edu (128.204.1.4).  In the /pub/graphics directory
there is large collection of old comp.graphics articles and
code that were posted at one time or another here.  There's alot
to look at for old postings.


Jeff Bakke
NU113738@NDSUVM1.BITNET

myers@hpldola.HP.COM (Dan Myers) (08/05/89)

Jeffrey T LeBlanc writes:

>     Does anyone out there have an algorithm handy that, when given the
>coordinates of three XY points can return the circle that would fall on
>them?  Any help along those lines would be appreciated.


This is pretty off-the-cuff, but is based on the fact that the distance
from any point on the perpendicular bisector of a line segment is
equidistant from the original segments endpoints:

	Given:  3 points A, B, and C (in XY coords)
	Algorithm:
	        If any of A,B,or C are duplicates, return the circle
		centered on the midpoint of the segment joining the two 
		distinct endpoints with radius equal to 1/2 their distance.

		Determine the equations for the perpendicular 
		bisectors of any TWO pairs of points( say AB and BC ).
		Call them perpAB and perpBC.
		
		If slope(perpAB) equals slope( perpBC ), return an
		"infinite" circle (i.e., the line passing through all
		points since they are collinear)
		
		Find the intersection of perpAB and perpBC (guaranteed
		exist since we made it past the last step...).  Call it
		centerpoint.
		
		Return the circle with center centerpoint and radius
		equal to the distance from centerpoint to ANY of the 
		given points (e.g. distance(centerpoint, A) ).
		
		Details are left as an exercise to the reader :^)
		
		
	Hope this helps...
	
	
	Dan Myers
	hplabs.hp.com!hpldola!myers
	
	

daveb@pogo.WV.TEK.COM (Dave Butler) (08/15/89)

Just saw the discussion about circles:

Dan Myers writes:

> Jeffrey T LeBlanc writes:
>
>>     Does anyone out there have an algorithm handy that, when given the
>>coordinates of three XY points can return the circle that would fall on
>>them?  Any help along those lines would be appreciated.

Any two points on a circle form a cord of that circle.  A line that is
perpendicular to a cord and bisects that cord also bisects the circle (and
therefore passes through the center of the circle).  Two unique cords, will
have two unique perpendicular bisection lines, both of which pass through the
center of the circle.  Therefore calculate the formula for these lines and
then calculate their intersection point, because that's where the center of
the circle is located. 

				Later,

				Dave Butler

    Why does this magnificent applied science, which saves work and makes 
    life easier, bring us so little happiness? The simple answer runs:
    Because we have not yet learned to make sensible use of it.
				Albert Einstein