1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
# Copyright (c) 1997-2024
# Ewgenij Gawrilow, Michael Joswig, and the polymake team
# Technische Universität Berlin, Germany
# https://polymake.org
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version: http://www.gnu.org/licenses/gpl.txt.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#-------------------------------------------------------------------------------
package Visual::Gale;
use Math::Trig;
use Polymake::Struct (
[ '@ISA' => 'Object' ],
[ '$Polytope' => '#%' ],
[ '$VertexLabels' => 'unify_labels(#%)', default => 'undef' ],
'@points',
'@colors',
'$dim',
[ '$different_x_y' => 'new Map<Vector<Float>, Set<Int>>' ],
'%different_angles',
[ '$whites' => 'new Map<Vector<Float>, Int>' ],
[ '$blacks' => 'new Map<Vector<Float>, Int>' ],
'@loops',
'@gale_lines',
);
declare %decorations=( Name => undef, Title => undef, VertexLabels => enum("hidden") );
sub new {
my $self=&_new;
my $Transform=new Matrix<Float>($self->Polytope->GALE_TRANSFORM);
$self->dim=$Transform->cols-1;
# get affine coordinates
my $v=0;
foreach my $gv (@{$self->Polytope->GALE_VERTICES}) {
my $color=$gv->[0];
my $point=$gv->slice(range_from(1));
push @{$self->colors}, $color;
push @{$self->points}, $point;
if ($color) {
if ($self->dim==1) {
my $angle=atan2($Transform->elem($v,1), $Transform->elem($v,0));
push @{$self->different_angles->{$angle}}, $v;
}
$self->different_x_y->{$point} += $v;
if ($color>0) {
$self->whites->{$point}=1;
delete $self->blacks->{$point};
} elsif (!exists $self->whites->{$point}) {
$self->blacks->{$point}=1;
}
} else {
push @{$self->loops}, $v;
}
++$v;
}
# for each facet find a triple of b/w points not belonging to it
foreach my $compl_list (@{~ $self->Polytope->VERTICES_IN_FACETS}) {
my @gale_line=@$compl_list;
if (@gale_line==3) {
push @{$self->gale_lines}, \@gale_line;
}
}
$self;
}
1
# Local Variables:
# cperl-indent-level:3
# indent-tabs-mode:nil
# End:
|