#  Copyright (c) 1997-2010
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
#  http://www.polymake.de
#
#  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.
#-------------------------------------------------------------------------------
#  $Project: polymake $$Id: gale.rules 9502 2010-02-24 00:26:29Z gawrilow $

use VisualGale;

object Polytope {

# @category Basic properties
# Coordinates of the Gale transform.

property GALE_TRANSFORM : Matrix<Scalar>;


# @category Visualization
# Coordinates of points for an affine Gale diagram.

property GALE_VERTICES : Matrix<Float>;

rule GALE_TRANSFORM : VERTICES {
   $this->GALE_TRANSFORM=transpose(null_space(transpose($this->VERTICES)));
}
precondition : BOUNDED;

rule GALE_VERTICES : GALE_TRANSFORM {
   $this->GALE_VERTICES(temporary)=gale_vertices($this->GALE_TRANSFORM);
}

# @category Visualization
# Generate the Gale diagram of a //d//-polyhedron with at most //d+4// vertices.
# @return Visual::Gale

user_method GALE (%Visual::Gale::decorations) : GALE_TRANSFORM, GALE_VERTICES, VERTICES_IN_FACETS {
   my ($this, $decor)=@_;
   visualize( new Visual::Gale(
      Name => $this->name,
      Title => "Gale diagram of " . $this->name,
      VertexLabels => $this->lookup("VERTEX_LABELS"),
      Polytope => $this,
      $decor
   ));
}
precondition : GALE_TRANSFORM {
   my $d=$this->GALE_TRANSFORM->cols;
   return $d==2 || $d==3;
}

}


# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
