Exploring Analyic Geometry with Mathematica® |
|||||
| Home | Contents | Commands | Packages | Explorations | Reference |
| Tour | Lines | Circles | Conics | Analysis | Tangents |
D2DNumbers2D
The package D2DNumbers2D provides functions for special manipulations of real numbers.
Initialization
BeginPackage["D2DNumbers2D`", {"D2DExpressions2D`", "D2DMaster2D`"}];
D2DNumbers2D::usage=
"D2DNumbers2D is a package that provides utilities for manipulating special numbers.";
ChopImaginary2D::usage=
"ChopImaginary2D[expr,(tol)] removes tiny imaginary parts from complex numbers; the default tolerance, if omitted, is 10^(-10).";
PrimaryAngle2D::usage=
"PrimaryAngle2D[theta,period] normalizes an angle to a period; the period must be Pi or 2Pi radians; if the period is omitted, it defaults to 2Pi.";
PrimaryAngleRange2D::usage=
"PrimaryAngleRange2D[{t1,t2}] normalizes a range of angles to primary angles.";
Begin["`Private`"];
Chop Imaginary Part
Format: ChopImaginary2D[expr,(tol)]
Removes the tiny imaginary parts of complex numbers in the expression that are less than a given tolerance. The default tolerance, if omitted, is
.
ChopImaginary2D[expr_,tol_:(10^(-10))] :=
MapAll[If[IsTinyImaginary2D[#],Re[#],#]&,expr] /;
TrueQ[N[tol]>=0];
Primary Angle
Format: PrimaryAngle2D[θ,2Pi|Pi]
Adjusts an angle to a primary angle in the range 0≤θ<period. The period may be Pi or 2Pi radians. The default period, if omitted, is 2Pi radians.
PrimaryAngle2D[theta_?IsScalar2D,period_:2Pi] :=
Module[{theta1=theta},
While[IsNegative2D[theta1],
theta1+=period];
While[IsZeroOrNegative2D[period-theta1],
theta1-=period];
If[Head[theta]===Real,N[theta1],theta1] ] /;
(period==Pi || period==2Pi);
Primary Angle Range
Format: PrimaryAngleRange2D[{
,
}]
Normalizes a list of two angles so that the first is in the range
, and the second is in the range
.
PrimaryAngleRange2D[{t1_?IsScalar2D,t2_?IsScalar2D}] :=
Module[{T1,T2,twoPi},
T1=PrimaryAngle2D[t1];
T2=PrimaryAngle2D[t2];
twoPi=If[Head[T2]===Real,N[2Pi],2Pi];
If[IsZeroOrNegative2D[T2-T1],
{T1,T2+twoPi},
{T1,T2}] ];
Epilogue
End[ ]; (* end of "`Private" *)
EndPackage[ ]; (* end of "D2DNumbers2D`" *)