Exploring Analyic Geometry with Mathematica® |
|||||
| Home | Contents | Commands | Packages | Explorations | Reference |
| Tour | Lines | Circles | Conics | Analysis | Tangents |
D2DHyperbola2D
The package D2DHyperbola2D implements the Hyperbola2D object.
Initialization
BeginPackage["D2DHyperbola2D`",{"D2DExpressions2D`", "D2DGeometry2D`", "D2DLine2D`", "D2DMaster2D`", "D2DNumbers2D`", "D2DPoint2D`", "D2DQuadratic2D`", "D2DSegment2D`", "D2DSketch2D`", "D2DTransform2D`"}];
D2DHyperbola2D::usage=
"'D2DHyperbola2D' is a package providing support for hyperbolas.";
Conjugate2D::usage=
"Conjugate2D is a keyword used to construct a conjugate hyperbola in Hyperbola2D[hyperbola, Conjugate2D].";
Hyperbola2D::usage=
"Hyperbola2D[{h,k},a,b,theta] is the standard form of a hyperbola, centered at (h,k), semi-transverse axis length 'a', semi-conjugate axis 'b' and rotation angle 'theta'.";
SemiConjugateAxis2D::usage=
"SemiConjugateAxis2D[hyperbola] returns the length of the semi-conjugate axis of a hyperbola.";
SemiTransverseAxis2D::usage=
"SemiTransverseAxis2D[hyperbola] returns the length of the semi-transverse axis of a hyperbola.";
Begin["`Private`"];
Description
Representation
Format: Hyperbola2D[{h,k},a,b,θ]
Standard representation of a hyperbola in Descarta2D. The first argument is a list of coordinates representing the center of the hyperbola. The second and third arguments are (positive) scalars representing the lengths of the semi-transverse and semi-conjugate axes. The fourth argument is the counter-clockwise rotation (in radians) of the hyperbola about the center point.
Equation
Format: Quadratic2D[hyperbola]
Constructs the 'quadratic' representing the equation of a hyperbola.
Quadratic2D[Hyperbola2D[{h_,k_},a_,b_,theta_]] :=
Rotate2D[
Quadratic2D[b^2,0,-a^2,-2*b^2*h,2*a^2*k,-a^2*b^2+b^2*h^2-a^2*k^2],
theta,{h,k}];
Evaluation
Format: Hyperbola2D[{h,k},a,b,θ,True|False][t]
Evaluates the primary branch of a hyperbola (when the keyword is False or omitted) or its reflection (when the keyword is True). The primary branch is the one opening about the +x-axis when the rotation angle is zero. The end points of the focal chords are at parameter values -1 and +1.
Hyperbola2D[{h_,k_},a_,b_,theta_,reflection_:False][t_?IsScalar2D] :=
Module[{alpha,e,s},
alpha=If[reflection==False,0,Pi];
e=Sqrt[a^2+b^2]/a;
s=ArcCosh[e];
Rotate2D[{h+a*Cosh[s*t],k+b*Sinh[s*t]},theta+alpha,{h,k}] ] /;
MemberQ[{True,False},reflection];
Graphics
Provides graphics for a hyperbola by extending the Mathematica Display command. Executed when the package is loaded.
SetDisplay2D[
Hyperbola2D[{h_,k_},a_,b_,t_][{t1_?IsScalar2D,t2_?IsScalar2D}] /;
t1<=t2,
MakePrimitives2D[
Hyperbola2D[{h,k},a,b,t,False],{t1,t2}] ];
SetDisplay2D[
Hyperbola2D[{h_,k_},a_,b_,t_][{t1_?IsScalar2D,t2_?IsScalar2D}] /;
t1>t2,
MakePrimitives2D[
Hyperbola2D[{h,k},a,b,t,True],{t2,t1}] ];
SetDisplay2D[
Hyperbola2D[{h_,k_},a_,b_,t_],
Map[MakePrimitives2D[
Hyperbola2D[{h,k},a,b,t,#],
CurveLimits2D[{a,0},Hyperbola2D[{0,0},a,b,0]]]&,
{False,True}] ];
Validation
Format: Hyperbola2D[{h,k},a,b,θ]
Detects a hyperbola with imaginary arguments and returns the $Failed symbol. If the imaginary parts are insignificant, they are removed.
Hyperbola2D::imaginary=
"An invalid hyperbola of the form 'Hyperbola2D[`1`, `2`, `3`, `4`]' has been detected; the arguments cannot be imaginary.";
Hyperbola2D[{h_,k_},a_,b_,theta_] :=
(Hyperbola2D @@ ChopImaginary2D[Hyperbola$2D[{h,k},a,b,theta]]) /;
(FreeQ[{h,k,a,b,theta},_Pattern] && IsTinyImaginary2D[{h,k,a,b,theta}]);
Hyperbola2D[{h_,k_},a_,b_,theta_] :=
(Message[Hyperbola2D::imaginary,{h,k},a,b,theta];$Failed) /;
(FreeQ[{h,k,a,b,theta},_Pattern] && IsComplex2D[{h,k,a,b,theta},0]);
Format: Hyperbola2D[{h,k},a,b,θ]
Detects a hyperbola with invalid arguments and returns the $Failed symbol.
Hyperbola2D::invalid=
"An invalid hyperbola of the form 'Hyperbola2D[`1`, `2`, `3`, `4`]' was encountered; the lengths of the semi-transverse and semi-conjugate axes must be positive.";
Hyperbola2D[{h_,k_},a_,b_,theta_] :=
(Message[Hyperbola2D::invalid,{h,k},a,b,theta];$Failed) /;
(FreeQ[{h,k,a,b,theta},_Pattern] && IsZeroOrNegative2D[{a,b},Or,0]);
Format: Hyperbola2D[{h,k},a,b,θ]
Normalizes the rotation angle on a hyperbola to the range 0≤θ<π.
Hyperbola2D[{h_,k_},a_,b_,theta_] :=
Hyperbola2D[{h,k},a,b,PrimaryAngle2D[theta,Pi]] /;
(FreeQ[{h,k,a,b,theta},_Pattern] && (theta=!=PrimaryAngle2D[theta,Pi]));
Format: IsValid2D[hyperbola]
Verifies that a hyperbola is syntactically valid.
IsValid2D[Hyperbola2D[{h_,k_},a_,b_,theta_,True]] :=
IsValid2D[Hyperbola2D[{h,k},a,b,theta]];
IsValid2D[Hyperbola2D[{h_,k_},a_,b_,theta_,False]] :=
IsValid2D[Hyperbola2D[{h,k},a,b,theta]];
IsValid2D[
Hyperbola2D[{h_?IsScalar2D,k_?IsScalar2D},
a_?IsScalar2D,b_?IsScalar2D,
theta_?IsScalar2D]] := True;
Scalars
Angle of Rotation
Format: Angle2D[hyperbola]
Returns the rotation angle of a hyperbola.
Angle2D[Hyperbola2D[{h_,k_},a_,b_,theta_]] := theta;
Semi-transverse Axis Length
Format: SemiTransverseAxis2D[hyperbola]
Returns the length of the semi-transverse axis of a hyperbola.
SemiTransverseAxis2D[Hyperbola2D[{h_,k_},a_,b_,theta_]] := a;
Semi-conjugate Axis Length
Format: SemiConjugateAxis2D[hyperbola]
Returns the length of the semi-conjugate axis of a hyperbola.
SemiConjugateAxis2D[Hyperbola2D[{h_,k_},a_,b_,theta_]] := b;
Transformations
Reflect
Format: Reflect2D[hyperbola,line]
Reflects a hyperbola in a line.
Reflect2D[Hyperbola2D[{h_,k_},a_,b_,theta_],L:Line2D[p_,q_,r_]] :=
Hyperbola2D[Reflect2D[{h,k},L],a,b,ReflectAngle2D[theta,L]];
Rotate
Format: Rotate2D[hyperbola,θ,coords]
Rotates a hyperbola 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[Hyperbola2D[{h_,k_},a_,b_,theta_],alpha_?IsScalar2D,
{x0_?IsScalar2D,y0_?IsScalar2D}] :=
Hyperbola2D[Rotate2D[{h,k},alpha,{x0,y0}],a,b,alpha+theta];
Scale
Format: Scale2D[hyperbola,s,coords]
Scales a hyperbola from a position given by coordinates. If the position is omitted, it defaults to the origin (see D2DTransform2D.html).
Scale2D[Hyperbola2D[{h_,k_},a_,b_,theta_],s_?IsScalar2D,
{x0_?IsScalar2D,y0_?IsScalar2D}] :=
Hyperbola2D[Scale2D[{h,k},s,{x0,y0}],s*a,s*b,theta] /;
Not[IsZeroOrNegative2D[s]];
Translate
Format: Translate2D[hyperbola,{u,v}]
Translates a hyperbola delta distance.
Translate2D[Hyperbola2D[{h_,k_},a_,b_,theta_],
{u_?IsScalar2D,v_?IsScalar2D}] :=
Hyperbola2D[{h+u,k+v},a,b,theta];
Point Construction
Center Point of a Hyperbola
Format: Point2D[hyperbola]
Constructs the center point of a hyperbola.
Point2D[Hyperbola2D[{h_,k_},a_,b_,theta_]] := Point2D[{h,k}];
Pole Point
Format: Point2D[line,hyperbola]
Constructs the pole (point) of a polar (line) with respect to a hyperbola. If the line is tangent to the hyperbola then the point is the point of tangency.
Point2D[L1:Line2D[a1_,b1_,c1_],H2:Hyperbola2D[{h_,k_},a_,b_,theta_]] :=
Point2D[L1,Quadratic2D[H2]];
Line Construction
Axis of a Hyperbola
Format: Line2D[hyperbola]
Constructs a line that contains the transverse axis of a hyperbola.
Line2D[Hyperbola2D[{h_,k_},a_,b_,theta_]] :=
Rotate2D[Line2D[0,1,-k],theta,{h,k}];
Polar Line
Function: Line2D[point,hyperbola]
Constructs the polar (line) of a pole (point) with respect to a hyperbola. If the point is on the hyperbola then the line is tangent to the hyperbola at the point.
Line2D[P1:Point2D[{x1_,y1_}],H2:Hyperbola2D[{h_,k_},a_,b_,theta_]] :=
Line2D[P1,Quadratic2D[H2]];
Hyperbola Construction
Conjugate Hyperbola
Format: Hyperbola2D[hyperbola,Conjugate2D]
Constructs the conjugate hyperbola of a given hyperbola.
Hyperbola2D[Hyperbola2D[{h_,k_},a_,b_,theta_],Conjugate2D] :=
Hyperbola2D[{h,k},b,a,theta+Pi/2]
Hyperbola from Vertices/Eccentricity
Format: Hyperbola2D[{point,point},e]
Constructs a hyperbola from the vertices and eccentricity.
Hyperbola2D::invdef=
"The defining geometry or eccentricity is invalid; the eccentricity of a hyperbola must be greater than 1, the foci and vertices cannot be coincident and the focus cannot lie on the directrix.";
Hyperbola2D[{P1:Point2D[{x1_,y1_}],P2:Point2D[{x2_,y2_}]},e_?IsScalar2D] :=
Module[{a,b,h,k},
If[IsZeroOrNegative2D[e-1] || IsCoincident2D[P1,P2],
Message[Hyperbola2D::invdef];$Failed,
a=Distance2D[P1,P2]/2;
b=a*Sqrt[e^2-1];
{h,k}={(x1+x2)/2,(y1+y2)/2};
Hyperbola2D[{h,k},a,b,ArcTan[x2-x1,y2-y1]]] ];
Hyperbola from Foci/Eccentricity
Format: Hyperbola2D[point,point,e]
Constructs a hyperbola from the foci and eccentricity.
Hyperbola2D[P1:Point2D[{x1_,y1_}],P2:Point2D[{x2_,y2_}],e_?IsScalar2D] :=
Module[{a,b,h,k},
If[IsZeroOrNegative2D[e-1] || IsCoincident2D[P1,P2],
Message[Hyperbola2D::invdef];$Failed,
a=Distance2D[P1,P2]/(2*e);
b=a*Sqrt[e^2-1];
{h,k}={(x1+x2)/2,(y1+y2)/2};
Hyperbola2D[{h,k},a,b,ArcTan[x2-x1,y2-y1]]] ];
Hyperbola from Focus/Directrix/Eccentricity
Format: Hyperbola2D[point,line,e]
Constructs a hyperbola from focus point, directrix line and eccentricity.
Hyperbola2D[P1:Point2D[{x1_,y1_}],L2:Line2D[p_,q_,r_],e_?IsScalar2D] :=
Module[{d,s,a,b,h,k},
If[IsZeroOrNegative2D[e-1] || IsOn2D[P1,L2],
Message[Hyperbola2D::invdef];$Failed,
d=Distance2D[P1,L2];
s=(p*x1+q*y1+r)/(p^2+q^2);
a=d*e/(e^2-1);
b=a*Sqrt[e^2-1];
{h,k}={x1,y1}-{p,q}*(a*s*e)/d;
Hyperbola2D[{h,k},a,b,ArcTan[p,q]]] ];
Epilogue
End[ ]; (* end of "`Private" *)
EndPackage[ ]; (* end of "D2DHyperbola2D`" *)