Exploring Analyic Geometry with Mathematica® |
|||||
| Home | Contents | Commands | Packages | Explorations | Reference |
| Tour | Lines | Circles | Conics | Analysis | Tangents |
D2DTangentCircles2D
The package D2DTangentCircles2D provides a variety of functions for constructing tangent circles that satisfy three conditions. The conditions include passing through a given point, center at a given point or on a given curve, tangent to a given line and tangent to a given circle.
Initialization
BeginPackage["D2DTangentCircles2D`", {"D2DCircle2D`", "D2DExpressions2D`", "D2DGeometry2D`", "D2DLine2D`", "D2DMaster2D`", "D2DPoint2D`", "D2DSolve2D`"}];
D2DTangentCircles2D::usage=
"D2DTangentCircles2D is a package for constructing tangent circles.";
TangentCircles2D::usage=
"TangentCircles2D[objList,(center),(radius)] constructs a list of circles tangent to one, two or three objects (points, lines or circles); optionally, the center may be constrained to a point, line or circle; optionally, the radius may be specified; the total number of constraints must be three (constraining the center to a point is two constraints).";
Begin["`Private`"];
Queries
Point, Line or Circle Query
The private function IsSimple$2D returns True if an object is a point, line or circle; otherwise, returns False.
IsSimple$2D[obj_] := Is2D[obj,{Point2D,Line2D,Circle2D}];
Line or Circle Query
The private function IsSimpleCurve$2D returns True if an object is a line or a circle; otherwise, returns False.
IsSimpleCurve$2D[obj_] := Is2D[obj,{Line2D,Circle2D}];
Tangent/On Equations
Point Tangent to a Circle (On Circle)
The private function TangentEquation$2D returns an equation constraining a point to be on a circle.
TangentEquation$2D[Point2D[{x1_,y1_}],Circle2D[{h2_,k2_},r2_]] :=
(x1-h2)^2+(y1-k2)^2==r2^2;
Line Tangent to a Circle
The private function TangentEquation$2D returns an equation constraining a line to be tangent to a circle.
TangentEquation$2D[Line2D[a1_,b1_,c1_],Circle2D[{h2_,k2_},r2_]] :=
(a1^2+b1^2)*r2^2==(a1*h2+b1*k2+c1)^2;
Circle Tangent to a Circle
The private function TangentEquation$2D returns an equation constraining two circles to be tangent.
TangentEquation$2D[Circle2D[{h1_,k1_},r1_],Circle2D[{h2_,k2_},r2_]] :=
((h1-h2)^2+(k1-k2)^2-(r1-r2)^2)*((h1-h2)^2+(k1-k2)^2-(r1+r2)^2) == 0;
Point on a Point
The private function OnEquation$2D returns a pair of equations constraining two points to be coincident.
OnEquation$2D[{x1_,y1_},Point2D[{x2_,y2_}]] := {x1==x2, y1==y2};
Point on a Line
The private function OnEquation$2D returns an equation constraining a point to be on a line.
OnEquation$2D[{x1_,y1_},Line2D[a2_,b2_,c2_]] := {a2*x1+b2*y1+c2==0};
Point on a Circle
The private function OnEquation$2D returns an equation constraining a point to be on a circle.
OnEquation$2D[{x1_,y1_},Circle2D[{h2_,k2_},r2_]] :=
{(x1-h2)^2+(y1-k2)^2==r2^2};
General Circle Tangency
Tangent Circles
The private function TangentCircles$2D is a general function that constructs a list of circles tangent to a list of one, two or three objects, optionally with center on a given object, optionally with a given radius.
TangentCircles$2D[obj_List,cenObj_,radius_] :=
Module[{h,k,r,c1,eq1,eq2,eq3,ans,circles},
c1=Circle2D[{h,k},r];
eq1=Map[TangentEquation$2D[#,c1]&,obj];
eq2=If[cenObj===Null,{},OnEquation$2D[{h,k},cenObj]];
eq3=If[radius===Null,{},{r==radius}];
ans=Solve2D[Join[eq1,eq2,eq3],{h,k,r}];
ans=Select[ans,Not[IsComplex2D[{h,k,r} /. #]]&];
ans=Select[ans,Not[IsZeroOrNegative2D[r /. #]]&];
circles=Map[(c1 /. #)&, ans];
Complement[Union[circles],obj] ];
Tangent Circle Construction
Tangent Object, Center Point
Format: TangentCircles2D[{pt|ln|cir}, pt]
Constructs a list of circles tangent to a point, line or circle and passing through a point.
TangentCircles2D[{obj_?IsSimple$2D},P:Point2D[{x_,y_}]] :=
TangentCircles$2D[{obj},P,Null];
Tangent Object, Center on Object, Radius
Format: TangentCircles2D[{pt|ln|cir}, ln|cir, r]
Constructs a list of circles tangent to a point, line or circle, with center point on a line or circle and with a given radius.
TangentCircles2D[{obj1_?IsSimple$2D},obj2_?IsSimpleCurve$2D,
r3_?IsScalar2D] :=
TangentCircles$2D[{obj1},obj2,r3] /;
Not[IsZeroOrNegative2D[r3]];
Two Tangent Objects, Center On Object
Format: TangentCircles2D[{pt|ln|cir, pt|ln|cir}, ln|cir]
Constructs a list of circles tangent to two objects (points, lines or circles) centered on a line or circle.
TangentCircles2D[{obj1_?IsSimple$2D,obj2_?IsSimple$2D},
obj3_?IsSimpleCurve$2D] :=
TangentCircles$2D[{obj1,obj2},obj3,Null];
Two Tangent Objects, Radius
Format: TangentCircles2D[{pt|ln|cir, pt|ln|cir}, r]
Constructs a list of circles tangent to two objects (points, lines or circles) with a given radius.
TangentCircles2D[{obj1_?IsSimple$2D,obj2_?IsSimple$2D},
r3_?IsScalar2D] :=
TangentCircles$2D[{obj1,obj2},Null,r3] /;
Not[IsZeroOrNegative2D[r3]];
Three Tangent Objects
Format: TangentCircles2D[{pt|ln|cir, pt|ln|cir, pt|ln|cir}]
Constructs a list of circles tangent to three objects (points, lines or circles).
TangentCircles2D[{obj1_?IsSimple$2D,obj2_?IsSimple$2D,
obj3_?IsSimple$2D}] :=
TangentCircles$2D[{obj1,obj2,obj3},Null,Null];
Epilogue
End[ ]; (* end of "`Private" *)
EndPackage[ ]; (* end of "D2DTangentCircles2D`" *)