Conic Sections

by Mohammad Ghomi

Implementation

Simplify[Solve[(x^2) + (y^2) == (((m x + h))^2), {x}]]

nf[m_] := (Sqrt[1 + (m^2)])

EllipticSection[m_, h_][y_] := 
      Module[{a, b, A, B}, a = ((m h)/(1 - (m^2))); b = 0; 
        A = (h/(1 - (m^2))); 
        B = (h/(Sqrt[1 - (m^2)])); {nf[m] A Sin[π y] + a, 
          B Cos[π y] + b}]

HyperbolicSection[m_, h_][
        y_] := {{((nf[m] (h m + (Sqrt[((m^2) - 1) (y^2) + (h^2)])))/(1 - (m^2))), 
          y}, {((nf[m] (h m - (Sqrt[((m^2) - 1) (y^2) + (h^2)])))/(1 - (m^2))), y}}

ParabolicSection[m_, h_][y_] := 
      If[h ≠ 0, {((nf[m] ((y^2) - (h^2)))/(2 h)), y}, {y, 
          0}]

GeneralSection[theta_, h_][y_] := 
      Module[{m}, m = Tan[(π/2) - theta]; 
        Which[N[Cos[(π/2) - theta]] == 0, {{y - h, y}, {-y - h, y}}, 
          N[Abs[m]] < 1, EllipticSection[m, h][y], 
          N[Abs[m]] > 1, HyperbolicSection[m, h][y], 
          N[Abs[m]] == 1, ParabolicSection[m, h][y]]]

g[theta_, h_] := 
        ParametricPlot[
          Evaluate[GeneralSection[theta, h][y]], {y, -1, 1}, 
          AspectRatio -> Automatic, 
          PlotRange -> {{-1, 1}, {-1, 1}}, Ticks -> None, 
          GridLines -> Automatic, Axes -> False, 
          FrameTicks -> None, 
          PlotStyle -> {AbsoluteThickness[1.5]}, 
          Background -> RGBColor[ .6,  .8, 1], 
          DefaultColor -> RGBColor[1, 0, 0], 
          DisplayFunction -> Identity];

Cn = 
        ParametricPlot3D[{r Cos[t], r Sin[t], r}, {r, -1, 1}, {t, 0, 
            2 π}, 
          PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}, {-1.5, 
                1.5}}, Ticks -> None, 
          DisplayFunction -> Identity];

Pl[theta_, h_] := 
        If[N[Cos[(π/2) - theta]] ≠ 0, 
          ParametricPlot3D[{y, x, 
              Tan[(π/2) - theta] y + 
                h}, {y, -Abs[Cos[(π/2) - theta]], 
              Abs[Cos[(π/2) - theta]]}, {x, -1, 1}, 
            Ticks -> None, PlotPoints -> 9, 
            PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}, {-1.5, 
                  1.5}}, DisplayFunction -> Identity], 
          ParametricPlot3D[{0, x, y + h}, {x, -1, 1}, {y, -1, 1}, 
            Ticks -> None, PlotPoints -> 9, 
            PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}, {-1.5, 
                  1.5}}, DisplayFunction -> Identity]];

CnPl[theta_, h_] := 
        Show[{Cn, Pl[theta, h]}, 
          DisplayFunction -> Identity];

graph[theta_, h_] := 
      Show[GraphicsArray[{g[theta, h], CnPl[theta, h]}], 
        DisplayFunction -> $DisplayFunction]

Animations

Elliptic Sections

Table[graph[(π/3), t], {t, -1, 1,  .1}]

Parabolic Sections

Table[graph[(π/4), t], {t, -1, 1,  .1}]

Hyperbolic Sections

Table[graph[(π/6), t], {t, -1, 1,  .1}]

Mixed Sections

Table[graph[π t,  .5], {t, 0, 1,  .05}]