Exploring Analyic Geometry with Mathematica®

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


The package D2DEllipse2D implements the Ellipse2D object.


BeginPackage["D2DEllipse2D`",{"D2DExpressions2D`", "D2DGeometry2D`", "D2DLine2D`", "D2DMaster2D`", "D2DNumbers2D`", "D2DPoint2D`", "D2DQuadratic2D`", "D2DSegment2D`", "D2DSketch2D`", "D2DTransform2D`"}];

   "D2DEllipse2D is a package that implements the Ellipse2D object.";

   "Ellipse2D[{h,k},a,b,theta] is the standard form of an ellipse centered at (h,k), semi-major axis length 'a', semi-minor axis length 'b' and rotation angle 'theta'.";

   "SemiMajorAxis2D[ellipse] returns the length of the semi-major axis of an ellipse.";

   "SemiMinorAxis2D[ellipse] returns the length of the semi-minor axis of an ellipse.";




Format: Ellipse2D[{h,k},a,b,θ]
Standard representation of an ellipse in Descarta2D.  The first argument is a list of coordinates representing the center of the ellipse.  The second and third arguments are (positive) scalars representing the lengths of the semi-major and semi-minor axes of the ellipse.  The fourth argument is the CCW rotation angle (in radians) of the ellipse about the center point.


Format: Quadratic2D[ellipse]
Constructs a quadratic representing the equation of an ellipse.

Quadratic2D[Ellipse2D[{h_,k_},a_,b_,theta_]] :=


Format: Ellipse2D[{h,k},a,b,θ]["D2DEllipse2D_1.gif"]
Evaluates a position on an ellipse at parameter "D2DEllipse2D_2.gif" and returns a list of coordinates {x,y}.  Parameters in the range "D2DEllipse2D_3.gif" cover the entire ellipse.

Ellipse2D[{h_,k_},a_,b_,theta_][t_?IsScalar2D] :=


Provides the graphics primitives for an ellipse by extending the Mathematica Display command. Executed when the package is loaded.

                    PrimaryAngleRange2D[{t1,t2}]] ];

   MakePrimitives2D[Ellipse2D[{h,k},a,b,t],{0,2Pi}] ];


Format: Ellipse2D[{h,k},a,b,θ]
Detects an ellipse with imaginary arguments and returns the $Failed symbol.  If the imaginary parts are insignificant, they are removed.

   "An invalid ellipse of the form 'Ellipse2D[`1`, `2`, `3`, `4`]' has been detected; the arguments of an ellipse cannot involve imaginary numbers.";

Ellipse2D[{h_,k_},a_,b_,theta_] :=
   (Ellipse2D @@ ChopImaginary2D[Ellipse$2D[{h,k},a,b,theta]]) /;
(FreeQ[{h,k,a,b,theta},_Pattern] && IsTinyImaginary2D[{h,k,a,b,theta}]);

Ellipse2D[{h_,k_},a_,b_,theta_] :=
   (Message[Ellipse2D::imaginary,{h,k},a,b,theta];$Failed) /;
(FreeQ[{h,k,a,b,theta},_Pattern] && IsComplex2D[{h,k,a,b,theta},0]);

Format: Ellipse2D[{h,k},a,b,θ]
Detects an ellipse with invalid arguments and returns the $Failed symbol.

   "An invalid ellipse of the form 'Ellipse2D[`1`, `2`, `3`, `4`]' has been detected; the length of both the semi-major and semi-minor axes must be positive.";

Ellipse2D[{h_,k_},a_,b_,theta_] :=
   (Message[Ellipse2D::invalid,{h,k},a,b,theta];$Failed) /;
(FreeQ[{h,k,a,b,theta},_Pattern] && IsZeroOrNegative2D[{a,b},0]);

Format: Ellipse2D[{h,k},a,b,θ]
Detects a y-axis ellipse and rotates it π/2 radians.

Ellipse2D[{h_,k_},a_,b_,theta_] :=
   Ellipse2D[{h,k},b,a,theta+Pi/2] /;
(FreeQ[{h,k,a,b,theta},_Pattern] && IsNegative2D[a-b,0]);

Format: Ellipse2D[{h,k},a,b,θ]
Adjusts the rotation angle on all ellipses to the range 0≤θ<π.

Ellipse2D[{h_,k_},a_,b_,theta_] :=
   Ellipse2D[{h,k},a,b,PrimaryAngle2D[theta,Pi]] /;
(FreeQ[{h,k,a,b,theta},_Pattern] && (theta=!=PrimaryAngle2D[theta,Pi]));

