# Parabolas part 3

The standard equation for a parabola with horizontal directrix and vertex at (h,k) $(X-h)^2=4p(Y-k)$ The loop program not shown is the same one that draws the parabola with vertex at origin (in part 2).

```
Sub draw_pr05()
'Horiz Directrix at vertex (h,k)
Call init_parabola
funcname = "PR_05"

A = frm_parabola.txt_a5.Value
B = frm_parabola.txt_b5.Value
C = frm_parabola.txt_c5.Value

strLabel = "(X-" &amp; B &amp; ")^2 = 4 * " &amp; A &amp; " * (Y-" &amp; C &amp; ")"

Call draw_parabola(funcname)
Call draw_focus(B, A + C)
Call draw_directrix(Xmin, C - A, Xmax, C - A)
acadApp.Update
End Sub

Function PR_05(X As Double) As Double
'Y = (x-h)^2/4P + k
PR_05 = ((X - B) ^ 2) / (4 * A) + C
End Function

``` The standard equation for a parabola with vertical directrix and vertex at (h,k) $(Y-k)^2=4p(X-h)$

Programmatically this is a simple transformation. I admit i simply switched the x and y values at the recording of values (when they are stored in the data array that the polyline object uses) and then when the vertex came out switched between x and y, i just switched the reading of that variable into the function.  I won’t build on that technique until i understand it better. If i had  reconstructed the whole program, i would have added routines and logic, i would have added many lines of code.  i changed only 3 lines of code to make this work.  Call it a pragmatic solution.  Kludge might be a better description, though its not inefficient. Hard to maintain, Hard to extend is accurate. I think it draws an accurate graph in all cases.

dictionary.com “kludge – a software or hardware configuration that, while inelegant, inefficient, clumsy, or patched together, succeeds in solving a specific problem or performing a particular task”.

Intuitively it makes sense, the function is the same, the graph is only rotated on its vertex. X and Y are just labels.  The standard procedure to rotate a graph around a point is to subtract the point from the graph (move the graph to the origin), rotate the graph around the origin, then move the graph back the same displacement.  Other types of coordinate graphing systems, parametric and polar, will graph this equation without problem.

The loop program not shown is the same one that draws the parabola with vertex at origin (in part 2).

```
Sub draw_pr06()
'Vert Directrix at vertex (h,k)
Call init_parabola
funcname = "PR_05"

A = frm_parabola.txt_a6.Value
B = frm_parabola.txt_b6.Value
C = frm_parabola.txt_c6.Value

'draw the focus and directrix without any funny business
Call draw_focus(B + A, C)
Call draw_directrix(B - A, Xmin, B - A, Xmax)

'embarrassing but this covers a complex transformation
'i dont understand it well enough to explain it
'at this point i think it works in all cases
B = frm_parabola.txt_c6.Value
C = frm_parabola.txt_b6.Value

Call draw_parabola_yx(funcname)
acadApp.Update
strLabel = "(Y-" &amp; B &amp; ")^2 = 4 * " &amp; A &amp; " * (X-" &amp; C &amp; ")"
End Sub

```

Advertisements

This site uses Akismet to reduce spam. Learn how your comment data is processed.