1 | initial version |
var("x y z")
P = vector((x,y,z))
eqns = [ x==-1, x==1, y==-1, y==1, z==-1, z==1 ]
#eqns = [ z==0, x+y+z ==1, -x+y+z == 1, -x-y+z==1, x-y+z==1]
indizes = range(len(eqns))
vertices = []
for C in combinations(indizes,3):
lse = [eqns[i] for i in C]
sol = solve(lse,x,y,z,solution_dict=True)
if sol:
vertices.append(P.substitute(sol[0]))
#for V in vertices: print V
"draw the solid start with vertices"
G = point3d(vertices,size=10,color='red')
" faces "
for eq in eqns:
poly = []
for V in vertices:
if(eq.substitute({x:V[0],y:V[1],z:V[2]})):
if not V in poly:
poly.append(V)
"""TODO poly should be convex"""
shuffle(poly)
# print poly
try:
G += polygon(poly,alpha=0.5,color=(random(),random(),random()))
except:
pass
G.show(aspect_ratio=1)
2 | No.2 Revision |
var("x y z")
P = vector((x,y,z))
eqns = [ x==-1, x==1, y==-1, y==1, z==-1, z==1 ]
#eqns = [ z==0, x+y+z ==1, -x+y+z == 1, -x-y+z==1, x-y+z==1]
indizes = range(len(eqns))
vertices = []
for C in combinations(indizes,3):
lse = [eqns[i] for i in C]
sol = solve(lse,x,y,z,solution_dict=True)
if sol:
vertices.append(P.substitute(sol[0]))
#for V in vertices: print V
"draw the solid - start with vertices"
G = point3d(vertices,size=10,color='red')
" faces "
for eq in eqns:
poly = []
for V in vertices:
if(eq.substitute({x:V[0],y:V[1],z:V[2]})):
if not V in poly:
poly.append(V)
"""TODO poly should be convex"""
shuffle(poly)
# print poly
try:
G += polygon(poly,alpha=0.5,color=(random(),random(),random()))
except:
pass
G.show(aspect_ratio=1)
3 | No.3 Revision |
var("x y z")
P = vector((x,y,z))
eqns = [ x==-1, x==1, y==-1, y==1, z==-1, z==1 ]
#eqns = [ z==0, x+y+z ==1, -x+y+z == 1, -x-y+z==1, x-y+z==1]
indizes = range(len(eqns))
vertices = []
for C in combinations(indizes,3):
lse = [eqns[i] for i in C]
sol = solve(lse,x,y,z,solution_dict=True)
if sol:
vertices.append(P.substitute(sol[0]))
#for V in vertices: print V
"draw the solid - start with vertices"
G = point3d(vertices,size=10,color='red')
" faces "
for eq in eqns:
poly = []
for V in vertices:
if(eq.substitute({x:V[0],y:V[1],z:V[2]})):
if not V in poly:
poly.append(V)
"""TODO poly should be convex"""
shuffle(poly)
# print poly
try:
G += polygon(poly,alpha=0.5,color=(random(),random(),random()))
except:
pass
G.show(aspect_ratio=1)