## Plotting Icosahedron in Polymake

General discussion on polymake goes here.
goz
Posts: 4
Joined: 15 Apr 2024, 03:39

### Plotting Icosahedron in Polymake

Hello,

I generally use GAP, but because GAP lacks visualization capabilities, I recently started exploring polymake for plotting purposes. What I want to achieve is plotting the icosahedral group (regular icosahedron) and the binary icosahedral group. With this aim, I have some questions:

Is there any direct access to these two groups in polymake? By this, I mean that, for example, in GAP, you can simply say g:=SL(2,5) and access the group and its generators easily. Is such a thing possible in polymake?

I am trying to plot a regular icosahedron just like in the following image: https://en.wikipedia.org/wiki/Regular_i ... angles.svg and I have the following code:

Code: Select all

use application 'polytope'; my $phi = (1 + sqrt(5)) / 2; # Define the vertices of an icosahedron my$v = new Matrix<Rational>([ [-1, 0, 0], [1, 0, 0], [0, -1, 0], [0, 1, 0], [0, 0, -1], [0, 0, 1], [0, -1/$phi, -$phi], [0, 1/$phi, -$phi], [0, -1/$phi,$phi], [0, 1/$phi,$phi], [-1/$phi, -$phi, 0], [1/$phi, -$phi, 0], [-1/$phi,$phi, 0], [1/$phi,$phi, 0], [-$phi, 0, -1/$phi], [$phi, 0, -1/$phi], [-$phi, 0, 1/$phi], [$phi, 0, 1/$phi], [-$phi, -1/$phi, 0], [$phi, -1/$phi, 0], [-$phi, 1/$phi, 0], [$phi, 1/$phi, 0], ]); # Define the faces of the icosahedron my $f = new Matrix<Rational>([ [0, 8, 4], [0, 5, 10], [0, 4, 5], [0, 10, 11], [0, 11, 8], [1, 6, 9], [1, 7, 6], [1, 9, 11], [1, 10, 7], [1, 11, 10], [2, 7, 9], [2, 8, 3], [2, 6, 7], [2, 9, 3], [2, 3, 8], [3, 4, 8], [3, 9, 4], [3, 6, 4], [3, 5, 6], [3, 10, 5] ]); # Create the icosahedron my$P = new Polytope(POINTS=>$v, FACETS=>$f); # Visualize the icosahedron $P->VISUAL;  However, the code only shows a single face rather than the entire figure. Then I modified the code as follows: Code: Select all use application 'polytope'; # Define rotation matrices for the icosahedral group my @rotations; for (my$i = 0; $i < 3;$i++) { for (my $j = 0;$j < 3; $j++) { next if$i == $j; for my$sign (1, -1) { my $mat = new Matrix<Rational>([ [$i == 0 ? $sign : 0,$j == 1 ? $sign : 0,$i == 2 ? $sign : 0], [$i == 1 ? $sign : 0,$j == 2 ? $sign : 0,$j == 0 ? $sign : 0], [$j == 2 ? $sign : 0,$i == 0 ? $sign : 0,$j == 1 ? $sign : 0] ]); push @rotations,$mat; } } } # Define vertices of an icosahedron my $v = new Matrix<Rational>([ [-1, 0, 0], [1, 0, 0], [0, -1, 0], [0, 1, 0], [0, 0, -1], [0, 0, 1] ]); # Create the icosahedron my$P = new Polytope(POINTS=>$v); # Apply the rotation matrices to the vertices of the icosahedron for my$rot (@rotations) { my @transformed_vertices; for my $i (0 ..$v->rows - 1) { my $vertex =$v->row($i); my$transformed_vertex = $vertex *$rot; # Calculate the magnitude of the transformed vertex my $magnitude = sqrt($transformed_vertex->[0]**2 + $transformed_vertex->[1]**2 +$transformed_vertex->[2]**2); # Check if the magnitude is not zero if ($magnitude > 0) { push @transformed_vertices,$transformed_vertex; } } # Create a new Polytope with the transformed vertices and visualize it my $transformed = new Polytope(POINTS=>\@transformed_vertices);$transformed->VISUAL; } 
Unfortunately, I couldn't make this work either. Therefore, I would like to ask how to plot a regular icosahedron in polymake.

joswig
Main Author
Posts: 288
Joined: 24 Dec 2010, 11:10

### Re: Plotting Icosahedron in Polymake

To show the regular icosahedron you can just use

Code: Select all

icosahedron()->VISUAL; 
or

Code: Select all

icosahedron()->VISUAL_GRAPH; 
if you only want to see the vertices and the edges.

What you will get exactly will depend on the configuration of your setup, the default backend being threejs.
To show the four planes additionally you would need to visualize them seperately and use compose on the lot.

Please consult this tutorial for more details.

goz
Posts: 4
Joined: 15 Apr 2024, 03:39

### Re: Plotting Icosahedron in Polymake

Thank you !
It worked. I am now able to play with colors, fonts and everything. Thanks a lot. I will plot the icosahedrons with rectangles now
Some little questions:
1) Is there any easy way to save the plot via script? SO far I have tried these but none of them worked for me:

Code: Select all

$ico->VISUAL->output("icosahedron.png"); Code: Select all $ico->VISUAL->write_to_file("icosahedron.png");
2) Is there any easy way to access binary icosahedral. Same way of writing icosahedron()->VISUAL, I would love to plot binary icosahedron. I have tried to run:

Code: Select all

binary_icosahedron()->VISUAL;

Code: Select all

SL(2,5)->VISUAL;
none of them worked. Then, I found that I can use:

Code: Select all

regular_600_cell()->VISUAL;
, but is this the only way for binary icosahedrals?

Thank you