# 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.  ```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

```  ```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

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