Sharedminimal8_3dmodel.ipynbOpen in CoCalc
Authors: Samuel Lelièvre, Alba Marina Malaga Sabogal
Views : 50
Description: Akiyama 8-polyhedron

Verify version as stl export works only if version ≥ 7.6.beta3

In [1]:
version()
'SageMath version 8.9, Release Date: 2019-09-29'

Definition of the polyhedron

Define t as the name for the variable for polynomials of one variable and rational coefficients.

In [2]:
t = polygen(QQ,'t')

Define Fw(t)Q[t]F_w(t)∈ℚ[t] where Fw(t)=840t32t2+268t314t4+378t5916t6+874t7265t8314t9+374t10150t11+21t12F_w(t) = 8 − 40t − 32t^2 + 268t^3 − 14t^4 + 378t^5 − 916t^6 + 874t^7 − 265t^8 − 314t^9 + 374t^{10} − 150t^{11} + 21t^{12}

In [3]:
Fw = \ 8 - 40*t - 32*t^2 + 268*t^3 - 14*t^4 + 378*t^5 - 916*t^6 + 874*t^7 \ - 265*t^8 - 314*t^9 + 374*t^10 - 150*t^11 + 21*t^12

Compute the roots of FwF_w in the set 𝔸𝔸 of Q-algebraic real numbers.

In [4]:
Rw = Fw.roots(AA,multiplicities=false)

Define ww as the third root.

In [5]:
w = Rw[2]; w
2.042801338284120?

Define Fx2(t)Q[t]F_{x^2}(t)∈ℚ[t] where Fx2(t)=1500625+246891400t6498924184t2+197676252320t3549916476544t4+9593743607488t537068998078592t6+43451585720832t7+6412940883200t847369088623616t9+34505601388544t1010887830962176t11+1413638553600t12F_{x^2}(t) = − 1500625 + 246891400t − 6498924184t^2 + 197676252320t^3 − 549916476544t^4 + 9593743607488t^5 − 37068998078592t^6 + 43451585720832t^7 + 6412940883200t^8 − 47369088623616t^9 + 34505601388544t^{10} − 10887830962176t^{11} + 1413638553600t^{12}

In [6]:
Fx2= \ -1500625 + 246891400*t - 6498924184*t^2 + 197676252320*t^3 - \ 549916476544*t^4 + 9593743607488*t^5 - 37068998078592*t^6 + \ 43451585720832*t^7 + 6412940883200*t^8 - 47369088623616*t^9 + \ 34505601388544*t^10 - 10887830962176*t^11 + 1413638553600*t^12

Compute the roots of Fx2F_{x^2} in the set 𝔸𝔸 of Q-algebraic real numbers and define xx as the square root of the largest root of Fx2F_{x^2}.

In [7]:
Rx2 = Fx2.roots(AA, multiplicities=false) x = sqrt(Rx2[-1]); x
1.535252427655712?

Define Fz2(t)Q[t]F_{z^2}(t)∈ℚ[t] where Fz2(t)=881721+14088624t507815656t2+22228266304t3345876361600t4+2163078191936t55229062814592t6+2885777661952t7+604100406528t8+284044459008t91111813844992t10+65086242816t11+157070950400t12F_{z^2}(t) = − 881721 + 14088624t − 507815656t^2 + 22228266304t^3 − 345876361600t^4 + 2163078191936t^5 − 5229062814592t^6 + 2885777661952t^7 + 604100406528t^8 + 284044459008t^9 − 1111813844992t^{10} + 65086242816t^{11} + 157070950400t^{12}

In [8]:
Fz2 = ( -881721 + 14088624*t - 507815656*t^2 + 22228266304*t^3 - 345876361600*t^4 + 2163078191936*t^5 - 5229062814592*t^6 + 2885777661952*t^7 + 604100406528*t^8 + 284044459008*t^9 - 1111813844992*t^10 + 65086242816*t^11 + 157070950400*t^12 )

Compute the roots of Fz2F_{z^2} in the set 𝔸𝔸 of Q-algebraic real numbers and define zz as the square root of the second largest root of Fz2F_{z^2}.

In [9]:
Rz2 = Fz2.roots(AA,multiplicities=false) z = sqrt(Rz2[-2]);z
0.4766141791981877?

Define the polyhedron PP as the convex hull of the following set of points:
{(z,0,w),(z,0,w),(x,1,0),(x,1,0),(z,w,0),(z,w,0),(x,0,1),(x,0,1)}\{(z,0,w), (z,0,−w), (x,1,0), (x,−1,0), (−z,w,0), (−z,−w,0), (−x,0,1), (−x,0,−1)\}

In [10]:
vertices=[vector([z,0,w]), vector([z,0,-w]), vector([x,1,0]), vector([x,-1,0]), vector([-z,w,0]), vector([-z,-w,0]), vector([-x,0,1]), vector([-x,0,-1])] P = Polyhedron(vertices)

Plot PP as SageMath's stl export works only from graphics objects

In [ ]:
G=P.plot(aspect_ratio=1, viewer='threejs', online=True)
In [ ]:
G

G is a group of graphical objects. The last element in the group is an IndexFaceSet and can be saved to stl file.

In [ ]:
G.all[-1].save('akiyama8hull.stl')

Search good position for the printing.

The 3d printer cannot print on air. That's why any polyhedron passed to the printer should be lying down on one of it's faces. Slicer software, which helps to convert stlfiles to the gcodeneeded by the printer can usually take care of this step. But as we had some troubles with our slicing step, we also tried to put the polyhedron in a correct position before slicing it.

Option 1 : Cut in two parts

A first try could be to try to cut by a horizontal plane. Then, the two parts are the same because of the symmetries of the polyhedron and the top half is lying flat.

In [ ]:
vertices_top=[[z,0,w], [x,1,0], [x,-1,0], [-z,w,0], [-z,-w,0], [-x,0,1], [-x,0,0]] P_top = Polyhedron(vertices_top) G_top=P_top.plot(aspect_ratio=1) G_top.all[-1].save('akiyama8hull_top.stl')

Unfortunately this cut did not work out well in printing because the very top corner is too sharp. The 3d printer has usually some troubles with cusps pointing upwards.

Option 2 : Rotate the polygon to put it flat

Compute the normal vector of the face that will be put flat

In [ ]:
f = P.faces(2)[0] #The first face in the list of 2-faces of P r1 = vector([x,1,0])-vector([z,0,w]) r2 = vector([x,-1,0])-vector([z,0,w]) n = r1.cross_product(r2)
In [ ]:
r2 = r2-r2.dot_product(r1)*r1/r1.dot_product(r1) #r2 made orthogonal to r1 r1 = r1/r1.dot_product(r1).sqrt() #normalized r1 r2 = r2/r2.dot_product(r2).sqrt() #normalized r1 n = n/n.dot_product(n).sqrt() #normalized n M = matrix (3,3,[r1,r2,n])
In [ ]:
M*P
In [ ]:
flattened_vertices = [M*v for v in vertices];
In [ ]:
flattened_vertices
In [ ]:
# flattened_P=Polyhedron(flattened_vertices) # commented out because something does not work here,

Option 3 : Ask Slic3r to do the job.

Unfortunately, the graphical interface of the recent version of Slic3r do not work on (my) Linux Debian. Using it from the command line turned out to be not really evident.
This is kind of sad because Slic3r's has a handy "Lay flat" button which works very well - at least for objects with low number of faces, as this one.
This finally worked – on a borrowed Windows computer…