05-08-2022, 09:41 AM
(This post was last modified: 05-08-2022, 09:45 AM by TarotRedhand.)
From back in the day and made to work in QB64. All six are just the top level of each of the fractals. Of the six, three are not really suitable for zooming in.
It is said that Benois Mandlebrot used the Cantor Dust fractal to illustrate (to a group of electronic engineers) why just increasing the power of transmitted signals wouldn't illiminate the "random" errors they were observing but that some form of error checking would need to be devised.
Cantor.BAS (Not Zoom)
The second one is the Henon Fractal. This one achieves variety by asking you to input a number. For an interesting result try the value of PI. Not Zoom.
Henon.BAS
If you have a slow machine you may want to edit this one. That is because there is a FOR NEXT loop in it, that loops 20,000,000 times. That number is high in order to show most of the finer detail of this fractal. Watching as it builds has somewhat of a retro feel. Again don't bother adding a zoom feature.
Ikida.BAS
Next, here is the classic Mandlebrot fractal. You can add a zoom to this one if you want.
Mandle.BAS
It is said that for each chaotic point on a Mandlebrot fractal, there is a corresponding Julia fractal. Here is one -
Julia.BAS (Zoom can be added)
Finally we have a pseudo fractal. At least the creator of this said that they didn't think it was really a fractal. You be the judge. A zoom feature can certainly be added and values tweaked repeatedly in order to make an animation.
Topham.BAS
Have fun and see what you can do with these.
TR
It is said that Benois Mandlebrot used the Cantor Dust fractal to illustrate (to a group of electronic engineers) why just increasing the power of transmitted signals wouldn't illiminate the "random" errors they were observing but that some form of error checking would need to be devised.
Cantor.BAS (Not Zoom)
Code: (Select All)
Const Left = 1
Const Right = 640
Screen 2
_FullScreen _SquarePixels
Cls
CantorDust Left, Right, 1
End
Sub CantorDust (Start, Finish, Level)
Y = Level * 20
Line (Start, Y)-(Finish, Y), 1
Length = Finish - Start
If Length < 2 Then
Exit Sub
End If
Third = Length / 3
A = Start + Third - 1
B = 1 + Finish - Third
CantorDust Start, A, Level + 1
CantorDust B, Finish, Level + 1
End Sub
The second one is the Henon Fractal. This one achieves variety by asking you to input a number. For an interesting result try the value of PI. Not Zoom.
Henon.BAS
Code: (Select All)
xc = 320
yc = 240
xmul = 400
ymul = 360
Cls
Input "Enter the value for a"; a
Screen 12
_FullScreen _SquarePixels
Cls
For x = -.1 To .8 Step .05
For y = -.1 To .8 Step .05
x1 = x
y1 = y
For i% = 1 To 1000
If x1 > 1000 Or y1 > 1000 Or x1 < -1000 Or y1 < -1000 Then
i% = 1000
Else
ca = Cos(a)
sa = Sin(a)
yy = y1 - x1 * x1
xx = x1 * ca - yy * sa
y1 = x1 * sa + yy * ca
x1 = xx
PSet (xc + (x1 * xmul), yc + (y1 * ymul)), (i% Mod 17)
End If
Next i%
Next y
Next x
If you have a slow machine you may want to edit this one. That is because there is a FOR NEXT loop in it, that loops 20,000,000 times. That number is high in order to show most of the finer detail of this fractal. Watching as it builds has somewhat of a retro feel. Again don't bother adding a zoom feature.
Ikida.BAS
Code: (Select All)
x = 0
y = 0
p = 7.7
colour = 16
xc = 435
yc = 270
xmul = 240
ymul = 180
MaxColour = 16
Screen 12
_FullScreen _SquarePixels
Cls
For n& = 1 To 20000000
theta = .4 - (p / (1 + (x * x + y * y)))
ctheta = Cos(theta)
stheta = Sin(theta)
Point9x = .9 * x
Point9y = .9 * y
x1 = .85 + Point9x * ctheta - Point9y * stheta
y1 = Point9x * stheta + Point9y * ctheta
PSet (xc + (xmul * -x1), yc + (ymul * y1)), colour
x = x1
y = y1
colour = colour + 1
If colour > MaxColour Then
colour = 1
End If
Locate 6, 1
Print "Iterations = ";
Print Using "##,###,###"; n&;
Next n&
Next, here is the classic Mandlebrot fractal. You can add a zoom to this one if you want.
Mandle.BAS
Code: (Select All)
Const MaxCol% = 17
Const MaxX% = 640
Const MaxY% = 480
Const BailOut = 4!
Const MaxIterations% = 255
AngleR = -2
AngleL = -1.25
Side = 2.5
DistanceX = Side / MaxX%
DistanceY = Side / MaxY%
Screen 12
_FullScreen _SquarePixels
Cls
For Y = 1 To MaxY%
For X = 1 To MaxX%
CR = X * DistanceX + AngleR
CL = Y * DistanceY + AngleL
ZR = CR
ZL = CL
Iteration% = 0
Do
A = ZR * ZR
B = ZL * ZL
Length = A + B
ZL = 2 * ZR * ZL + CL
ZR = A - B + CR
Iteration% = Iteration% + 1
Loop Until Length > BailOut Or Iteration% > MaxIterations%
col = Iteration% Mod MaxCol%
PSet (X, Y), col
Next X
Next Y
It is said that for each chaotic point on a Mandlebrot fractal, there is a corresponding Julia fractal. Here is one -
Julia.BAS (Zoom can be added)
Code: (Select All)
Const MaxCol% = 17
Const LastX% = 640
Const LastY% = 480
Const MaxX% = 400
Const MaxY% = 460
Const BailOut = 4!
Const MaxIterations% = 255
AngleR = -2
AngleL = -1.25
CR = -1
CL = -.625
Side = 2.5
DistanceX = Side / MaxX%
DistanceY = Side / MaxY%
Screen 12
_FullScreen _SquarePixels
Cls
For Y = 1 To LastY%
For X = 1 To LastX%
ZR = X * DistanceX + AngleR
ZL = Y * DistanceY + AngleL
Iteration% = 0
Do
A = ZR * ZR
B = ZL * ZL
Length = A + B
ZL = 2 * ZR * ZL + CL
ZR = A - B + CR
Iteration% = Iteration% + 1
Loop Until Length > BailOut Or Iteration% > MaxIterations%
col = Iteration% Mod MaxCol%
PSet (X, Y), col
Next X
Next Y
Finally we have a pseudo fractal. At least the creator of this said that they didn't think it was really a fractal. You be the judge. A zoom feature can certainly be added and values tweaked repeatedly in order to make an animation.
Topham.BAS
Code: (Select All)
Screen 12
_FullScreen _SquarePixels
Cls
xpos = 320
ypos = 240
across = 640
down = 480
a = -1.5
b = -.5
c = 2.4
d = -.45
e = .5
xmin = -3.5
xmax = 4.5
ymin = -2
ymax = 2
maxiter = 70
cresh = 500
dx = (xmax - xmin) / across
dy = (ymax - ymin) / down
For ynn = 1 To down
For xnn = 1 To across
k = 0
xn = xmin + dx * xnn
yn = ymin + dy * ynn
Do
k = k + 1
xnsqr = xn * xn
ynsqr = yn * yn
If (xnsqr + ynsqr) > cresh Then
GoSub PlotPoint
Exit Do
End If
If k > maxiter Then
Exit Do
End If
xm = a + b * xn + c * ynsqr
yn = d + e * xn
xn = xm
Loop
Next xnn
Next ynn
End
PlotPoint:
Select Case (k Mod 7) + 1
Case 1
col = 12
Case 2
col = 10
Case 3
col = 14
Case 4
col = 9
Case 5
col = 15
Case 6
col = 11
Case 7
col = 13
End Select
PSet (xpos - .5 * across + xnn, ypos - .5 * down + ynn), col
Return
Have fun and see what you can do with these.
TR