Exploring Analyic Geometry with Mathematica®

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

D2DLoci2D

The package D2DLoci2D provides functions for constructing loci (points, lines and conics) from equations.

Initialization

BeginPackage["D2DLoci2D`",{"D2DCircle2D`", "D2DEllipse2D`", "D2DExpressions2D`", "D2DGeometry2D`", "D2DHyperbola2D`", "D2DLine2D`", "D2DParabola2D`", "D2DPoint2D`", "D2DQuadratic2D`", "D2DTransform2D`"}];

D2DLoci2D::usage=
   "D2DLoci2D is a package that provides functions constructing loci (points, lines and conics) from equations.";

Loci2D::usage=
   "Loci2D[quad] constructs a list of loci (point, lines or conics) represented by a quadratic; Loci2D[point, line, eccentricity] constructs a list of loci (point, lines or conics) given the focus point, directrix line and eccentricity.";

Begin["`Private`"];

Utilities

Not Zero Query

The private function NotZero$2D returns the logical negation of IsZero2D.

NotZero$2D[r_] := Not[IsZero2D[r]];

Conic Construction

Conic from Quadratic

Format: Loci2D[quad]
Constructs a list of conics (proper or degenerate) represented by a quadratic.

Loci2D::central=
   "The quadratic is a central conic, but its type cannot be determined.";

Loci2D::noLocus=
   "The quadratic has no real locus.";

Linear Polynomial, D x+E y+F=0: Constructs a list containing one line represented by a quadratic whose second-degree coefficients are all zero.

Loci2D[Quadratic2D[a_?IsZero2D,b_?IsZero2D,c_?IsZero2D,d_,e_,f_]] :=
   {Line2D[d,e,f]} /;
(NotZero$2D[d] || NotZero$2D[e]);

Parallel Lines, "D2DLoci2D_1.gif":  Constructs a list of two vertical parallel lines.

