Exploring Analyic Geometry with Mathematica®

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

D2DCircle2D

The package D2DCircle2D implements the Circle2D object.

Initialization

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

D2DCircle2D::usage=
   "D2DCircle2D is a package that implements the Circle2D object.";

Circle2D::usage=
   "Circle2D[{h,k},r] is the standard form of a circle with radius 'r' centered at {h,k}.";

Radius2D::usage=
   "Radius2D[circle] gives the radius of a circle.";

Begin["`Private`"];

Description

Representation

Format: Circle2D[{h,k},r]
Standard representation of a circle in Descarta2D.  The center of the circle is (h,k) and the radius is r.

Equation

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

Quadratic2D[Circle2D[{h_,k_},r_]] :=
   Quadratic2D[1,0,1,-2*h,-2*k,h^2+k^2-r^2];

Evaluation

Format: Circle2D[{h,k},r][θ]
Evaluates a parameter, θ, on a circle and returns a coordinate list {x,y}.  Parameters in the range 0≤θ<2π cover a complete circle.

Circle2D[{h_,k_},r_][t_?IsScalar2D] := {h+r*Cos[t],k+r*Sin[t]};

Graphics

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

SetDisplay2D[
   Circle2D[{h_,k_},r_][{t1_?IsScalar2D,t2_?IsScalar2D}],
   Circle[{h,k},r,PrimaryAngleRange2D[{t1,t2}]] ];

SetDisplay2D[
   Circle2D[{h_,k_},r_],
   Circle[{h,k},r] ];

Validation

Format: Circle2D[{h,k},r]
Detects a circle with imaginary arguments and returns the $Failed symbol.  If the imaginary parts are insignificant, they are removed.

Circle2D::imaginary=
   "An invalid circle of the form 'Circle2D[`1`,`2`]' has been detected; the arguments cannot be imaginary.";

Circle2D[{h_,k_},r_] :=
   (Circle2D @@ ChopImaginary2D[Circle$2D[{h,k},r]]) /;
(FreeQ[{h,k,r},_Pattern] && IsTinyImaginary2D[{h,k,r}]);

Circle2D[{h_,k_},r_] :=
   (Message[Circle2D::imaginary,{h,k},r];$Failed) /;
(FreeQ[{h,k,r},_Pattern] && IsComplex2D[{h,k,r},0]);

Format: Circle2D[{h,k},r]
Detects a circle whose radius is non-positive and returns the $Failed symbol.

Circle2D::invalid=
   "An invalid circle of the form 'Circle2D[`1`, `2`]' has been detected; the radius must be positive.";

Circle2D[{h_,k_},r_] :=
   (Message[Circle2D::invalid,{h,k},r];$Failed) /;
(FreeQ[{h,k,r},_Pattern] && IsZeroOrNegative2D[r,0]);

Format: IsValid2D[circle]
Verifies that a circle is syntactically valid.

IsValid2D[Circle2D[{h_?IsScalar2D,k_?IsScalar2D},r_?IsScalar2D]] := True;

Scalars

Distance Point/Circle

Format: Distance2D[point,circle]
Computes the distance between a point and a circle.

Distance2D[Point2D[{x_,y_}],Circle2D[{h_,k_},r_]] :=
   Sqrt[(Distance2D[{x,y},{h,k}]-r)^2];

Radius

Format: Radius2D[circle]
Returns the radius of a circle.

Radius2D[Circle2D[{h_,k_},r_]] := r;

Transformations

Reflect

Format: Reflect2D[circle,line]
Reflects a circle in a line.

Reflect2D[Circle2D[{h_,k_},r_],L:Line2D[a_,b_,c_]] :=
   Circle2D[Reflect2D[{h,k},L],r];

Rotate

Format: Rotate2D[circle,θ,coords]
Rotates a circle 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).

Rotate2D[Circle2D[{h_,k_},r_],theta_?IsScalar2D,
         {x0_?IsScalar2D,y0_?IsScalar2D}] :=
   Circle2D[Rotate2D[{h,k},theta,{x0,y0}],r];

Scale

Format: Scale2D[circle,s,coords]
Scales a circle from a coordinate position.  If the position is omitted, it defaults to the origin (see D2DTransform2D.html).

Scale2D[Circle2D[{h_,k_},r_],s_?IsScalar2D,
        {x0_?IsScalar2D,y0_?IsScalar2D}] :=
   Circle2D[Scale2D[{h,k},s,{x0,y0}],s*r] /;
Not[IsZeroOrNegative2D[s]];

Translate

