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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
# 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.
#-------------------------------------------------------------------------------
###############################################################################
#
# Visual::PointSet - a cloud of points
#
package Visual::PointSet;
use Polymake::Struct (
[ '@ISA' => 'Visual::Object' ],
# [ "coord vector", ... ]
[ '$Vertices | Points' => 'check_points(#%)', default => 'croak("Points missing")' ],
# ambient dimension
[ '$Dim' => '$this->Vertices->cols' ],
# [ "string", ... ]
# or "hidden" suppress any labels
# default: point indices (0,1,...) as labels
[ '$VertexLabels | PointLabels' => 'unify_labels(#%)', default => 'undef' ],
[ '$VertexColor | PointColor' => 'unify_decor(#%)', merge => 'unify_decor(#%)', default => '$Visual::Color::vertices' ],
[ '$VertexThickness | PointThickness' => 'unify_decor(#%)', merge => 'unify_decor(#%)', default => '1' ],
[ '$VertexBorderColor | PointBorderColor' => 'unify_decor(#%)', merge => 'unify_decor(#%)', default => 'undef' ],
[ '$VertexBorderThickness | PointBorderThickness' => 'unify_decor(#%)', merge => 'unify_decor(#%)', default => 'undef' ],
# recognized values:
# "hidden" draw neither circles nor point labels
[ '$VertexStyle | PointStyle' => 'unify_decor(#%)', merge => 'unify_decor(#%)', default => 'undef' ],
# boolean: don't show this object at the session start (only makes sense for interactive viewers)
[ '$Hidden' => '#%' ],
# View and Scale options for packages like Sketch capable of rendering 3-d prictures.
# Default values correspond the standard camera position in jReality.
[ '$ViewPoint' => '#%', default => '[0, 0, 1]' ],
[ '$ViewDirection' => '#%', default => '[0, 0, 0]' ],
[ '$ViewUp' => '#%', default => '[0, 1, 0]' ],
[ '$Scale' => '#%', default => '1' ],
[ '$LabelAlignment' => '#%', default => '"left"'],
# An option to prevent objects from exploding in threejs (if set to 0)
[ '$Explodable' => '#%', default => '1'],
);
# inverse transformation matrix, defaults pkg => (ViewPoint, ViewDirection, ViewUp, Scale)
sub transform2view {
my ($self, $inv_transform, $defaults_pkg)=@_;
( !Struct::is_default($self->ViewPoint)
? $self->ViewPoint :
defined($inv_transform)
? ($inv_transform * new Vector<Float>(1., @{$self->ViewPoint}))->slice(range_from(1))
: *{$defaults_pkg->{view_point}}{ARRAY}
),
( !Struct::is_default($self->ViewDirection)
? $self->ViewDirection :
defined($inv_transform)
? ($inv_transform * new Vector<Float>(1., @{$self->ViewDirection}))->slice(range_from(1))
: *{$defaults_pkg->{view_direction}}{ARRAY}
),
( !Struct::is_default($self->ViewUp)
? $self->ViewUp :
defined($inv_transform)
? ($inv_transform * new Vector<Float>(0., @{$self->ViewUp}))->slice(range_from(1))
: *{$defaults_pkg->{view_up}}{ARRAY}
),
( !Struct::is_default($self->Scale)
? $self->Scale :
defined($inv_transform)
? do {
my $ray=new Vector<Float>(0, 1, 1, 1);
my $img=$inv_transform*$ray;
$self->Scale * sqrt(3. / ($img*$img))
}
: ${$defaults_pkg->{scale}}
)
}
1
# Local Variables:
# mode:perl
# cperl-indent-level:3
# indent-tabs-mode:nil
# End:
|