Format: IsValid2D[ellipse]
Verifies that an ellipse is syntactically valid.

                    theta_?IsScalar2D]] := True;


Angle of Rotation

Format: Angle2D[ellipse]
Returns the rotation angle of an ellipse.

Angle2D[Ellipse2D[{h_,k_},a_,b_,theta_]] := theta;

Semi-major Axis Length

Format:  SemiMajorAxis2D[ellipse]
Returns the length of the semi-major axis of an ellipse.

SemiMajorAxis2D[Ellipse2D[{h_,k_},a_,b_,theta_]] := a;

Semi-minor Axis Length

Format: SemiMinorAxis2D[ellipse]
Returns the length of the semi-major axis of an ellipse.

SemiMinorAxis2D[Ellipse2D[{h_,k_},a_,b_,theta_]] := b;



Format: Reflect2D[ellipse,line]
Reflects an ellipse in a line.

Reflect2D[Ellipse2D[{h_,k_},a_,b_,theta_],L:Line2D[p_,q_,r_]] :=


Format: Rotate2D[ellipse,θ,coords]
Rotates an ellipse by an angle θ about a position specified by a coordinate list.  If the third argument is omitted, it defaults to the origin (see D2DTransform2D.html).

         {x0_?IsScalar2D,y0_?IsScalar2D}] :=


Format: Scale2D[ellipse,s,coords]
Scales an ellipse by a scale factor, s, from a position given by coordinates.  If the third argument is omitted, it defaults to the origin (see D2DTransform2D.html).

        {x0_?IsScalar2D,y0_?IsScalar2D}] :=
   Ellipse2D[Scale2D[{h,k},s,{x0,y0}],s*a,s*b,theta] /;


Format: Translate2D[ellipse,{u,v}]
Translates an ellipse delta distance.

            {u_?IsScalar2D,v_?IsScalar2D}] :=

Point Construction

Center Point

Format: Point2D[ellipse]
Constructs the center point of an ellipse.

Point2D[Ellipse2D[{h_,k_},a_,b_,theta_]] := Point2D[{h,k}];

Pole Point

Format: Point2D[line,ellipse]
Constructs the pole point of a line with respect to an ellipse.  If the line is tangent to the ellipse then the point is the point of tangency.

Point2D[L1:Line2D[a1_,b1_,c1_],E2:Ellipse2D[{h2_,k2_},a2_,b2_,theta2_]] :=

Line Construction

Axis Line

Format: Line2D[ellipse]
Constructs a line containing the major axis of an ellipse.

Line2D[Ellipse2D[{h_,k_},a_,b_,theta_]] :=

Polar Line

Format: Line2D[point,ellipse]
Constructs the polar (line) of a pole (point) with respect to an ellipse.  If the point is on the ellipse then the line is tangent to the ellipse at the point.

Line2D[P1:Point2D[{x1_,y1_}],E2:Ellipse2D[{h2_,k2_},a2_,b2_,theta2_]] :=

Ellipse Construction

Ellipse from Vertices and Eccentricity

Format: Ellipse2D[{point,point},e]
Constructs an ellipse from the vertices and eccentricity.

   "The defining geometry or eccentricity is invalid; the eccentricity of an ellipse must be in the range 0<e<1, the foci and vertices cannot be coincident, and the focus cannot lie on the directrix.";

Ellipse2D[{P1:Point2D[{x1_,y1_}],P2:Point2D[{x2_,y2_}]},e_?IsScalar2D] :=
      If[IsZeroOrNegative2D[{e,1-e},Or] || IsCoincident2D[P1,P2],
         Ellipse2D[{h,k},a,b,ArcTan[x2-x1,y2-y1]]] ];

Ellipse from Foci and Eccentricity

Format: Ellipse2D[point,point,e]
Constructs an ellipse from the foci and eccentricity.

Ellipse2D[P1:Point2D[{x1_,y1_}],P2:Point2D[{x2_,y2_}],e_?IsScalar2D] :=
      If[IsZeroOrNegative2D[{e,1-e},Or] || IsCoincident2D[P1,P2],
         Ellipse2D[{h,k},a,b,ArcTan[x2-x1,y2-y1]]] ];

Ellipse from Focus, Directrix and Eccentricity

Format: Ellipse2D[point,line,e]
Constructs an ellipse from a focus point, directrix line and eccentricity.

Ellipse2D[P1:Point2D[{x1_,y1_}],L2:Line2D[p_,q_,r_],e_?IsScalar2D] :=
      If[IsZeroOrNegative2D[{e,1-e},Or] || IsOn2D[P1,L2],
         Ellipse2D[{h,k},a,b,ArcTan[p,q]]] ];


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

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