Cartesian form

Capture_11-17-2015-2


Option Explicit

Sub init_rect()
Call connect_acad
Xmin = frm_rect.txt_xmin
Xmax = frm_rect.txt_xmax
X_inc = frm_rect.txt_xinc
A = 0
B = 0
C = 0
D = 0
E = 0
F = 0
End Sub

Sub draw_rect(funcname As String)
'Call connect_acad
Dim X As Double, Y As Double
Dim plineobj As AcadLWPolyline
Dim pt() As Double
Dim i As Integer, numpts As Integer

numpts = (Xmax - Xmin) / X_inc 'number of line segments
numpts = numpts + 1 'one more pt than line segment
ReDim pt(1 To numpts * 2) 'store x and y for one pt

For i = 1 To numpts
X = Xmin + ((i - 1) * X_inc)
Y = Application.Run(funcname, X)
pt(i * 2 - 1) = X: pt(i * 2) = Y
Next i

Set plineobj = acadDoc.ModelSpace.AddLightWeightPolyline(pt)
Update

If frm_rect.chk_box_label_graph = True Then
label_graph
End If

End Sub

Function C_02(X As Double) As Double
'Y = AX ^ 2 + BX + C
C_02 = A * (X ^ 2) + B * X + C
End Function

Function C_03(X As Double) As Double
'Y = A * (X ^ 3) + B * (X ^ 2) + C * X + D
C_03 = A * (X ^ 3) + B * (X ^ 2) + C * X + D
End Function

Function C_04(X As Double) As Double
'Y = A * (X ^ 4) + B * (X ^ 3) + C * (X ^ 2) + D * X + E
C_04 = A * (X ^ 4) + B * (X ^ 3) + C * (X ^ 2) + D * X + E
End Function

Function C_06(X As Double) As Double
'Y = A * (B ^ X) / A * (B ^ X)
C_06 = (A * (X ^ 2) + B * X + C) / (D * (X ^ 2) + E * X + F)
End Function

Function C_07(X As Double) As Double
'Y = A * (B ^ X)
C_07 = A * (B ^ X)
End Function

Sub draw_c02()
Call init_rect
funcname = "C_02"
On Error Resume Next
A = frm_rect.txt_a2.Value
B = frm_rect.txt_b2.Value
C = frm_rect.txt_c2.Value
strLabel = "Y= " & A & "X^2 + " & B & "X + " & C
Call draw_rect(funcname)
End Sub

Sub draw_c03()
Call init_rect
funcname = "C_03"
On Error Resume Next
A = frm_rect.txt_a3.Value
B = frm_rect.txt_b3.Value
C = frm_rect.txt_c3.Value
D = frm_rect.txt_d3.Value
strLabel = "Y= " & A & "X^3 + " & B & "X^2 + " & C & "X + " & D
Call draw_rect(funcname)
End Sub

Sub draw_c04()
Call init_rect
funcname = "C_04"
On Error Resume Next
A = frm_rect.txt_a4.Value
B = frm_rect.txt_b4.Value
C = frm_rect.txt_c4.Value
D = frm_rect.txt_d4.Value
E = frm_rect.txt_e4.Value
strLabel = "Y= " & A & "X^4 + " & B & "X^3 + " & C & "X^2 + " & D & "X +" & E
Call draw_rect(funcname)
End Sub

Sub draw_c06()
Call init_rect
funcname = "C_06"
On Error Resume Next
A = frm_rect.txt_a6.Value
B = frm_rect.txt_b6.Value
C = frm_rect.txt_c6.Value
D = frm_rect.txt_d6.Value
E = frm_rect.txt_e6.Value
F = frm_rect.txt_f6.Value

strLabel = "Y= " & A & "X^2 + " & B & "X + " & C
strLabel = strLabel & " / " & D & "X^2 + " & E & "X + " & F
Call draw_rect(funcname)
End Sub

Sub draw_c07()
Call init_rect
funcname = "C_07"
On Error Resume Next
A = frm_rect.txt_a7.Value
B = frm_rect.txt_b7.Value
strLabel = "Y= " & A & "*" & B & "^X"
Call draw_rect(funcname)
End Sub

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