Example 4.1.3

This notebook simulates the discussion in Example 4.1.3 of the text.  Example 4.1.3 talks about finding the conic through 5 points - 4 of which are fixed to be the corners of the "unit square", and the 5th is a point on a circle.

Two manipulations are included here. The first follows Example 4.1.3 exactly in that the fifth point is constrained to be on a circle of radius 1 centered at (0,1/2).  This point is in red and can be freely dragged around the circle, with both the equation and graph of the conic updated.  The second manipulation generalizes the problem by letting you enter the center and radius of the circle (so you could for example choose the circle centered at (3,2) with radius 5). Both manipulations will run without any evaluation. 

Be aware that for certain carefully chosen point placements in the second manipulation, there may not be a conic and an error will be returned (you may want to investigate this on your own and see if you can figure out what the placement must be).

ConicThrough5Points[a_,b_,c_,d_,e_,x_,y_]:= Block[ {eqns, conic,b1,c1,d1,e1,f1},
eqns = ( x^2  + b1 x y + c1 y^2 + d1 x+ e1 y + f1==0)/. { {x->a[[1]], y->a[[2]]},{x->b[[1]], y->b[[2]]},{x->c[[1]], y->c[[2]]},{x->d[[1]], y->d[[2]]},{x->e[[1]], y->e[[2]]}};
conic=(x^2  + b1 x y + c1 y^2 + d1 x+ e1 y + f1==0)/. Solve[ eqns,{b1,c1,d1,e1,f1}][[1]];
Return[conic]];

ConicFrame[ pt1_]:=Block[ {rawgraphics, conic, conicplot,x,y,pt},
pt={0,1/2}+(pt1-{0,1/2})/Norm[pt1-{0,1/2}];
rawgraphics={PointSize[.02], Black,Point[ {{0,0},{0,1},{1,0},{1,1}}],Red,Point[pt], Black, Circle[{0,1/2},1]};
conic=ConicThrough5Points[{1,1},{0,0},{1,0},{0,1},pt,x,y];
conicplot=ContourPlot[Evaluate[conic], {x,-5,5},{y,-5,5}, Frame->False, Axes->True, AxesOrigin->{0,0}, PlotPoints->75];
Return[Show[ conicplot, Graphics[rawgraphics], PlotLabel-> conic]]
]
ConicFrame2[ pt1_,pt2_,r_]:=Block[ {rawgraphics, conic, conicplot,x,y,pt},
pt=pt2+(pt1-pt2)/Norm[pt1-pt2]r;
rawgraphics={PointSize[.02], Black,Point[ {{0,0},{0,1},{1,0},{1,1}}],Red,Point[pt], Black, Circle[pt2,r]};
conic=ConicThrough5Points[{1,1},{0,0},{1,0},{0,1},pt,x,y];
conicplot=ContourPlot[Evaluate[conic], {x,-5,5},{y,-5,5}, Frame->False, Axes->True, AxesOrigin->{0,0}, PlotPoints->75];
Return[Show[ conicplot, Graphics[rawgraphics], PlotLabel-> conic]]
]

The original problem with a circle of radius 1 centered at (0,1/2):

Manipulate[ConicFrame[spot],{{spot,{1,1/2}},Locator, Appearance->None}, SaveDefinitions->True]

The generalization with any circle you want to enter:

Manipulate[ConicFrame2[spot,center,radius],{{spot,{1,1/2}},Locator, Appearance->None},{{center,{0,1/2},"Circle Center"},ControlType->InputField},{{radius,1,"Circle radius"}, ControlType->InputField}, SaveDefinitions->True]