Exploring Analyic Geometry with Mathematica®

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


The package D2DSketch2D provides the Sketch2D command which is the basic command for plotting Descarta2D objects.


BeginPackage["D2DSketch2D`", {"D2DExpressions2D`", "D2DMaster2D`"}];

   "D2DSketch2D is a package providing sketching functions.";

   "AskCurveLength2D[ ] returns the value of the option CurveLength2D for the Sketch2D function (the approximate sketched length of an unbounded curve).";

   "CurveLength2D->n is an option for the Sketch2D function to specify the approximate sketched length of an unbounded curve.";

   "CurveLimits2D[{x,y},curve] returns a list of two parameter values, {-t,t}, so that the distance the point on the unbounded curve at the parameter 't' is a distance CurveLength2D/2 from the given coordinates.";

   "IsDisplay2D[object] returns 'True' if the object can be displayed.";

   "MakePrimitives2D[object,{t1,t2}] returns a list of graphics primitives between a pair of parameters for a parametrically defined curve.";

   "SetDisplay2D[objPatt,objPrim] modifies the Display command to allow plotting of a new object.";

   "Sketch2D[objList,opts] sketches a list of geometric objects.";



Filter Options

The private function FilterOptions$2D filters a list of options and provides a Sequence of valid options for the specified command.

FilterOptions$2D[command_Symbol,opts___] :=
   Module[{keywords = First /@ Options[command]},
      Sequence @@ Select[{opts},MemberQ[keywords,First[#]]&] ];


Set Display

Format: SetDisplay2D[objPatt,objPrim]
Modifies the Mathematica Display command to enable plotting of a new object.  The argument objPatt is a pattern which matches the standard form of the object used in Descarta2D; the argument objPrim provides the commands that generate the primitives required to plot the object.


Display Query

Format:  IsDisplay2D[object]
Returns True if the object can be displayed and has parameters that can be evaluated to real numbers; otherwise, returns False.  The function SetDisplay2D, above, provides the implementation of IsDisplay2D for each object after its display graphics are defined.

IsDisplay2D[___] := False;

Curve Length

Format: CurveLength2D->n
The option CurveLength2D of the Sketch2D command specifies the plotted length of an infinite curve and is measured from the midpoint to one of the plotted end points of the curve.

   "Option CurveLength2D->`1` is invalid; 'CurveLength2D' must be positive; the current value of CurveLength2D->`2` will be retained.";

SetOptions[Sketch2D,opts1___,CurveLength2D->n_,opts2___] :=
   Message[Sketch2D::invalidLength,n,AskCurveLength2D[ ]] /;
(IsZeroOrNegative2D[n] || !IsReal2D[n]);

Format: AskCurveLength2D[ ]
Returns the value of the Sketch2D command CurveLength2D option.

AskCurveLength2D[ ] := Options[Sketch2D,CurveLength2D][[1,2]];

Curve Parameter Limits

Format: CurveLimits2D[{x,y},curve]
Returns a list of two parameter values {-t,t} on an unbounded curve such that the points at the parameter values on the curve are at a distance CurveLength2D/2 from the given base point coordinates.  This is a numerical function used to support plotting, and, therefore, requires numerical arguments.

CurveLimits2D[p0:{x0_,y0_},crv_?IsValid2D] :=
      {-t,t} /. root[[1]] ] /;

Make Graphics Primitives

Format: MakePrimitives2D[curve,{"D2DSketch2D_2.gif","D2DSketch2D_3.gif"}]
Provides graphics primitives for a parametrically defined curve between two parameters.

MakePrimitives2D[crv_?IsValid2D,{t1_?IsScalar2D,t2_?IsScalar2D}] :=
      parPlot=ParametricPlot[crv[t] //Evaluate,{t,t1,t2}];
      parPlot ];


Format: Sketch2D[objList,opts]
Plots a list of Descarta2D objects.  The options may be any options supported by the Mathematica Graphics command.  The list is flattened before it is plotted.

Sketch2D::noObj="No valid objects to sketch.";

   "<`1`> object(s) cannot be sketched.";

Options[Sketch2D] =

Sketch2D[obj_List,opts___?OptionQ] :=
                                  Sequence @@ inputOptsList]];
      grOptsSequence=FilterOptions$2D[Graphics, Sequence @@ allOptsList];
      realObj=Select[Flatten[obj],IsDisplay2D] //N;
      SetOptions[Sketch2D,Sequence @@ sketchOptsList];
      grafix ];


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

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