Реализации алгоритмов/Ковёр Серпинского: различия между версиями

Перейти к навигации Перейти к поиску
м
(Lisp from Lee Mac)
 
Dim pointObj As AcadPoint
Dim xlocation(0 To 2) As Double
Dim y As Double
 
Dim i As LongDouble 'Iteration Number
Dim R As Double 'Random Number
location(2) = 0 'Z Coordinate of Chaos
 
For i = 1 To 10000100000
R = Rnd(1)
If R < 0.125 Then
xlocation(0) = (xlocation(0) - 1) / 3 'location(0) = (location(0) - 2*0.5) / 3
ylocation(1) = (ylocation(1) - 0.51) / 3
ElseIf R < 0.25 Then
xlocation(0) = (xlocation(0) - 0.51) / 3
location(1) = location(1) / 3 'location(0) = (location(0) - 2*0) / 3
y = y / 3
ElseIf R < 0.375 Then
xlocation(0) = (xlocation(0) - 0.51) / 3
ylocation(1) = (ylocation(1) + 0.51) / 3
ElseIf R < 0.5 Then
xlocation(0) = xlocation(0) / 3
ylocation(1) = (ylocation(1) + 0.51) / 3
ElseIf R < 0.625 Then
xlocation(0) = (xlocation(0) + 0.51) / 3
ylocation(1) = (ylocation(1) + 0.51) / 3
ElseIf R < 0.75 Then
xlocation(0) = (xlocation(0) + 0.51) / 3
ylocation(1) = ylocation(1) / 3
ElseIf R < 0.875 Then
xlocation(0) = (xlocation(0) + 0.51) / 3
ylocation(1) = (ylocation(1) - 0.51) / 3
Else
xlocation(0) = xlocation(0) / 3
ylocation(1) = (ylocation(1) - 0.51) / 3
End If
 
Set pointObj = ThisDrawing.ModelSpace.AddPoint(CStr(x)+","+CStr(y)location)
Next i
 
ZoomExtents
End Sub

Навигация