Format: Translate2D[circle,{u,v}]
Translates a circle delta distance.

Translate2D[Circle2D[{h_,k_},r_],
            {u_?IsScalar2D,v_?IsScalar2D}] :=
   Circle2D[{h+u,k+v},r];

Point Construction

Center Point

Format: Point2D[circle]
Constructs the center point of the circle.

Point2D[Circle2D[{h_,k_},r_]] := Point2D[{h,k}];

Pole Point

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

Point2D[L1:Line2D[a1_,b1_,c1_],C2:Circle2D[{h2_,k2_},r2_]] :=
   Point2D[L1,Quadratic2D[C2]];

Line Construction

Polar Line

Format: Line2D[point,circle]
Constructs a line that is the polar line of a point with respect to a circle.  If the point is on the circle then the line is tangent to the circle.

Line2D[P1:Point2D[{x1_,y1_}],C2:Circle2D[{h2_,k2_},r2_]] :=
   Line2D[P1,Quadratic2D[C2]];

Radical Axis

Format: Line2D[circle,circle]
Constructs a line that is the radical axis of two circles.

Line2D::concentric=
   "The circles {`1`, `2`} are concentric; no radical axis exists.";

Line2D[C1:Circle2D[{h1_,k1_},r1_],C2:Circle2D[{h2_,k2_},r2_]] :=
   If[IsConcentric2D[C1,C2],
      Message[Line2D::concentric,C1,C2];$Failed,
      Line2D[2*(h2-h1),2*(k2-k1),(h1^2-h2^2)+(k1^2-k2^2)+(r2^2-r1^2)]];

Circle Construction

Circle from Quadratic Equation

Format: Circle2D[quad]
Constructs a circle from a quadratic.  The quadratic must be recognizable as a circle.

Circle2D::noCircle=
   "The curve represented by `1` is not a circle.";

Circle2D[Q:Quadratic2D[a_,b_,c_,d_,e_,f_]] :=
   Module[{s},
      If[IsZero2D[{a-c,b},And] && Not[IsZero2D[{a,c},Or]],
         s=(d^2+e^2-4*a*f)/a^2;
         If[IsZeroOrNegative2D[s],
            Message[Circle2D::noCircle,Q];$Failed,
            Circle2D[{-d/(2a),-e/(2a)},Sqrt[s]/2]],
         Message[Circle2D::noCircle,Q];$Failed] ];

Circle from Center Point and Radius

Format: Circle2D[point,r]
Constructs a circle from a center point and radius.

Circle2D::radius=
   "The radius argument, `1`, is invalid; the radius must be positive.";

Circle2D[Point2D[{h_,k_}],r_?IsScalar2D] :=
   If[IsZeroOrNegative2D[r],
      Message[Circle2D::radius,r];$Failed,
      Circle2D[{h,k},r]];

Circle from Center Point and Point on Circle

Format: Circle2D[point,point]
Constructs a circle from a center point and a point on the circle.

Circle2D::coincident=
   "The points {`1`, `2`} are coincident; no valid circle exists.";

Circle2D[P1:Point2D[{x1_,y1_}],P2:Point2D[{x2_,y2_}]] :=
   If[IsCoincident2D[P1,P2],
      Message[Circle2D::coincident,P1,P2];$Failed,
      Circle2D[{x1,y1},Sqrt[(x1-x2)^2+(y1-y2)^2]]];

Circle from Center and Tangent Line

Format: Circle2D[point,line]
Constructs a circle from a center point and a tangent line.

Circle2D::on=
   "`1` is on `2`; no valid circle exists.";

Circle2D[P1:Point2D[{x1_,y1_}],L2:Line2D[A2_,B2_,C2_]] :=
   If[IsOn2D[P1,L2],
      Message[Circle2D::on,P1,L2];$Failed,
      Circle2D[{x1,y1},Sqrt[(A2*x1+B2*y1+C2)^2/(A2^2+B2^2)]]];

Circle Through Three Points

Format: Circle2D[point,point,point]
Constructs a circle through three points.

Circle2D::collinear=
   "The points {`1`, `2`, `3`} are collinear; no valid circle exists.";

Circle2D[P1:Point2D[{x1_,y1_}],P2:Point2D[{x2_,y2_}],
         P3:Point2D[{x3_,y3_}]] :=
   If[IsCollinear2D[P1,P2,P3],
      Message[Circle2D::collinear,P1,P2,P3];$Failed,
      Circle2D[Quadratic2D[P1,P2,P3]] ];

Epilogue

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


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