Exploring Analyic Geometry with Mathematica®

Home Contents Commands Packages Explorations Reference
Tour Lines Circles Conics Analysis Tangents

D2DMedial2D

The package D2DMedial2D constructs curves that are equidistant from two points, lines or circles.

Initialization

BeginPackage["D2DMedial2D`",{"D2DCircle2D`", "D2DExpressions2D`", "D2DGeometry2D`", "D2DMaster2D`", "D2DLine2D`", "D2DLoci2D`", "D2DPoint2D`", "D2DQuadratic2D`"}];

D2DMedial2D::usage=
   "D2DMedial2D is a package that constructs medial equations and loci.";

MedialEquations2D::usage=
   "MedialEquations2D[{obj,obj}] constructs a list of lines or quadratics equidistant from two objects (points, lines or circles).";

MedialLoci2D::usage=
   "MedialLoci2D[{obj,obj}] constructs a list of curves equidistant from two objects (points, lines or circles).";

Begin["`Private`"];

MedialEquations2D::coincident=
   "The objects {`1`, `2`} are coincident; no finite number of medial equations exist.";

Medial Equations

Medial Linear or Quadratic

Format: MedialEquations2D[{"D2DMedial2D_1.gif","D2DMedial2D_2.gif"}]
Constructs a list of lines or quadratics equidistant from two objects (points, lines or circles).

MedialEquations2D[{obj1_,obj2_}] :=
   If[TrueQ[IsCoincident2D[obj1,obj2]],
      Message[MedialEquations2D::coincident,obj1,obj2];{},
      Medial$2D[Reverse[Sort[{obj1,obj2}]]]] /;
Is2D[obj1,{Point2D,Line2D,Circle2D}] &&
Is2D[obj2,{Point2D,Line2D,Circle2D}];

Medial Loci

Medial Loci

Format: MedialLoci2D[{"D2DMedial2D_3.gif","D2DMedial2D_4.gif"}]
Constructs a list of curves equidistant from two objects (points, lines or circles).  

MedialLoci2D[{obj1_,obj2_}] :=
   Union[
      Flatten[
         Map[If[Head[#]===Line2D,#,Loci2D[#]]&,
             MedialEquations2D[{obj1,obj2}]]]] /;
Is2D[obj1,{Point2D,Line2D,Circle2D}] &&
Is2D[obj2,{Point2D,Line2D,Circle2D}];

Point--Point

The private function Medial$2D constructs a list of one line equidistant from two points.

Medial$2D[{Point2D[{x1_,y1_}],Point2D[{x2_,y2_}]}] :=
   {Line2D[2*(x2-x1),2*(y2-y1),(x1^2+y1^2)-(x2^2+y2^2)]};

Point--Line

The private function Medial$2D constructs a list of one quadratic representing the curve equidistant from a point and a line.

Medial$2D[{Point2D[{x1_,y1_}],Line2D[a2_,b2_,c2_]}] :=
   Module[{a,b,c,d,e,f,p,q,r},
      {p,q,r}={a2,b2,c2}/Sqrt[a2^2+b2^2];
      a=q^2;
      b=-2*p*q;
      c=p^2;
      d=-2*(x1+p*r);
      e=-2*(y1+q*r);
      f=x1^2+y1^2-r^2;
      {Quadratic2D[a,b,c,d,e,f]} ];

Point--Circle

The private function Medial$2D constructs a list of one quadratic representing the curve equidistant from a point and a circle.

Medial$2D[{Point2D[{x1_,y1_}],Circle2D[{h2_,k2_},r2_]}] :=
   Module[{R,a,b,c,d,e,f},
      R=(h2^2+k2^2)-(x1^2+y1^2)-r2^2;
      a=4((x1-h2)^2-r2^2);
      b=8*(x1-h2)*(y1-k2);
      c=4((y1-k2)^2-r2^2);
      d=4*(R*(x1-h2)+2*r2^2*x1);
      e=4*(R*(y1-k2)+2*r2^2*y1);
      f=R^2-4*r2^2*(x1^2+y1^2);
      {Quadratic2D[a,b,c,d,e,f]} ];

Line--Line

The private function Medial$2D constructs a list of two lines equidistant from two lines (the angle bisectors).  If the lines are parallel, only one line is returned in the list.

Medial$2D[{L1:Line2D[a1_,b1_,c1_],L2:Line2D[a2_,b2_,c2_]}] :=
   Module[{a,b,c,f1,f2,s},
      f1=Sqrt[a1^2+b1^2];
      f2=Sqrt[a2^2+b2^2];
      a=a1*f2+s*a2*f1;
      b=b1*f2+s*b2*f1;
      c=c1*f2+s*c2*f1;
      If[IsParallel2D[L1,L2],
         If[IsZero2D[Sqrt[a^2+b^2] /. s->1],
            {Line2D[a,b,c]} /. s->-1,
            {Line2D[a,b,c]} /. s->1],
         Map[(Line2D[a,b,c] /. s->#)&,{-1,1}]] ];

Line--Circle

The private function Medial$2D constructs a list of two quadratics representing curves equidistant from a line and a circle.

Medial$2D[{Line2D[a1_,b1_,c1_],Circle2D[{h2_,k2_},r2_]}] :=
   Module[{a,b,c,d,e,f,p,q,r,s},
      {p,q,r}={a1,b1,c1}/Sqrt[a1^2+b1^2];
      a=q^2;
      b=-2*p*q;
      c=p^2;
      d=-2*(h2+p*(r+s*r2));
      e=-2*(k2+q*(r+s*r2));
      f=(h2^2+k2^2)-r2^2-r*(r+2*s*r2);
      Map[(Quadratic2D[a,b,c,d,e,f] /. s->#)&, {-1,1}] ];

Circle--Circle

The private function Medial$2D constructs a list of two quadratics representing the curves equidistant from two circles.

Medial$2D[{Circle2D[{h1_,k1_},r1_],Circle2D[{h2_,k2_},r2_]}] :=
   Module[{s,R,D1,D2,a,b,c,d,e,f},
      R=(r1-s*r2)^2;
      D1=h1^2+k1^2;
      D2=h2^2+k2^2;
      a=4*((h1-h2)^2-R);
      b=8*(h1-h2)*(k1-k2);
      c=4*((k1-k2)^2-R);
      d=4*(h1*(-D1+D2+R)+h2*(D1-D2+R));
      e=4*(k1*(-D1+D2+R)+k2*(D1-D2+R));
      f=(D1-D2)^2-2*(D1+D2)*R+R^2;
      Map[(Quadratic2D[a,b,c,d,e,f] /. s->#)&, {-1,1}] ];

Epilogue

End[ ]; (* end of "`Private" *)
EndPackage[ ]; (* end of "D2DMedial2D`" *)


Copyright © 1999-2007 Donald L. Vossler, Descarta2D Publishing
www.Descarta2D.com