Friday, April 25

Koch Snowflake 3D_02

























The last script was built to assemble a one degree bigger 3D Koch Snowflake from a picked base flake. If you change the loop contained in it with this one here, you will have a randomly growing snowflake accumulation...! Also, I added a function preventing snowflakes from being copied in positions that are already occupied by other flakes.

If you'd like to try out increasing the max. i value, go ahead! - but I told you beware of your graphics RAM...

__
EnableRedraw (False)
'''''''''''''''''''''''''''''''''''''''''''''''
For i = 0 To 50
For j = 0 To 5
ReDim Preserve arrVec(n)
ReDim Preserve arrFlakes(n)
If i = 0 And (Rnd > 0.5) Then
arrVec(n) = PointAdd (arrFlakeBase, arrReloc(j))
arrFlakes(n) = CopyObject (strFlake0, arrFlakeBase, arrVec(n))
n = n + 1
ElseIf n >= 1 And (Rnd > 0.5) Then
arrVec(n) = PointAdd (arrVec(n-1), arrReloc(j))
If functOccupied (arrVec, n) = False Then
arrFlakes(n) = CopyObject (strFlake0, arrFlakeBase, arrVec(n))
n = n + 1
End If
End If
Next
Next
'''''''''''''''''''''''''''''''''''''''''''''''
EnableRedraw (True)


'''''''''''''''''''''''''''''''''''''''''''''''
Function functOccupied (arrVec, n)
Dim k
functOccupied = False

For k = 0 To Ubound (arrVec) - 1
If PointCompare (arrVec(k), arrVec(n)) = True Then
functOccupied = True
Exit For
End If
Next

End Function
'''''''''''''''''''''''''''''''''''''''''''''''


No comments: