(* :Author: Christopher Moretti *) (* :Summary: This notebook contains a command ConicInfo[] which handles the rotation, shifting, and plotting of conic sections. The axes of the conic (or axis and directrix in the case of a parabola) are plotted, as is the center (or focus and vertex for a parabola). ConicInfo[] checks for degenrate cases, and plots them if the conic is a line pair. If one of the axes is vertical, ImplicitPlot (used to plot the conics) will return an error message. ConicInfo[] accepts all of the options from the Plot[] command - in particular, AspectRatio-> Automatic is useful for preserving shapes of the conic. It does this through the use of FilterOptions[].*) (* :History: Version 1.0 by Christopher Moretti, 1997 *) <$DisplayFunction, Axes->True}]; v1=var[[1]];st=var[[2]];fi=var[[3]]; a=Coefficient[conic,v1^2]; c=Coefficient[conic, v2^2]; b=Coefficient[conic, v1 v2]; d=Coefficient[conic/.v2->0,v1]; e=Coefficient[conic/.v1->0,v2]; f=conic/.{v1->0,v2->0}; mat={{a,b/2,d/2},{b/2,c,e/2},{d/2,e/2,f}}; eig=Re[N[Eigenvalues[mat]]]; flag=MemberQ[eig,0]||Abs[eig]==eig||Abs[eig]==-eig; If[flag,Print[conic, "=0 represents a degenerate conic section."];]; If[flag, eqnlist=v2 /. Solve[conic==0,v2]; If[ Union[Im[eqnlist/.v1->3],Im[eqnlist/.v1->4]]=={0}, Print["The conic is the union of the lines:"]; Print[v2," = ",eqnlist[[1]]]; Print[v2," = ",eqnlist[[2]]]; ImplicitPlot[conic==0, {v1,st,fi}]; Return[], Print["The conic is either a single point or empty."];Return[]] ]; If[flag,Return[]]; If[b^2-4a c!=0, h=-((-2*c*d + b*e)/(b^2 - 4*a*c)); k=-((-(b*d) + 2*a*e)/(-b^2 + 4*a*c)); conic1=Expand[conic/.{v1->x1 Cos[t]-y1 Sin[t],v2->x1 Sin[t]+y1 Cos[t]}]; badterm=Coefficient[conic1, x1 y1]; t=If[NumberQ[badterm],0, Select[(t/.Solve[badterm==0,t]),( And[(N[#1]>=-.001),N[#1]{Automatic,Automatic,Automatic,Dashing[{.05}], Dashing[{.05}]},DisplayFunction->Identity,PlotPoints->50], plotopts];]; If[b^2-4 a c==0 , conic1a=Expand[conic/.{v1->x2 Cos[t]-y2 Sin[t],v2->x2 Sin[t]+y2 Cos[t]}]; badterm=Coefficient[conic1a, x2 y2]; t=If[NumberQ[badterm],0, Select[(t/.Solve[badterm==0,t]),( And[(N[#1]>=-.001),N[#1]0,y2->0}; h=(c1^2-4b1 d1)/(4 a1 b1); k=-c1/(2b1);mat2={{Cos[t],-Sin[t]},{Sin[t],Cos[t]}}; {h1,k1}=mat2.{h,k}; eqn1=((v1) Cos[t]+(v2) Sin[t])/.{v1->v1-h1,v2->v2-k1}; {foc1,foc2}=mat2.{h-f1,k}; eqn2=Numerator[ Together[((v1) Cos[t+Pi/2]+(v2) Sin[t+Pi/2])/.{v1->v1-h1, v2->v2-k1}]]; eqn3=((v1) Cos[t]+(v2) Sin[t]); eqn4=((v1) Cos[t+Pi/2]+(v2) Sin[t+Pi/2]); h3=-Coefficient[conic2,y2]/(Coefficient[conic2,y2^2]2); conic3=Expand[conic2/.{x2->x2+h,y2->y2+k}]; Print["For the parabola ",conic,"=0:"]; Print["After rotating the coordinate axes through an angle of ",t, "radians, the conic has the equation ", Normal[Series[conic2,{x2,h,2},{y2,k,2}]]," = 0."]; Print["The vertex of the parabola is (",h1,",",k1,")."]; Print["The focus is (",foc1,",",foc2,")."]; Print["The focal length is ",Abs[f1],"."]; Print["The axis of the parabola is "Expand[ eqn2*Denominator[Together[eqn2]]]," = 0."]; Print["The directrix of the parabola is ",eqn1-f1," = 0."]; Show[Graphics[{{PointSize[.04],Point[{h1,k1}]},{PointSize[.04], Point[{foc1,foc2}]}}], ImplicitPlot[{conic==0,eqn1==f1,eqn2==0,eqn3==0,eqn4==0},{v1,st,fi}, PlotPoints->50, PlotStyle->{Automatic,Dashing[{.05}],Dashing[{.05}],Automatic, Automatic},DisplayFunction->Identity],plotopts];]]; If[b^2-4 a c==0 , If[Exponent[conic2a,x2]==2,conic2=conic2a/Coefficient[conic2a,x2^2]; f1=Coefficient[conic2,y2]/4; a1=4 f1;b1=Coefficient[conic2,x2^2];c1= Coefficient[conic2,x2];d1=conic2/.{x2->0,y2->0}; h=(c1^2-4b1 d1)/(4 a1 b1); k=-c1/(2b1);mat2={{Cos[t],-Sin[t]},{Sin[t],Cos[t]}}; {h1,k1}=mat2.{k,h}; eqn1=((v1) Cos[t]+(v2) Sin[t])/.{v1->v1-h1,v2->v2-k1}; {foc1,foc2}=mat2.{k,h-f1}; eqn2=Numerator[ Together[((v1) Cos[t+Pi/2]+(v2) Sin[t+Pi/2])/.{v1->v1-h1, v2->v2-k1}]]; eqn3=((v1) Cos[t]+(v2) Sin[t]); eqn4=((v1) Cos[t+Pi/2]+(v2) Sin[t+Pi/2]); h3=-Coefficient[conic2,x2]/(Coefficient[conic2,x2^2]2); conic3=Expand[conic2/.{x2->x2+h,y2->y2+k}]; Print["For the parabola ",conic," =0:"]; Print["After rotating the coordinate axes through an angle of ",t, "radians, the conic has the equation ", Normal[Series[conic2,{x2,h1,2},{y2,-k1,2}]]," = 0."]; Print["The vertex of the parabola is (",h1,",",k1,")."]; Print["The focus is (",foc1,",",foc2,")."]; Print["The focal length is ",Abs[f1],"."]; Print["The axis of the parabola is "Expand[ eqn1*Denominator[Together[eqn1]]]," = 0."]; Print["The directrix of the parabola is ",eqn2-f1," = 0."]; Show[Graphics[{{PointSize[.04],Point[{h1,k1}]},{PointSize[.04], Point[{foc1,foc2}]}}], ImplicitPlot[{conic==0,eqn1==0,eqn2==f1,eqn3==0,eqn4==0},{v1,st,fi}, PlotPoints->50, PlotStyle->{Automatic,Dashing[{.05}],Dashing[{.05}],Automatic, Automatic},DisplayFunction->Identity],plotopts];]];] ConicInfo::usage="ConicInfo[ q,{x,a,b},y] performs translations and rotations of the conic form given by q=0. The equations \ of the axes of the conic are given as well as the center of the conic, the \ angle of rotation, and the simplified conic form in the new coordinate system {x2,y2}. ConicInfo can detect degenerate conics and will process the case of a pair \ of lines. ConicInfo will also create a plot of the conic and axes from x=a to \ x=b using ImplicitPlot. If {x2,y2} is just a translation of {x,y}, the \ vertical axis will not be plotted. If the conic is a hyperbola whose \ asymptotes are close to being vertical/horiztonal then ImplicitPlot may \ return a misleading graph." (* Example: ConicInfo[(x-3)^2+2x y+y^2-5,{x,-10,10},y,AspectRatio->Automatic] *)