Sierpinski Tetrahedron Generator
Sierpinski Tetrahedron Generator
hey guys
just asked a friend of mine thomas (lyc.deviantart.com) to build me an app that creates sierpinski tetrahedrons and exports them in .obj format. can be quite useful and can be used to make some pretty cool stuff. here is an image i made quick as an example once again. very nifty! Hope u like
http://www.fractographer.com/binaries/tetra_sierp.zip
greetz
mat
just asked a friend of mine thomas (lyc.deviantart.com) to build me an app that creates sierpinski tetrahedrons and exports them in .obj format. can be quite useful and can be used to make some pretty cool stuff. here is an image i made quick as an example once again. very nifty! Hope u like
http://www.fractographer.com/binaries/tetra_sierp.zip
greetz
mat
- Attachments
-
- im1189534930.png (928.41 KiB) Viewed 6401 times
Last edited by matsta on Wed Sep 12, 2007 8:02 am, edited 2 times in total.
Nice
I wrote one for blender for a comp a while back
http://blenderartists.org/forum/showpos ... ostcount=3
Heres the code if anyone wants it, makes a range of different level gaskets.
Modified to just make one
Kram, it's not too heavy, Takes under a second for a level 6, a few seconds for a level 7 (level 7 = 390k faces). (amd64 3000)
I wrote one for blender for a comp a while back
http://blenderartists.org/forum/showpos ... ostcount=3
Heres the code if anyone wants it, makes a range of different level gaskets.
Code: Select all
import Blender
from Blender import Mesh,Scene
scn=Scene.GetCurrent()
def generate(location, scale, level, currentVerts,currentFaces):
height=2.
x,y,z=location
newVerts,newFaces=[],[]
if level:
scale/=2.0
generate(location,scale,level-1,currentVerts,currentFaces)
generate([x-scale,y-scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x+scale,y-scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x-scale,y+scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x+scale,y+scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
else:
start=len(currentVerts)
currentVerts.extend([[x,y,z],\
[x-scale,y-scale,z-scale*height],\
[x+scale,y-scale,z-scale*height],\
[x+scale,y+scale,z-scale*height],\
[x-scale,y+scale,z-scale*height]])
currentFaces.extend([[start,start+1,start+2],\
[start,start+2,start+3],\
[start,start+3,start+4],\
[start,start+1,start+4],\
[start+1,start+2,start+3,start+4]])
return [currentVerts,currentFaces]
for i in range(6):
v,f=generate([0,0,2],1,i,[],[])
level=Mesh.New(str(i)+'level')
level.verts.extend(v)
level.faces.extend(f)
ob=scn.objects.new(level,'gasket'+str(i))
Code: Select all
import Blender
from Blender import Mesh,Scene
################
# Level of gasket wanted
i=6
# warning: try 5/6 first, it's quite dense already.
################
scn=Scene.GetCurrent()
def generate(location, scale, level, currentVerts,currentFaces):
height=2.
x,y,z=location
newVerts,newFaces=[],[]
if level:
scale/=2.0
generate(location,scale,level-1,currentVerts,currentFaces)
generate([x-scale,y-scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x+scale,y-scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x-scale,y+scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x+scale,y+scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
else:
start=len(currentVerts)
currentVerts.extend([[x,y,z],\
[x-scale,y-scale,z-scale*height],\
[x+scale,y-scale,z-scale*height],\
[x+scale,y+scale,z-scale*height],\
[x-scale,y+scale,z-scale*height]])
currentFaces.extend([[start,start+1,start+2],\
[start,start+2,start+3],\
[start,start+3,start+4],\
[start,start+1,start+4],\
[start+1,start+2,start+3,start+4]])
return [currentVerts,currentFaces]
v,f=generate([0,0,2],1,i,[],[])
level=Mesh.New(str(i)+'level')
level.verts.extend(v)
level.faces.extend(f)
ob=scn.objects.new(level,'gasket'+str(i))
Kram, that's not quite right for mine.
Mine isn't a serpinski tetrahedron one, it's a serpinski gasket based on a square based pyramid. I only just clicked that the OP was different, I just didn't think, sorry.
So mine is 5 faces each, and 5 objects.
Mine goes from level 0 as a pyramid.
So,
Which is why I warn against high levels
Mine isn't a serpinski tetrahedron one, it's a serpinski gasket based on a square based pyramid. I only just clicked that the OP was different, I just didn't think, sorry.
So mine is 5 faces each, and 5 objects.
Mine goes from level 0 as a pyramid.
So,
Code: Select all
level - faces
0 - 5
1 - 25
2 - 125
3 - 625
4 - 3,125
5 - 15,625
6 - 78,125
7 - 390,625
8 - 1,953,125
9 - 9,765,625
10 - 48,828,125
11 - 244,140,625
12 - 1,220,703,125
13 - 6,103,515,625
14 - 30,517,578,125
15 - 152,587,890,625
Which is why I warn against high levels
It's not hard to write, it's just a more general case of my code.
Take my code and replace the hard coded shape by reading in an object from the scene, and have a group of objects showing the replacement rule (so to get what my code does normally, you'd make a square based pyramid, and then place several of those into a level 1 version).
To be honest, I spend 8-10 hours coding a day (then more if I decide to work on anything of my own projects) so unless something really grabs me I tend not to work on it.
Take my code and replace the hard coded shape by reading in an object from the scene, and have a group of objects showing the replacement rule (so to get what my code does normally, you'd make a square based pyramid, and then place several of those into a level 1 version).
To be honest, I spend 8-10 hours coding a day (then more if I decide to work on anything of my own projects) so unless something really grabs me I tend not to work on it.
Who is online
Users browsing this forum: No registered users and 41 guests