Fractals: Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Mindraker (Category:Player Created) |
>Mindraker No edit summary |
||
Line 28: | Line 28: | ||
p = Instance.new("Part") | p = Instance.new("Part") | ||
p.CFrame = CFrame.new(Vector3.new(x,1.8,z)) | 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 | |||
</pre> | |||
== 3D Sierpinsky Triangle == | |||
[[Image:3D Sierpinsky Triangle.PNG|thumb|3D Sierpinsky Triangle]] | |||
<b>WARNING</b> This can freeze up your computer. (My computer could only handle 5000 after about a <b>half hour</b>.) If you have a slow computer, reduce the "For" loop to a lower number, like 500, then work your way up to 1000. | |||
For a better picture of what this is, see the [http://en.wikipedia.org/wiki/Sierpi%C5%84ski_Triangle wikipedia article on Sierpinsky triangles] | |||
<pre> | |||
local x = 0 | |||
local y = 1.8 | |||
local z = 0 | |||
for i = 1, 5000 do | |||
a = math.random(1,8) | |||
if a == 1 then | |||
x = (x - 200)/2 | |||
y = (y - 200)/2 | |||
z = (z + 200)/2 | |||
end | |||
if a == 2 then | |||
x = (x + 200)/2 | |||
y = (y - 200)/2 | |||
z = (z + 200)/2 | |||
end | |||
if a == 3 then | |||
x = (x - 200)/2 | |||
y = (y - 200)/2 | |||
z = (z - 200)/2 | |||
end | |||
if a == 4 then | |||
x = (x + 200)/2 | |||
y = (y - 200)/2 | |||
z = (z - 200)/2 | |||
end | |||
if a == 5 then | |||
x = (x + 0)/2 | |||
y = (y + 200)/2 | |||
z = (z + 0)/2 | |||
end | |||
p = Instance.new("Part") | |||
p.CFrame = CFrame.new(Vector3.new(x,y,z)) | |||
p.Size = Vector3.new(1,1,1) | p.Size = Vector3.new(1,1,1) | ||
p.Anchored = true | p.Anchored = true |
Revision as of 20:12, 16 December 2008
Sierpinsky 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
3D Sierpinsky Triangle
WARNING This can freeze up your computer. (My computer could only handle 5000 after about a half hour.) If you have a slow computer, reduce the "For" loop to a lower number, like 500, then work your way up to 1000.
For a better picture of what this is, see the wikipedia article on Sierpinsky triangles
local x = 0 local y = 1.8 local z = 0 for i = 1, 5000 do a = math.random(1,8) if a == 1 then x = (x - 200)/2 y = (y - 200)/2 z = (z + 200)/2 end if a == 2 then x = (x + 200)/2 y = (y - 200)/2 z = (z + 200)/2 end if a == 3 then x = (x - 200)/2 y = (y - 200)/2 z = (z - 200)/2 end if a == 4 then x = (x + 200)/2 y = (y - 200)/2 z = (z - 200)/2 end if a == 5 then x = (x + 0)/2 y = (y + 200)/2 z = (z + 0)/2 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
Fern leaf
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
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
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
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
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
See Also
Beauty in Mathematics, an introductory article on fractals with helpful images