Exercise: Points in Motion
Make sure you understand the section on 1-D Arrays, iteration and points. This exercise will help you think how to go about calculating the coordinates of each points in ways that describe interesting shapes. According to wikipedia, for instance, the set of points on a circle can be defined parametrically with the following equations:
and the circumference itself is defined by
Dim radius : radius = 10.0
Dim x, y, z, theta
For theta = 0 to Rhino.Pi()*2 Step 0.1
x = cos(theta)*radius
y = sin(theta)*radius
z = 0
Rhino.AddPoint array(x,y,z)
Next
Dim radius : radius = 10.0
Dim x, y, z, theta
ReDim points1(62)
ReDim points2(62)
Dim thispoint1, thispoint2
For theta = 0 To Rhino.Pi()*2 Step 0.1
'Rhino.Print (theta*10)
x = Cos(theta)*radius
y = Sin(theta)*radius
z = theta*4
points1(theta*10) = Array(x,y,z)
Next
radius = 2.0
For theta = 0 To Rhino.Pi()*2 Step 0.1
x = Cos(theta)*radius
y = Sin(theta)*radius
z = theta*4
points2(theta*10) = Array(x,y,z)
Next
Dim i
For i = 0 To 62
If IsArray(points1(i)) Then
Rhino.Print "Is Array"
Else
Rhino.Print "Not Array"
End If
Rhino.AddPoint points1(i)
Rhino.AddPoint points2(i)
Rhino.AddCurve array( points1(i), points2(i) )
Next
Problem 1
Make sure you understand the code above, take some time and change the variables. What would you need to change in order to make the two spiraling sets of points to be "out of phase"? Can the points be connected differently? What happens if you use a trigonometric function for the Z coordinate? What happens if instead of iterating to Rhino.Pi()*2 you do so to Rhino.Pi()*4? Modify the code and experiment with different parameter values.
Problem 2
Take a mathematically-defined geometric shape (different from the circle) and implement it in RhinoScript using the control flow and data structure we have used so far: For Loops and Arrays. Use the references as sources of material and inspiration. Use only points and lines. If you need a reference for logical operators and mathematical notation check here.
Other Materials and References
Mathematical AlchemyHere you will find scripts for describing this and other geometric shapes.
Archimedean Spirals
http://en.wiki.mcneel.com/default.aspx/McNeel/RsArchimedeanSpiral.html