|
Three points on a plane define a unique circle. Here's the logic and
some code to determine the locations and size of the circle.
I won't include all of the details for the methods - excellent web page
references and sample Delphi code with all the details are included
below. But here's an outline.
First - to determine the center point:
- Given points P1, P2, and P3, determine the center point of the
circumscribed circle (the smallest circle that encloses the 3 points).
Lets assume that the points are connected, we'll call the lines P1-P2,
P2-P3 and P3-P1.
- Construct the perpendicular bisectors of lines P1-P2 and
P2-P3. If either of these lines is vertical (infinite slope),
just renumber the points so that the vertical line is
excluded.
- The lines intersect at the desired point. The geometrical solution
ends here. For the algebraic solution we need to solve the equations of the
bisectors to find the center point. From there the radius can be
determined using the Pythagorean theorem to calculate the distance from the
center to any of the other points.
- Here's a reference page http://forum.swarthmore.edu/dr.math/problems/culpepper9.9.97.html
- You can click below to download a sample Delphi Circle3Point
project which uses the GetCenter function.
Alternatively, if just the radius is required:
- If a, b and c are the lengths of the sides and K
is the area of the given triangle then the radius oft he circumscribed
circled is given by :
This
surprising equation is derived
here
. The derivation is not difficult, but it is not
intuitively obvious that the radius of a circle
circumscribed around a triangle should be equal to the product
of the side lengths divided by 4 times the area.
It does work though, as illustrated in
function GetRadius in the sample code.
The sample program measures the execution times for the 2 functions - GetRadius
is about twice as fast as GetCenter. (60 microseconds vs. 140 on my
new 800mhz Celeron). QueryPerformanceCounter and
QueryPerformanceFrequency functions are used to get accurate timings. To use
the program, just click 3 points on the image area and see the enclosing
circle.
Addendum Sept. 3, 2003: A viewer noticed that the Y coordinate
in this program increased in the downward direction. This is inherent in
computer graphics devices and normal for programmers, but not for the rest of
the population. I fixed the program today to put the (0,0)
coordinate in the bottom left corner where it belongs.
Running/Exploring the Program
| Created Sept 28, 2001 |
Modified
July 21, 2006
|
|