L
liugaohui
Unregistered / Unconfirmed
GUEST, unregistred user!
已知的分形维数D,要画出分形图,有多种方法可以实现。这里我用科赫曲线的推广形式来解决。用VB写的“IFS方法”的程序非常的简单,如下:Private Sub Command1_Click()Const pi = 3.1415926535Const k = 0.5Picture1.Scale (-k, 1 + k)-(1 + k, -k)Picture1.Line (0, 0)-(1, 1), RGB(255, 0, 0), BDim a, b, x, y As DoubleDim mx, my As DoubleDim D, r, h, the As DoubleD = 1.583 '已知的分形维数r = 1 / Exp(Log(2) / D)h = Sqr(r ^ 2 - 0.25)the = Atn(2 * h)Dim i As Long x = 0 y = 0 For i = 1 To 150000 a = Rnd * 2 If a < 1 Then mx = r * (Cos(the) * x - Sin(the) * y) my = r * (Sin(the) * x + Cos(the) * y) x = mx y = my ElseIf a >= 1 And a < 2 Then mx = r * (Cos(-the) * x - Sin(-the) * y) + 0.5 my = r * (Sin(-the) * x + Cos(-the) * y) + h x = mx y = my End If Picture1.PSet (x, y) Next iEnd Subhttp://www.fractal.cn/bbs/ShowPost.asp?ThreadID=623谢谢!