Cartesian Graphing

Locating points on a plane using a horizontal and vertical number line, giving each point a location with two numbers, then drawing lines between points, is called graphing with the Cartesian coordinate system. It is a link between algebra and geometry. Its named for Rene Descartes (“I think therefore I am”) who developed one of the first ideas along this line about 1637. Autocad is a Cartesian coordinate graphing system, although normally the lines are not input with algebraic equations.

Two more additions to our function library before we begin with a polar coordinate system.

Capture_10-25-2015-4

Capture_10-25-2015-2

Sub add_sin(a As Double, b As Double, c As Double, d As Double)
'Xmin, Xmax, X_inc already set
'Y = Sin(a * X) + Sin(b * X) + Sin(c * X) + d
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
numpts = numpts + 1
ReDim pt(1 To numpts * 2)

For i = 1 To numpts
X = Xmin + ((i - 1) * X_inc)
Y = Sin(a * X) + Sin(b * X) + Sin(c * X) + d
pt(i * 2 - 1) = X: pt(i * 2) = Y
Next i

Set plineobj = acadDoc.ModelSpace.AddLightWeightPolyline(pt)
Update
strLabel = "Y= Sin " & a & "X + Sin " & b & "X + Sin " & c & "X + " & d
End Sub

Capture_10-25-2015-5

Capture_10-25-2015-3

Sub exp_curve(Xmin As Double, Xmax As Double, a As Double, X_inc As Double)
'y = a^x
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 = a ^ X
pt(i * 2 - 1) = X: pt(i * 2) = Y
Next i

Set plineobj = acadApp.ActiveDocument.ModelSpace.AddLightWeightPolyline(pt)
Update
strLabel = "Y= " & a & "^X"
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