Fractals

From Legacy Roblox Wiki
Revision as of 21:32, 16 December 2008 by >Mindraker (Category:Player Created)
Jump to navigationJump to search

Sierpinsky Triangle

Sierpinksy Triangle
x = 0
y = 1.8
z = 0
for i = 1, 4000 do
a = math.random(1,3)

if a == 1 then 
x = x / 2
z = (z - 250)/2
end

if a == 2 then 
x = (x - 250)/2
z = (z + 250)/2
end

if a == 3 then 
x = (x + 250)/2
z = (z + 250)/2
end


p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(x,1.8,z))
p.Size = Vector3.new(1,1,1)
p.Anchored = true
p.Color = Color3.new(1)
p.Parent = game.Workspace
--wait(.1)
end

Fern leaf

Fern leaf fractal
x = 1
y = 1.8
z = 1
for i = 1, 500 do
a = math.random(1,100)

if a == 1 then

x = 0
z = (0.16*z)

elseif a > 1 and a <= 8 then

x = ((0.20*x) - (0.26*z))
z= (0.23*x + 0.22*z + 16)

elseif a > 8 and a <= 15 then

x = ((-0.15*x) + 0.28*z)
z = (0.26*x + 0.24*z + 4.4)

elseif a > 15 and a <= 100 then

x = 0.85*x + 0.04*z
z = ((-0.04*x) + 0.85*z + 16)

end

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(x,1.8,z))
p.Size = Vector3.new(1,1,1)
p.Anchored = true
p.Color = Color3.new(1)
p.Parent = game.Workspace
wait(.1)
end

Cantor set

2D Cantor set
x = 0
y = 1.8
z = 0
for i = 1, 3000 do
a = math.random(1,4)

if a == 1 then 
x = (x - 250)/3
z = (z - 250)/3
end

if a == 2 then 
x = (x - 250)/3
z = (z + 250)/3
end

if a == 3 then 
x = (x + 250)/3
z = (z + 250)/3
end

if a == 4 then 
x = (x + 250)/3
z = (z - 250)/3
end

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(x,1.8,z))
p.Size = Vector3.new(1,1,1)
p.Anchored = true
p.Color = Color3.new(1)
p.Parent = game.Workspace
--wait(.1)
end

3D Cantor set

3D Cantor set

WARNING This can freeze up your computer. If you have a slow computer, reduce the "For" loop to a lower number, like 500, then work your way up to 1000.

local x = 0
local y = 1.8
local z = 0

for i = 1, 2000 do
a = math.random(1,8)

if a == 1 then 
x = (x - 250)/3
y = (y - 250)/3
z = (z - 250)/3
end

if a == 2 then 
x = (x - 250)/3
y = (y - 250)/3
z = (z + 250)/3
end

if a == 3 then 
x = (x - 250)/3
y = (y + 250)/3
z = (z - 250)/3
end

if a == 4 then 
x = (x - 250)/3
y = (y + 250)/3
z = (z + 250)/3
end

if a == 5 then 
x = (x + 250)/3
y = (y + 250)/3
z = (z + 250)/3
end

if a == 6 then 
x = (x + 250)/3
y = (y - 250)/3
z = (z + 250)/3
end

if a == 7 then 
x = (x + 250)/3
y = (y + 250)/3
z = (z - 250)/3
end

if a == 8 then 
x = (x + 250)/3
y = (y - 250)/3
z = (z - 250)/3
end

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(x,y,z))
p.Size = Vector3.new(1,1,1)
p.Anchored = true
p.Color = Color3.new(1)
p.Parent = game.Workspace
--wait(.1)
end

Untitled

Untitled
x = 68
y = 1.8
z = 56
for i = 1, 500 do
a = math.random(1,5)

if a == 1 then 
x = x / 3
z = (z - 57)/3
end

if a == 2 then 
x = (x + 68)/3
z = (z - 13)/3
end

if a == 3 then 
x = (x + 42)/3
z = (z + 58)/3
end

if a == 4 then 
x = (x - 42)/3
z = (z + 58)/3
end

if a == 5 then 
x = (x - 68)/3
z = (z - 13)/3
end

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(x,1.8,z))
p.Size = Vector3.new(1,1,1)
p.Anchored = true
p.Color = Color3.new(1)
p.Parent = game.Workspace
--wait(.1)
end

Untitled2

Untitled
x = 82
y = 1.8
z = 30
for i = 1, 500 do
a = math.random(1,6)

if a == 1 then 
x = (x - 185)/5
z = (z - 300)/5
end

if a == 2 then 
x = (x + 180)/5
z = (z - 300)/5
end

if a == 3 then 
x = (x + 345)/5
z = (z + 5)/5
end

if a == 4 then 
x = (x + 175)/5
z = (z + 300)/5
end

if a == 5 then 
x = (x - 180)/5
z = (z + 300)/5
end

if a == 6 then 
x = (x - 350)/5
z = (z + 5)/5
end

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(x,1.8,z))
p.Size = Vector3.new(1,1,1)
p.Anchored = true
p.Color = Color3.new(1)
p.Parent = game.Workspace
--wait(.1)
end

Other Roblox Fractal images

3D Cantor dust Third iteration of 3D Koch quadratic fractal Square koch 3
Sierpinsky triangle fractal Variation of the Sierpinsky triangle fractal Vicsek fractal
Fractal T Fractal kite

See Also

Wikipedia article on Fractals

Beauty in Mathematics, an introductory article on fractals with helpful images