;### Set visualization backend prefer 'jreality'; ;### polytope visualization $oct = cross(3); $oct_trunc = truncation($oct,All); $oct_trunc->VISUAL; ;### Visualizing the truncation compose($oct->VISUAL,$oct_trunc->VISUAL); compose($oct->VISUAL(FacetStyle=>"hidden",VertexStyle=>"hidden"),$oct_trunc->VISUAL); $oct_trunc->VISUAL->TRIANGULATION; ;### Visualizing lattice points $oct_trunc->VISUAL->LATTICE; $T = new Matrix([ [1/2, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]); $oct_scaled = new Polytope(VERTICES => ($oct_trunc->VERTICES)*$T); $oct_scaled->VISUAL->LATTICE_COLORED; ;### Visualizing in higher dimensions $cr4 = cross(4); $cr4_trunc = truncation($cr4,All); $cr4_trunc->VISUAL_GRAPH; ;### Visualizing with linear objective print $cr4_trunc->VERTICES_IN_FACETS; print rows_numbered($cr4_trunc->VERTICES_IN_FACETS); $lp = new LinearProgram(LINEAR_OBJECTIVE=>${$cr4_trunc->FACETS}[16]); $cr4_trunc->LP = $lp; $cr4_trunc->VISUAL_GRAPH->VERTEX_COLORS; $l = $lp->LINEAR_OBJECTIVE; $cr4_trunc->VISUAL_GRAPH(NodeLabels=> sub { my $i = shift; my $v = ${$cr4_trunc->VERTICES}[$i]; my $val = $l*$v; return $val;} )->VERTEX_COLORS; ;### Changing face colors $soccerball = load("soccerball.poly"); $soccerball->VISUAL(FacetColor => sub { $i = shift; $s = ${$soccerball->VERTICES_IN_FACETS}[$i]; if($s->size == 5) { return "black"; } else { return "white"; } }); rand_sphere(3,100)->VISUAL(FacetColor => sub { return new RGB(rand,rand,rand); }, VertexColor => sub { return new RGB(rand,rand,rand); }, EdgeStyle => "hidden"); ;### Schlegel diagrams $cr4_trunc->SCHLEGEL(ZOOM=>".6"); $oct_trunc->SCHLEGEL(ZOOM=>".5")->CONSTRUCTION; compose($oct_trunc->SCHLEGEL(ZOOM=>".5",EdgeColor=>"orange")->CONSTRUCTION, $oct_trunc->SCHLEGEL(ZOOM=>".7")->CONSTRUCTION); $cr4_trunc->SCHLEGEL(ZOOM=>".5")->SOLID(FacetTransparency=>".9"); ;### Tight spans $ts = load("bees.poly"); $ts->VISUAL_BOUNDED_GRAPH->EDGE_COLORS; ;### Tropical polytopes application 'tropical'; $tcyc = cyclic(3,5); $tcyc->VISUAL_PSEUDOVERTEX_GRAPH; $ths = new TropicalHypersurface(MONOMIALS=>[[1,1,2,1],[0,1,3,1],[0,3,2,0],[1,2,1,1]],COEFFICIENTS=>[1,3,2,2]); $ths->VISUAL; ;### Fans application 'fan'; $nf = normal_fan($oct_trunc); $nf->VISUAL; script("visual_normal_fan",$oct_trunc);