       Re: Equation for Circle in 3-D surrounding Equilateral Triangle

• To: mathgroup at smc.vnet.net
• Subject: [mg2356] Re: [mg2321] Equation for Circle in 3-D surrounding Equilateral Triangle
• From: Preston Nichols <nichols at godel.math.cmu.edu>
• Date: Fri, 27 Oct 1995 01:49:42 -0400

```John Duggan, duggan at ecs.umass.edu,Tue, 24 Oct 1995, wrote:

"The question is:

"Given three point at the intersection of the sides of an
Equilateral triangle in 3D what is and how does one code Mathematica
for the equation of the circle in 3D that contains all 3 points. I
felt that the intersection of a sphere and a plane would solve the
problem. But my mathematica coding appears to fall short for this."

-----------------------------------------------------------

I'm not sure exactly what you are trying to get as a result, but
the following might help.  The steps below work for any triangle in
3-space, not only equilateral ones.  (However, very thin triangles
might lead to numerical trouble.)
-----------------------------------------------------------

(* First, we gather some tools and set the initial data *)

Needs["LinearAlgebra`Orthogonalization`"];
Needs["LinearAlgebra`CrossProduct`"];

norm[v_] := Sqrt[v.v];

p1 = { -0.256, -0.256, 3.423 };
p2 = {-3.206, 0.474, -2.690 };
p3 = {-6.532, 2.766, 2.769 };

(* Now get some vectors parallel to the sides, *)

s1 := p2 - p1;
s2 := p3 - p2;
s3 := p1 - p3;

(* and find the midpoints of the sides. *)

m1 := p1 + s1/2;
m2 := p2 + s2/2;
m3 := p3 + s3/2;

(* Acutally, s3 and m3 will not be needed.  Note the use of := ,
which means that the si and mi will be automatically recomputed
(when called) if the values of the pi are changed (i = 1,2,3). *)

(* A useful fact from Euclid:  in any triangle, the perpendicular
bisectors (in the plane of the triangle) of the three sides all meet
at a single point, and this point is equidistant from the three
vertices.  This point is called the circumcenter of the triangle,
and it is the center of the circle we are seeking.

If the triangle is `floating' in three dimensions, the
perpendicular bisecting lines in the plane of the triangle are not
as easy to get hold of as the orthogonal planes which bisect the
sides.  These three planes will intersect each other in a single
line, orthogonal to the plane of the triangle, through the
circumcenter.  The equations of these planes are

({x,y,z} -m1).s1 == 0; ({x,y,z} -m2).s2 == 0; ({x,y,z} -m3).s3 == 0;

because we can use s1, s2, and s3 as the normal vectors to the
planes.  To find the circumcenter we need to find the intersection
of any two of these planes with the plane of the triangle, whose
normal vector is: *)

trianglenormal := Cross[s1,s2];

(* If we let

triangleplane := ({x,y,z} - p1). trianglenormal == 0;
midplane1 := ({x,y,z} -m1).s1 == 0;
midplane2 := ({x,y,z} -m2).s2 == 0;

we could use

Solve[{triangleplane, midplane1, midplane2}, {x,y,z}]

but it is more graceful and more efficient to use the following,
which combines the equations for the three planes into a single
system of linear equations: *)

circumcenter := LinearSolve[{s1,s2, trianglenormal},
{m1.s1,m2.s2,p1. trianglenormal}];

(*  So now we have the center of the desired circumscribed circle,
and here's the radius: *)

(* One of the best ways to represent curves such as a circle in
3-space is by a parametric equation.    This will be easy if we can
get a pair of orthonormal vectors parallel to the plane of the
triangle.  Fortunately, there's a neat trick in the
LinearAlgebra`Orthogonalization` package: *)

{v1,v2} = GramSchmidt[{s1,s2}];

(* The GramSchmidt process returns an orthonormal set of vectors
with the same span as the vectors you give it.  Thus {v1,v2} are a
basis for the plane through the origin which is parallel to the
plane of the triangle.  Now we can parametrically plot the circle.
*)

Off[ParametricPlot3D::ppcom];

thecircle = ParametricPlot3D[
radius Cos[t] v1 + radius Sin[t] v2 + circumcenter,
{t,0,2 Pi}];

(* To see why this works, think about what happens when v1 =
{1,0,0}, v2 = {0,1,0}, circumcenter = {0,0,0}, and radius =
anything. *)

(* Finally, to check the result: *)

thetriangle = Graphics3D[Polygon[{p1,p2,p3}]];
Show[{thetriangle, thecircle}];

-----------------------------------------------------------
Preston Nichols
Department of Mathematics
Carnegie Mellon University

```

• Prev by Date: Re: There must be a better way!
• Next by Date: RE:There must be a better way!
• Previous by thread: Re: Numerical Solutions to Schrod Eq with Mathematica
• Next by thread: Erase postscript cells