Loci2D[Quadratic2D[a_?NotZero$2D,b_?IsZero2D,c_?IsZero2D,
                   d_,e_?IsZero2D,f_]] :=
   Module[{disc=d^2-4*a*f},
      disc=If[IsZero2D[disc],0,Simplify[disc]];
      If[IsNegative2D[disc],
         Message[Loci2D::noLocus];{},
         Map[Line2D[2*a,0,d+#*Sqrt[disc]]&,{-1,1}]] ];

Parallel Lines, "D2DLoci2D_2.gif":  Constructs a list of two horizontal parallel lines.

Loci2D[Quadratic2D[a_?IsZero2D,b_?IsZero2D,c_?NotZero$2D,
                   d_?IsZero2D,e_,f_]] :=
   Module[{disc=e^2-4*c*f},
      disc=If[IsZero2D[disc],0,Simplify[disc]];
      If[IsNegative2D[disc],
         Message[Loci2D::noLocus];{},
         Map[Line2D[0,2*c,e+#*Sqrt[disc]]&,{-1,1}]] ];

Intersecting Lines, "D2DLoci2D_3.gif":  Constructs a list of two intersecting lines or a list containing a single point.

Loci2D[Quadratic2D[a_?NotZero$2D,b_?IsZero2D,c_?NotZero$2D,
                   d_?IsZero2D,e_?IsZero2D,f_?IsZero2D]] :=
   Which[
      IsNegative2D[-a*c],
         {Point2D[{0,0}]},
      IsNegative2D[a] && IsNegative2D[-c],
         Map[Line2D[Sqrt[-a],#*Sqrt[c],0]&,{-1,1}],
      True, (* IsNegative2D[-a] && IsNegative2D[c] *)
         Map[Line2D[Sqrt[a],#*Sqrt[-c],0]&,{-1,1}]];

Circle, "D2DLoci2D_4.gif":  Constructs a list of one circle.

Loci2D[Quadratic2D[a_?NotZero$2D,b_?IsZero2D,c_?NotZero$2D,
                   d_?IsZero2D,e_?IsZero2D,f_?NotZero$2D]] :=
   If[IsNegative2D[-f/a],
      Message[Loci2D::noLocus];{},
      {Circle2D[{0,0},Sqrt[-f/a]]} ] /;
IsZero2D[a-c];

Parabola, "D2DLoci2D_5.gif":  Constructs a list of one parabola in standard position or rotated π radians.

Loci2D[Quadratic2D[a_?IsZero2D,b_?IsZero2D,c_?NotZero$2D,
                   d_?NotZero$2D,e_,f_]] :=
   Module[{h,k,p},
      h=(e^2-4*c*f)/(4*c*d);
      k=-e/(2*c);
      p=-d/(4*c);
      If[IsNegative2D[p],
         {Parabola2D[{h,k},-p,Pi]},
         {Parabola2D[{h,k}, p, 0]}] ];

Parabola, "D2DLoci2D_6.gif":  Constructs a list of one parabola rotated π/2 or 3π/2 radians.

Loci2D[Quadratic2D[a_?NotZero$2D,b_?IsZero2D,c_?IsZero2D,
                   d_,e_?NotZero$2D,f_]] :=
   Module[{h,k,p},
      h=-d/(2*a);
      k=(d^2-4*a*f)/(4*a*e);
      p=-e/(4*a);
      If[IsNegative2D[p],
         {Parabola2D[{h,k},-p,3Pi/2]},
         {Parabola2D[{h,k}, p, Pi/2]}] ];

Central Conic, "D2DLoci2D_7.gif":  Constructs a list of one central conic (ellipse or hyperbola).

Loci2D[Quadratic2D[a_?NotZero$2D,b_?IsZero2D,c_?NotZero$2D,
                   d_?IsZero2D,e_?IsZero2D,f_?NotZero$2D]] :=
   Which[
      IsNegative2D[-f/a] && IsNegative2D[-f/c],
         Message[Loci2D::noLocus];{},
      IsNegative2D[-f/a] && IsNegative2D[f/c],
         {Hyperbola2D[{0,0},Sqrt[-f/c],Sqrt[f/a],Pi/2]},
      IsNegative2D[f/a] && IsNegative2D[-f/c],
         {Hyperbola2D[{0,0},Sqrt[-f/a],Sqrt[f/c],0]},
      IsNegative2D[f/a] && IsNegative2D[f/c],
         If[IsNegative2D[(-f/a)-(-f/c)],
            {Ellipse2D[{0,0},Sqrt[-f/c],Sqrt[-f/a],Pi/2]},
            {Ellipse2D[{0,0},Sqrt[-f/a],Sqrt[-f/c],0]}],
      True,
         Message[Loci2D::central];{} ] /;
NotZero$2D[a-c];

Remove First-Degree Terms, "D2DLoci2D_8.gif":  Removes the x- and y- terms from a quadratic by applying a change of veriable to the equation.  The Translate2D function performs the inverse translation, thus returning the geometry to its original position.

Loci2D[Quadratic2D[a_?NotZero$2D,b_?IsZero2D,c_?NotZero$2D,d_,e_,f_]] :=
  Translate2D[Loci2D[Quadratic2D[4*a^2*c,0,4*a*c^2,
                                 0,0,-c*d^2-a*e^2+4*a*c*f]],
              {-d/(2*a),-e/(2*c)}] /;
(NotZero$2D[d] || NotZero$2D[e]);

Eliminate Cross-Term, "D2DLoci2D_9.gif":  Eliminates the cross-term of a quadratic by making the substitution x→k x+y and y→k y-x which is a scaling and rotation.  The subsequent scaling and rotation accomplishes the inverse transformation, thus returning the geometry to its original position.  If k is sufficiently close to zero then the substitution is not needed.

Loci2D[Quadratic2D[a_,b_?NotZero$2D,c_,d_,e_,f_]] :=
   Module[{k=Sqrt[((c-a)/b)^2+1]+(c-a)/b,Q1},
      If[IsZero2D[k],
         Loci2D[Quadratic2D[a,0,c,d,e,f]],
         Q1=Quadratic2D[a*k^2-b*k+c,0,c*k^2+b*k+a,d*k-e,e*k+d,f];
         Rotate2D[Scale2D[Loci2D[Q1],Sqrt[1+k^2]],
                  -ArcTan[1/k]]] ];

Conic from Focus, Directrix and Eccentricity

Format: Loci2D[point,line,e]
Constructs a list of conics (proper or degenerate) from a focus point, directrix line and eccentricity.

Loci2D::eccentricity=
   "The eccentricity, `1`, is invalid; the eccentricity must be positive.";

Loci2D[P1:Point2D[{x1_,y1_}],L2:Line2D[a2_,b2_,c2_],e_?IsScalar2D] :=
   If[IsZeroOrNegative2D[e],
      Message[Loci2D::eccentricity,e];$Failed,
      Loci2D[Quadratic2D[P1,L2,e]] ];

Conic Vertex Equation

Format: Loci2D[point,fcLen,e,θ]
Constructs a conic (circle, ellipse, hyperbola or parabola) from the vertex point, focal chord length, eccentricity and rotation angle.  If the rotation angle is omitted, it defaults to zero.

Loci2D[P1:Point2D[{x1_,y1_}],fcLen_?IsScalar2D,e_?IsScalar2D] :=
   Loci2D[P1,fcLen,e,0];

Loci2D[P1:Point2D[{x1_,y1_}],fcLen_?IsScalar2D,e_?IsScalar2D,
       theta_?IsScalar2D] :=
   Module[{Q},
      Q=Quadratic2D[P1,fcLen,e,theta];
      If[Q===$Failed,Q,Loci2D[Q]] ];

Epilogue

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


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