Exploring Analyic Geometry with Mathematica® |
|||||
| Home | Contents | Commands | Packages | Explorations | Reference |
| Tour | Lines | Circles | Conics | Analysis | Tangents |
D2DParabola2D
The package D2DParabola2D implements the Parabola2D object.
Initialization
BeginPackage["D2DParabola2D`",{"D2DExpressions2D`", "D2DGeometry2D`", "D2DLine2D`", "D2DMaster2D`", "D2DNumbers2D`", "D2DPoint2D`", "D2DQuadratic2D`", "D2DSegment2D`", "D2DSketch2D`", "D2DTransform2D`"}];
D2DParabola2D::usage=
"D2DParabola2D is a package that implements the Parabola2D object.";
FocalLength2D::usage=
"FocalLength2D[parabola] returns the focal length of a parabola.";
Parabola2D::usage=
"Parabola2D[{h,k},f,theta] is the standard form of a parabola that opens to the right (when theta=0); {x,y} is the vertex point of the parabola; 'f' is the distance from the vertex point to the focus; 'theta' is the counter-clockwise rotation (in radians) of the parabola about the vertex point.";
Begin["`Private`"];
Description
Representation
Format: Parabola2D[{h,k},f,θ]
Standard representation of a parabola in Descarta2D. The first argument is a list of coordinates representing the position of the vertex of the parabola. The second argument is a (positive) scalar representing the distance from the vertex to the focus (the focal length). The third argument is the counter-clockwise rotation (in radians) of the parabola about the vertex point.
Equation
Format: Quadratic2D[parabola]
Constructs the quadratic representing the equation of a parabola.
Quadratic2D[Parabola2D[{h_,k_},f_,theta_]] :=
Rotate2D[Quadratic2D[0,0,1,-4*f,-2*k,k^2+4*h*f],theta,{h,k}];
Evaluation
Format: Parabola2D[{h,k},f,θ][t]
Evaluates a parabola at a parameter t (-Infinity < t < +Infinity). The end points of the latus rectum are at t=-1 and t=1.
Parabola2D[{h_,k_},f_,theta_][t_?IsScalar2D] :=
Rotate2D[{h+f*t^2,k+2*f*t},theta,{h,k}];
Graphics
Provides graphics for a parabola by extending the Mathematica Display command. Executed when the package is loaded.
SetDisplay2D[
Parabola2D[{h_,k_},f_,t_][{t1_?IsScalar2D,t2_?IsScalar2D}],
MakePrimitives2D[Parabola2D[{h,k},f,t],{t1,t2}] ];
SetDisplay2D[
Parabola2D[{h_,k_},f_,t_],
MakePrimitives2D[Parabola2D[{h,k},f,t],
CurveLimits2D[{0,0},
Parabola2D[{0,0},f,0]]] ];
Validation
Format: Parabola2D[{h,k},f,θ]
Detects a parabola with imaginary arguments and returns the $Failed symbol. If the imaginary parts are insignificant, they are removed.
Parabola2D::imaginary=
"An invalid parabola of the form 'Parabola2D[`1`, `2`, `3`]' has been detected; the arguments cannot be imaginary.";
Parabola2D[{h_,k_},f_,theta_] :=
(Parabola2D @@ ChopImaginary2D[Parabola$2D[{h,k},f,theta]]) /;
(FreeQ[{h,k,f,theta},_Pattern] && IsTinyImaginary2D[{h,k,f,theta}]);
Parabola2D[{h_,k_},f_,theta_] :=
(Message[Parabola2D::imaginary,{h,k},f,theta];$Failed) /;
(FreeQ[{h,k,f,theta},_Pattern] && IsComplex2D[{h,k,f,theta},0]);
Format: Parabola2D[{h,k},f,θ]
Detects a parabola with an invalid focal length. If the focal length is negative, the parabola is rotated π radians to make it positive; if the focal length is zero, the $Failed symbol is returned.
Parabola2D::invalid=
"An invalid parabola of the form 'Parabola2D[`1`, `2`, `3`]' has been detected; the focal length cannot be zero.";
Parabola2D[{h_,k_},f_,theta_] :=
(Message[Parabola2D::invalid,{h,k},f,theta];$Failed) /;
(FreeQ[{h,k,f,theta},_Pattern] && IsZero2D[f,0]);
Parabola2D[{h_,k_},f_,theta_] :=
Parabola2D[{h,k},-f,theta+Pi] /;
(FreeQ[{h,k,f,theta},_Pattern] && IsNegative2D[f,0]);
Format: Parabola2D[{h,k},f,θ]
Adjusts the rotation angle on a parabola to the range 0≤θ≤2π.
Parabola2D[{h_,k_},f_,theta_] :=
Parabola2D[{h,k},f,PrimaryAngle2D[theta]] /;
(FreeQ[{h,k,f,theta},_Pattern] && (theta=!=PrimaryAngle2D[theta]));
Format: IsValid2D[parabola]
Verifies that a parabola is syntactically valid.
IsValid2D[Parabola2D[{h_?IsScalar2D,k_?IsScalar2D},
f_?IsScalar2D,
theta_?IsScalar2D]] := True;
Scalars
Angle of Rotation
Format: Angle2D[parabola]
Returns the rotation angle of a parabola.
Angle2D[Parabola2D[{h_,k_},f_,theta_]] := theta;
Focal Length
Format: FocalLength2D[parabola]
Returns the focal length of a parabola.
FocalLength2D[Parabola2D[{h_,k_},f_,theta_]] := f;
Transformations
Reflect
Format: Reflect2D[parabola,line]
Reflects a parabola in a line.
Reflect2D[Parabola2D[{h_,k_},f_,theta_],L2:Line2D[a2_,b2_,c2_]] :=
Parabola2D[Reflect2D[{h,k},L2],f,ReflectAngle2D[theta,L2]];
Rotate
Format: Rotate2D[parabola,θ,coords]
Rotates a parabola 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[Parabola2D[{h_,k_},f_,theta_],alpha_?IsScalar2D,
{x0_?IsScalar2D,y0_?IsScalar2D}] :=
Parabola2D[Rotate2D[{h,k},alpha,{x0,y0}],f,theta+alpha];
Scale
Format: Scale2D[parabola,s,coords]
Scales a parabola from a position given by coordinates. If the third argument is omitted, it defaults to the origin (see D2DTransform2D.html).
Scale2D[Parabola2D[{h_,k_},f_,theta_],s_?IsScalar2D,
{x0_?IsScalar2D,y0_?IsScalar2D}] :=
Parabola2D[Scale2D[{h,k},s,{x0,y0}],s*f,theta] /;
Not[IsZeroOrNegative2D[s]];
Translate
Format: Translate2D[parabola,{u,v}]
Translates a parabola delta distance.
Translate2D[Parabola2D[{h_,k_},f_,theta_],{u_?IsScalar2D,v_?IsScalar2D}] :=
Parabola2D[{h+u,k+v},f,theta];
Point Construction
Vertex Point
Format: Point2D[parabola]
Returns the vertex point of a parabola.
Point2D[Parabola2D[{h_,k_},f_,theta_]] := Point2D[{h,k}];
Pole Point
Format: Point2D[line,parabola]
Constructs the pole (point) of a polar (line) with respect to a parabola. If the line is tangent to the parabola then the point is the point of tangency.
Point2D[L1:Line2D[a1_,b1_,c1_],P2:Parabola2D[{h_,k_},f_,theta_]] :=
Point2D[L1,Quadratic2D[P2]];
Line Construction
Axis Line
Format: Line2D[parabola]
Constructs a line that contains the axis of a parabola.
Line2D[Parabola2D[{h_,k_},f_,theta_]] :=
Rotate2D[Line2D[0,1,-k],theta,{h,k}];
Polar Line
Format: Line2D[point,parabola]
Constructs the polar (line) of a pole (point) with respect to a parabola. If the point is on the parabola then the line is tangent to the parabola at the point.
Line2D[P1:Point2D[{x1_,y1_}],P2:Parabola2D[{h_,k_},f_,theta_]] :=
Line2D[P1,Quadratic2D[P2]];
Parabola Construction
Parabola from Focus/Directrix
Format: Parabola2D[point,line]
Constructs a parabola from a focus point and a directrix line.
Parabola2D::invptln=
"The focus `1` is on the directrix `2`; no valid parabola can be constructed.";
Parabola2D[P1:Point2D[{x1_,y1_}],L2:Line2D[a2_,b2_,c2_]] :=
Module[{pt},
If[IsOn2D[P1,L2],
Message[Parabola2D::invptln,P1,L2];$Failed,
pt=Point2D[P1,L2];
Parabola2D[Coordinates2D[Point2D[P1,pt]],
Distance2D[P1,pt]/2,
ArcTan[x1-XCoordinate2D[pt],
y1-YCoordinate2D[pt]]]] ];
Epilogue
End[ ]; (* end of "`Private" *)
EndPackage[ ]; (* end of "D2DParabola2D`" *)