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.

2015-12-12_hyperbola6

 

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.

2015-12-12_hyperbola7


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

acadApp.Update
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 lineobj As AcadLine
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
Set lineobj = acadDoc.ModelSpace.AddLine(pt1, pt2)

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 pointobj As AcadPoint
acadDoc.SetVariable "PDMODE", 35
acadDoc.SetVariable "PDSIZE", -4
Dim pt1(0 To 2) As Double
pt1(0) = x1: pt1(1) = y1: pt1(2) = 0
Set pointobj = acadDoc.ModelSpace.AddPoint(pt1)

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

this new wordpress editor inserts too much html into the code.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s