Exploring Analyic Geometry with Mathematica®

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

D2DEquations2D

The package D2DEquations2D provides functions for converting Mathematica equations and polynomials into Descarta2D lines and quadratics, and vice versa.

Initialization

BeginPackage["D2DEquations2D`", {"D2DExpressions2D`", "D2DLine2D`", "D2DQuadratic2D`"}];

D2DEquations2D::usage=
   "D2DEquations2D is a package that provides functions for converting Mathematica polynomials and equations into lines and quadratics, and vice versa.";

Equation2D::usage=
   "Equation2D[line, {x,y}] forms a linear equation in two unknowns, a*x + b*y + c == 0; Equation2D[quad, {x,y}] forms a quadratic equation in two unknowns, a*x^2 + b*x*y + c*y^2 + d*x + e*y + f == 0.";

Polynomial2D::usage=
   "Polynomial2D[line, {x,y}] forms a linear polynomial in two unknowns, a*x + b*y + c; Polynomial2D[quad, {x,y}] forms a quadratic polynomial in two unknowns, a*x^2 + b*x*y + c*y^2 + d*x + e*y + f.";

SimplifyCoefficients2D::usage=
   "SimplifyCoefficients2D[coefList] returns a list of coefficients with common factors removed.";

Begin["`Private`"];

Coefficients

Simplify Coefficients

Format: SimplifyCoefficients2D[coefList]
Returns a list of coefficients with common factors removed.

SimplifyCoefficients2D[coef:{c1_?IsScalar2D,c2__?IsScalar2D}] :=
   Module[{gcd,coef1},
      gcd=PolynomialGCD[Sequence @@ Rationalize[coef]];
      If[IsZero2D[gcd], gcd=1];
      coef1=Map[Simplify[#/gcd]&,coef];
      Map[If[IsZero2D[Round[#]-#],Round[#],#]&,coef1] ];

Equations

Linear

Format: Equation2D[line,{x,y}]
Forms a x+b y+c==0 from a line.

Equation2D[Line2D[a_,b_,c_],{x_?IsScalar2D,y_?IsScalar2D}] := a*x+b*y+c==0;

Quadratic

Format: Equation2D[quad,{x,y}]
Forms "D2DEquations2D_1.gif" from a quadratic.

Equation2D[Quadratic2D[a_,b_,c_,d_,e_,f_],{x_?IsScalar2D,y_?IsScalar2D}] :=
   a*x^2+b*x*y+c*y^2+d*x+e*y+f==0;

Polynomials

Linear

Format: Polynomial2D[line,{x,y}]
Forms a x+b y+c from a line.

Polynomial2D[Line2D[a_,b_,c_],{x_?IsScalar2D,y_?IsScalar2D}] := a*x+b*y+c;

Quadratic

Format: Polynomial2D[quad,{x,y}]
Forms "D2DEquations2D_2.gif" from a quadratic.

Polynomial2D[Quadratic2D[a_,b_,c_,d_,e_,f_],
             {x_?IsScalar2D,y_?IsScalar2D}] :=
   a*x^2+b*x*y+c*y^2+d*x+e*y+f;

Epilogue

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


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