Polar Coordinate Graphing

Polar Coordinates – P(R,Ɵ) – A point is defined by how far it is from the origin (R – Radius) and what angle (Ɵ – Theta) a line from the point to the origin make with the horizontal axis.

Rectangular Coordinates – P(X,Y) – A point is defined by how far it is from the horizontal (X) and vertical (Y) axes.

Capture_10-31-2015-2

Capture_10-31-2015-3

Capture_10-31-2015-4

Capture_10-31-2015-5

CARTESIAN LOOPS
LOOP NUMBER OF LINE SEGMENTS – CALC TWO POINTS and DRAW LINE EVERY TIME THRU LOOP
Point (X , Y)
‘Xmin, Xmax and X_inc are driving the loop
num_line_segments = (Xmax – Xmin) / X_inc
For i = 1 to num_line_segments
X1 = Xmin + (i – 1) * X_inc
X2 = Xmin + (i * X_inc)
Y1 = f(X1)
Y2 = f(X2)
Call line(X1, Y1, X2, Y2)
Next i

LOOP NUMBER OF POINTS – CALC AND ADD POINT TO ARRAY EVERY TIME THRU LOOP
num_line_segments = (Xmax – Xmin) / X_inc
numpts = num_Line_segments + 1
Redim pt ( 1 To numpts *2) ‘ an index location in the array for all X and Y values
For i = 1 to numpts
X = Xmin + (i – 1) * X_inc
Y = f(X)
pt(i * 2 – 1) = X
pt(i * 2) = Y
Next i
Set plineobj = AddLightWeightPolyline(pt)

POLAR LOOPS
LOOP NUMBER OF LINE SEGMENTS – CALC TWO POINTS and DRAW LINE EVERY TIME THRU LOOP
Point (R , A)
R is Radius (distance), A is Angle in degrees – typ values might be 0 to 360 inc by 1
‘Amin, Amax and A_inc are driving the loop
num_line_segments = (Amax – Amin) / A_inc
For i = 1 to num_line_segments
A1 = Amin + (i – 1) * A_inc
A2 = Amin + (i * A_inc)
R1 = f(A1))
R2 = f(A2))
Call line_polar(R1, A1, R2, A2)
‘if the function allows, line_polar can do the degrees to radian conversion
Next

LOOP NUMBER OF POINTS – CALC AND ADD POINT TO ARRAY EVERY TIME THRU LOOP
num_line_segments = (Amax – Amin) / A_inc
numpts = num_Line_segments + 1
Redim pt ( 1 To numpts *2) ‘size the array for all X and Y values
For i = 1 to numpts
A = Amin + (i – 1) * A_inc
A_rad=deg2rad(A) ‘create a radian value for A
R = f(A_rad) ‘function goes here
‘conversion of Polar to Cartesian coordinates
X= R * Cos(A_rad)
Y = R * Sin(A_rad)
pt(i * 2 – 1) = X
pt(i * 2) = Y
Next i
Set plineobj = AddLightWeightPolyline(pt)

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