# Hyperbola – part 2

The Hyperbola is the set of points whose distance to two fixed points called foci always has the same difference in length. The line through the foci is called the Transverse Axis. For the vertical axis, the equation is $\frac{Y^2}{a^2}-\frac{X^2}{b^2}=1$

solving for Y $Y=\pm{a}\sqrt{\frac{X^2}{b^2}+1}$

The complete hyperbola graph is made by calling the rectangular coordinate loop (not shown here) twice with a positive and negative value function. Sub draw_hyp_02()
'rect coordinates
'init_hyperbola reads in Xmin, Xmax and X_inc from form
Call init_hyperbola
A = frm_hyperbola.txt_a2.Value
B = frm_hyperbola.txt_b2.Value
strLabel = "Y^2/" & A & "^2 - X^2/" & B & "^2 = 1"

'rect coordinate graphing loop
Call draw_rect("hyp_02_plus")
Call draw_rect("hyp_02_minus")

C = ((A ^ 2) + (B ^ 2)) ^ (1 / 2)
Call draw_point(0, -C, "Focus")
Call draw_point(0, C, "Focus")

Call draw_line_mxb(A / B, 0, Xmin, Xmax, "Asymptote")
Call draw_line_mxb(-A / B, 0, Xmin, Xmax, "Asymptote")

If frm_hyperbola.chk_box_label_graph = True Then
label_graph
End If

End Sub

Function hyp_02_plus(x As Double) As Double
hyp_02_plus = ((x ^ 2) / (B ^ 2)) + 1
hyp_02_plus = hyp_02_plus ^ (1 / 2)
hyp_02_plus = A * hyp_02_plus
End Function

Function hyp_02_minus(x As Double) As Double
hyp_02_minus = ((x ^ 2) / (B ^ 2)) + 1
hyp_02_minus = hyp_02_minus ^ (1 / 2)
hyp_02_minus = -(A * hyp_02_minus)
End Function

Sub draw_line_mxb(m As Double, b_int As Double, x1 As Double, x2 As Double, Optional strname As String = "no_name")
'y=mx+b
Dim y1 As Double, y2 As Double
Dim pt1(0 To 2) As Double
Dim pt2(0 To 2) As Double

y1 = m * x1 + b_int
y2 = m * x2 + b_int
pt1(0) = x1: pt1(1) = y1: pt1(2) = 0
pt2(0) = x2: pt2(1) = y2: pt2(2) = 0

On Error Resume Next 'to not crash if layer does not exist
If strname <> "no_name" Then
lineobj.Layer = strname
End If
End Sub

Sub draw_point(x1 As Double, y1 As Double, Optional strname As String = "no_name")
Dim pt1(0 To 2) As Double
pt1(0) = x1: pt1(1) = y1: pt1(2) = 0