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 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
# 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.
#-------------------------------------------------------------------------------
object Polytope {
# @category Geometry
# A weighted inner point depending on the outer angle called Steiner point for all faces of dimensions 2 to d.
property STEINER_POINTS : Matrix<Scalar>;
# @category Geometry
# Steiner point of the whole polytope.
property STEINER_POINT : Vector<Scalar>;
rule STEINER_POINTS : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE, \
GRAPH.ADJACENCY, VERTICES, CONE_DIM {
$this->STEINER_POINTS=all_steiner_points($this);
}
precondition : BOUNDED;
weight 6.10;
rule STEINER_POINT : GRAPH.ADJACENCY, VERTICES, CONE_DIM {
$this->STEINER_POINT=steiner_point($this);
}
precondition : BOUNDED;
weight 5.10;
rule STEINER_POINT : STEINER_POINTS {
$this->STEINER_POINT=$this->STEINER_POINTS->[0];
}
weight 0.10;
}
package Visual::Color;
# Steiner points are drawn in blue
custom $steiner_point="0 0 255";
package application;
# Steiner points are drawn thicker than the vertices
custom $steiner_point_thickness=1;
###################################################################################
#
# decoration methods adding Steiner points to various drawings
#
package Visual::Polytope;
# Add the [[Polytope::STEINER_POINTS|STEINER_POINTS]] to the 3-d visualization.
# The facets become transparent.
# @options %Visual::PointSet::decorations
# @return Visual::Polytope
# @example Displays the Steiner points of a random threedimensional sphere with 20 vertices. The labels of the vertices are turned off.
# > rand_sphere(3,20)->VISUAL(VertexLabels=>"hidden")->STEINER;
user_method STEINER(%Visual::PointSet::decorations) {
my ($self, $decor)=@_;
my $VP=$self->basis_solid;
$VP->FacetTransparency //= 0.5;
my $P=$self->Polytope;
my $SP=new Visual::PointSet( Name => "Steiner points of " . $P->name,
Points => dehomogenize(convert_to<Float>($P->STEINER_POINTS)),
PointColor => $Visual::Color::steiner_point,
PointThickness => $steiner_point_thickness,
PointLabels => "hidden",
$decor,
);
compose($self, $SP);
}
package Visual::SchlegelDiagram;
# Add the [[Visual::SchlegelDiagram::STEINER_POINTS|STEINER_POINTS]] to the Schlegel Diagram
# @options %Visual::PointSet::decorations
# @option Bool center place the projection center to the Steiner point of the polytope
# and the view ray through the Steiner point of the facet
# @return Visual::SchlegelDiagram
user_method STEINER(%Visual::PointSet::decorations, { center => undef }) {
my ($self, $decor, $opts)=@_;
my $S=$self->SchlegelObject;
my $P=$S->parent;
if ($opts->{center}) {
$S->begin_transaction;
$S->INNER_POINT=$P->STEINER_POINTS->[0];
$S->FACET_POINT=$P->STEINER_POINTS->[$S->FACET+1];
$S->commit;
}
# omit the Steiner point of the whole polytope and the one on the projection facet
my $omit_points=new Set(0, $S->FACET+1);
my $SP=new Visual::PointSet( Name => "Steiner points of " . $P->name,
Points => (new Visual::SchlegelTransform($S, $P->STEINER_POINTS->minor(~$omit_points,All))),
PointColor => $Visual::Color::steiner_point,
PointThickness => $steiner_point_thickness,
PointLabels => "hidden",
$decor
);
compose($self, $SP);
}
# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
|