Edit 8 Feb 2012: The functions described below have been superseded by new versions which are described at https://newtonexcelbach.wordpress.com/2009/08/18/finding-circle-centres-in-3d/. That link also gives a description (with diagrams!) of how the functions work. The download file for the new versions is at IP2.zip.
In response to this thread at the Eng-Tips forum I have added two new functions to my IP.xls spreadsheet:
- ArcCenT2IP finds the centre and radius of an arc specified by 2 tangent points and the intersection point of the tangents.
- ArcCenP3 finds the centre and radius of an arc specified by any 3 points on the arc.
Full open source code for the two functions is included in the spreadsheet, which can be downloaded here:IP.zip
The procedure used is similar for both functions; for ArcCenP3:
- Read the 3D coordinates for three points on the circle
- Translate Point 2 and Point 3 for an origin at Point 1
- Find polar coordinates of Point 3
- Rotate Points 2 and 3 about the Z axis so that Point 3 is on the XZ plane
- Rotate Points 2 and 3 about the Y axis so that Point 3 is on the X axis
- Find angle of Point 2 from XY plane
- Rotate Points 2 about the X axis so that Point 2 is on the XY plane
- Find the XY coordinates of the mid-points of lines 1-2 and 3-2.
- Find a second point on the perpendiculars through mid-points
- Find the XY coordinates of the intersection of the perpendiculars. This is the centre of the circle.
- Find the radius of the circle
- Rotate and translate the centre point back to the original axes
- Assign the 3D coordinates of the circle centre, and the circle radius, to the function return value as a 1×4 array
ArcCenT2IP is very similar, except:
- The first step is to check that the two “tangent” points are equidistant from the intersection point. If not, adjust the coordinates of the further point to be an equal distance from the intersection point as the closer tangent point.
- Find the slope, and then the intersection point, of the perpendiculars through the two tangents. This is the centre of the circle.
- If either of the tangent points has been adjusted, return the adjusted coordinates, and the point number, as a second row of the 2×4 array function return value.
A screen shot of input and output for the two functions is shown below: