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

1

In [1]:

version()

2

'SageMath version 8.6, Release Date: 2019-01-15'

3

Define `t`

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

4

In [2]:

t = polygen(QQ,'t')

5

Define $F_w(t)∈ℚ[t]$ where $F_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}$

6

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

7

Compute the roots of $F_w$ in the set $𝔸$ of $ℚ$-algebraic real numbers.

8

In [4]:

Rw = Fw.roots(AA,multiplicities=false)

9

Define $w$ as the third root.

10

In [5]:

w = Rw[2]; w

11

2.042801338284120?

Define $F_{x^2}(t)∈ℚ[t]$ where $F_{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}$

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

13

Compute the roots of $F_{x^2}$ in the set $𝔸$ of $ℚ$-algebraic real numbers and define $x$ as the square root of the largest root of $F_{x^2}$.

14

In [7]:

Rx2 = Fx2.roots(AA, multiplicities=false) x = sqrt(Rx2[-1]); x

15

1.535252427655712?

Define $F_{z^2}(t)∈ℚ[t]$ where $F_{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}$

16

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 )

17

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

18

In [9]:

Rz2 = Fz2.roots(AA,multiplicities=false) z = sqrt(Rz2[-2]);z

19

0.4766141791981877?

Define the polyhedron $P$ 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)\}$

20

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)

21

Plot $P$ as SageMath's `stl`

export works only from graphics objects

22

In [33]:

G=P.plot(aspect_ratio=1, viewer='threejs', online=True)

23

In [34]:

G

24

iframe must specify project_id and sha1

`G`

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

file.

25

In [ ]:

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

26

27

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 `stl`

files to the `gcode`

needed 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.

28

29

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.

30

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')

31

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.

32

33

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

34

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)

35

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])

36

In [ ]:

M*P

37

In [ ]:

flattened_vertices = [M*v for v in vertices];

38

In [ ]:

flattened_vertices

39

In [ ]:

# flattened_P=Polyhedron(flattened_vertices) # commented out because something does not work here,

40

41

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…

42