;### Set visualization backend prefer 'jreality'; ;### polytope visualization $oct = cross(3); $oct_trunc = truncation($oct,All); $oct_trunc->VISUAL; ;### Visualizing the truncation compose($oct->VISUAL\n\n\n,$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; ;### 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 cube(3)->VISUAL(FacetColor=>"green"); @color=split(" ","red red red red blue blue blue blue"); cube(3)->VISUAL(VertexColor=>\@color); $soccerball = load("~/workshop2012/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); ;### Tight spans $ts = load("~/workshop2012/bees.poly"); $ts->VISUAL_BOUNDED_GRAPH->EDGE_COLORS; $ts->VISUAL_TIGHT_SPAN; ;### Tropical polytopes application 'tropical'; $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); ;### LaTeX Export ;## PDF 3D import prefer('sketch'); cube(3)->VISUAL; cube(4)->SCHLEGEL(ZOOM=>"0.5"); script("visual_normal_fan",$oct_trunc); $oct_trunc->VISUAL(ViewPoint=>[1,1,1], ViewDirection=>[0,0,0], ViewUp=>[0,0,1]); sketch($oct_trunc->VISUAL(ViewPoint=>[1,1,1], ViewDirection=>[0,0,0], ViewUp=>[0,0,1]), File=>"~/workshop2012/oct_trunk.sk");