cpolytope.c File Reference Detailed DescriptionImplements the functions for the polytope defined in a chart (i.e., in the tangent space to a variety defined on a given point).
Definition in file cpolytope.c.
Function Documentation
Determines if a couple of vertices are connected by a vertex and returns the set of faces defining the edge. This is for internal use only and no check is done if the vertices are actually used (properly defined) in the chart. This check must be done before calling this function.
Definition at line 364 of file cpolytope.c. References Tcpolytope::emptyPolytope, FALSE, Tcpolytope::indices, and Tcpolytope::k. Referenced by CutPolytopeWithFace(), GetPolytopeEdges(), and GetPolytopeNeighboursFromVertices().
This is an auxiliary function for PolytopeBoundaryPointFromExternalCorner and for PolytopeBoundaryPointsFromExternalCorners. In the first case the external corner is selected at random or just the first external corner is used (depending on paramter rand). In the second case all external corners are used (in sequence).
Definition at line 750 of file cpolytope.c. References AccumulateVector(), Error(), Tcpolytope::expandible, FALSE, GeneralDotProduct(), GetPolytopeInteriorPoint(), Tcpolytope::k, Tcpolytope::maxIndices, NO_UINT, Norm(), Tcpolytope::r, ScaleVector(), SGN, SubtractVector(), TRUE, Tcpolytope::vertex, Warning(), and WrongPolytopeCorner(). Referenced by PolytopeBoundaryPointFromExternalCorner(), and PolytopeBoundaryPointsFromExternalCorners().
Defines an empty chart polytope.
Definition at line 65 of file cpolytope.c. References Tcpolytope::emptyPolytope, Tcpolytope::k, Tcpolytope::open, PolytopeMaxVolume(), Tcpolytope::r, TRUE, and Tcpolytope::v. Referenced by InitChartInt(), and SPolytope2Polytope().
Defines a box with all vertices outside the ball defining the polytope. This polytope is refined as the local chart intersects with other local charts. In this refinement the external vertices progresively moves inside the ball. When all points are inside the ball, the chart is no longer in the frontier of expansion of the atlas.
Definition at line 77 of file cpolytope.c. References Tcpolytope::bb, Tcpolytope::emptyPolytope, Tcpolytope::expandible, Tcpolytope::face, FALSE, FirstCombination(), Tcpolytope::freeVertex, Tcpolytope::ID, Tcpolytope::indices, InitBox(), Tcpolytope::k, Tcpolytope::maxFaces, Tcpolytope::maxIndices, Tcpolytope::maxVertices, NEW, NewInterval(), Tcpolytope::nExpandible, NextCombination(), Tcpolytope::nFaces, Tcpolytope::nIndices, NO_UINT, Tcpolytope::nVertices, Tcpolytope::open, POLYTOPE_R_ENLARGEMENT, Tcpolytope::r, SetBoxInterval(), TRUE, and Tcpolytope::vertex. Referenced by CutPolytope(), GetPolytopeEdges(), GetPolytopeNeighboursFromVertices(), GetPolytopeVertices(), PolytopeBoundaryPointFromExternalCorner(), PolytopeBoundaryPointsFromExternalCorners(), PrintPolytopeInfo(), and SPolytope2Polytope().
Defines a chart polytope from a simple chart polytope.
Definition at line 188 of file cpolytope.c. References CT_R, CutPolytopeWithFace(), DefinePolytope(), GetParameter(), GetSPolytopeDim(), GetSPolytopeFace(), GetSPolytopeNFaces(), InitEmptyPolytope(), NEW, and SPolytopeNeighbourID(). Referenced by GetChartNeighboursFromVertices(), PlotChart(), and PlotChartAsPolygon().
Defines a simple chart polytope from a normal/full chart polytope.
Definition at line 212 of file cpolytope.c. References CT_DELTA, CT_SR, CutSPolytopeWithFace(), DefineSPolytope(), Tcpolytope::face, GetParameter(), Tcpolytope::ID, InitEmptySPolytope(), Tcpolytope::k, Tcpolytope::nFaces, and Tcpolytope::r.
Copies the data defining the polytope from one chart to another. Assumes the other fiels of the chart are already copied from src to dst (i.e., this is to be called at the end of the chart copy constructor).
Definition at line 229 of file cpolytope.c. References Tcpolytope::bb, CopyBox(), Tcpolytope::emptyPolytope, Tcpolytope::expandible, Tcpolytope::face, FALSE, Tcpolytope::freeVertex, Tcpolytope::ID, Tcpolytope::indices, Tcpolytope::k, Tcpolytope::maxFaces, Tcpolytope::maxIndices, Tcpolytope::maxVertices, NEW, Tcpolytope::nExpandible, Tcpolytope::nFaces, Tcpolytope::nIndices, Tcpolytope::nVertices, Tcpolytope::open, Tcpolytope::r, Tcpolytope::v, and Tcpolytope::vertex. Referenced by CopyChart().
Computes the center of the polytope.
Definition at line 301 of file cpolytope.c. References Tcpolytope::emptyPolytope, Error(), Tcpolytope::k, Tcpolytope::maxIndices, Tcpolytope::nVertices, and Tcpolytope::vertex. Referenced by GetPolytopeInteriorPoint().
Decides wheter or not a point in inside the polytope bounding a chart.
Definition at line 329 of file cpolytope.c. References Tcpolytope::emptyPolytope, Tcpolytope::face, FALSE, GeneralDotProduct(), Tcpolytope::k, Tcpolytope::nVertices, Tcpolytope::r, and TRUE. Referenced by FocusedPointOnBoundary(), GetPolytopeInteriorPoint(), InsideChartPolytope(), PolytopeRandomPointOnBoundary(), PolytopeVolume(), and RandomPointInPolytope().
Reduces a polytope bounding chart cropping it with a plane defined by the intersection of the chart ball with a ball centered at t with radious r. This ball is an approximation in the chart plane of the ball bounding another chart. This is basically a particular case for CutPolytopeWithFace where the face is defined from the intersection of two balls.
Definition at line 396 of file cpolytope.c. References CutPolytopeWithFace(), DefinePolytope(), Tcpolytope::emptyPolytope, Tcpolytope::k, Norm(), and Tcpolytope::r. Referenced by ForceChartCut(), and IntersectChartsInt().
This is the generic function cutting a polytope by a plane that can come from the intersection of two balls or from anywhere else. The plane is given in the form
where the are given in t, the are the variables in the tangent space, and is the dimension of this space.
Definition at line 412 of file cpolytope.c. References Tcpolytope::bb, CS_WD_SIMP_INEQUALITIES_ERROR, DeleteBox(), DistancePointToBoxTopology(), Tcpolytope::emptyPolytope, ExpandBox(), Tcpolytope::expandible, Tcpolytope::face, FALSE, Tcpolytope::freeVertex, GeneralDotProduct(), HaveEdge(), Tcpolytope::ID, Tcpolytope::indices, InitBoxFromPoint(), Tcpolytope::k, Local2Global(), Tcpolytope::maxFaces, Tcpolytope::maxIndices, Tcpolytope::maxVertices, MEM_DUP, MEM_EXPAND, NEW, Tcpolytope::nExpandible, Tcpolytope::nFaces, Tcpolytope::nIndices, NO_UINT, Norm(), Tcpolytope::nVertices, Tcpolytope::open, Tcpolytope::r, TRUE, Tcpolytope::v, and Tcpolytope::vertex. Referenced by AddBorderConstraint(), CutPolytope(), and SPolytope2Polytope().
Returns the radious of the ball included in the initial polytope.
Definition at line 654 of file cpolytope.c. References Tcpolytope::r.
Returns the dimensionality of the space where the simple polytope is defined.
Definition at line 659 of file cpolytope.c. References Tcpolytope::k.
Returns the axis aligned box bounding the polytope.
Definition at line 664 of file cpolytope.c. References Tcpolytope::bb, and Tcpolytope::emptyPolytope.
Sets a new bounding box for the polytope. Use carefully since a wrong bounding box could render the polytope inconsitent/useless.
Definition at line 672 of file cpolytope.c. References Tcpolytope::bb, CopyBox(), DeleteBox(), and Tcpolytope::emptyPolytope.
Checks if a polytope has vertices that can be sued to expand it, i.e., to generate a new neighbour.
Definition at line 679 of file cpolytope.c. References Tcpolytope::emptyPolytope, and Tcpolytope::nExpandible. Referenced by ExpandibleChart(), and OpenChart().
If we tried to extend a chart towards a selected vertex and we could not do it, we mark the corner as problematic and avoid using it for future chart extensions. This is no an issue as far as the whole manifold can be covered in many ways.
Definition at line 684 of file cpolytope.c. References Tcpolytope::emptyPolytope, Tcpolytope::expandible, FALSE, and Tcpolytope::nExpandible. Referenced by PolytopeBoundaryPointFromExternalCornerInt(), and WrongCorner().
Returns a point inside the ball and the polytope. This point is used to define lines to external polytope corners that crosses the ball.
Definition at line 693 of file cpolytope.c. References FALSE, INF, InsidePolytope(), Tcpolytope::k, Tcpolytope::maxIndices, Norm(), Tcpolytope::nVertices, PolytopeCenter(), TRUE, and Tcpolytope::vertex. Referenced by PolytopeBoundaryPointFromExternalCornerInt().
Returns a point on the ball selecting one of the external polytope vertices at random and connecting this vertex and the center of the ball. These points are typically in the border of expansion of the manifold discretization (i.e., good candidates for expansion).
Definition at line 847 of file cpolytope.c. References DefinePolytope(), Tcpolytope::emptyPolytope, FALSE, Tcpolytope::nExpandible, NO_UINT, PolytopeBoundaryPointFromExternalCornerInt(), and randomMax(). Referenced by BoundaryPointFromExternalCorner().
Generates all the possible points on the boundary from the polytope vertexes out of the ball with radius rSample.
Definition at line 876 of file cpolytope.c. References DefinePolytope(), Tcpolytope::emptyPolytope, Tcpolytope::k, NEW, Tcpolytope::nExpandible, and PolytopeBoundaryPointFromExternalCornerInt(). Referenced by BoundaryPointsFromExternalCorners().
Returns a random point uniformly distributed in the boundary of the hypersphere defined in the tangent space. After sampling the point we check if it is actually outside the neighbouring charts. The border with the neighbouring charts are defined by the faces used to cut the polytope bounding the ball (see IntersectCharts). Charts that are basically sorounded by neighbours and only have a small portion of its ball in the border or expansion of the manifold could be arbitrarily hard to sample. It is not allowed to sample interior charts (see ExpandibleChart).
Definition at line 908 of file cpolytope.c. References InsidePolytope(), Tcpolytope::k, and randomOnBall(). Referenced by RandomPointOnBoundary().
Drawns a random point inside the polytope with uniform distribution. Rejection sampling is used so for some degenerate polytopes it can take long.
Definition at line 914 of file cpolytope.c. References Tcpolytope::bb, Tcpolytope::emptyPolytope, InsidePolytope(), Tcpolytope::k, NewInterval(), POLYTOPE_R_ENLARGEMENT, Tcpolytope::r, randomInInterval(), RandomPointInBox(), and TRUE. Referenced by ChartVolume(), PolytopeVolume(), and RandomPointInChart().
Upper bound of the volume of the polytope. This is basically the volume of the area where RandomPointInPolytope uses to generate random points.
Definition at line 943 of file cpolytope.c. References Tcpolytope::bb, Tcpolytope::emptyPolytope, GetBoxVolume(), Tcpolytope::k, POLYTOPE_R_ENLARGEMENT, and Tcpolytope::r. Referenced by ChartVolume(), InitEmptyPolytope(), and PolytopeVolume().
Returns an estimation of the polytope volume. Initially the estimation is tight but as the polytope is cut with new hyperplanes we estimate the volume via sampling.
Definition at line 951 of file cpolytope.c. References InsidePolytope(), Tcpolytope::k, NEW, PolytopeMaxVolume(), RandomPointInPolytope(), and Tcpolytope::v. Referenced by ChartMaxVolume().
Returns the number of neighbours of a polytope. The neighbours of a polytope are those detected when intersecting polytopes (see CutPolytope). This only include neighbours with similar tangent spaces (not neighbours across singularities). Note that the neighbouring management is implemented in a way that is slow for query but constant time for update. This is so since we want to optimize the construction of the atlas and not its query. Not that for charts at the border of the ambient space, this number might include "virtual" neighbours given by the intersection with the ambient limits. Thses "virtual" neighbours have NO_UINT as identifier (see PolytopeNeighbourID).
Definition at line 974 of file cpolytope.c. References Tcpolytope::emptyPolytope, Tcpolytope::ID, Tcpolytope::nFaces, and NO_UINT. Referenced by ChartNumNeighbours().
Returns the identifier of one of the neighbours of a polytope. This includes only neighbours with similar tangent spaces (neighbours in the same aspect of the manifold)
Definition at line 992 of file cpolytope.c. References Tcpolytope::emptyPolytope, FALSE, Tcpolytope::ID, NO_UINT, and TRUE. Referenced by ChartNeighbourID().
Returns the set of vertices of the polytope.
Definition at line 1027 of file cpolytope.c. References DefinePolytope(), Tcpolytope::emptyPolytope, Tcpolytope::k, Tcpolytope::maxIndices, Tcpolytope::maxVertices, NEW, and Tcpolytope::vertex. Referenced by PlotChart(), and PlotChartAsPolygon().
For bidimensional manifold, we identify the two neighbouring charts coincident for each vertex. These two charts together with the current chart form one of the triangles of the triangulation of the atlas.
Definition at line 1061 of file cpolytope.c. References DefinePolytope(), Tcpolytope::emptyPolytope, Error(), HaveEdge(), Tcpolytope::ID, Tcpolytope::k, Tcpolytope::maxIndices, Tcpolytope::maxVertices, NEW, and Tcpolytope::nFaces. Referenced by GetChartNeighboursFromVertices().
Returns the set of edges of the polytope. Edges are returned as pairs of identifiers of vertices. The identifers correspond to the edges are returned by GetPolytopeVertices.
Definition at line 1126 of file cpolytope.c. References DefinePolytope(), Tcpolytope::emptyPolytope, HaveEdge(), Tcpolytope::maxIndices, Tcpolytope::maxVertices, NEW, Tcpolytope::nFaces, and Tcpolytope::nVertices. Referenced by PlotChart(), and PlotChartAsPolygon().
Computes the approximated memory used by the polytope (in bytes).
Definition at line 1169 of file cpolytope.c. References Tcpolytope::k, Tcpolytope::maxFaces, Tcpolytope::maxIndices, Tcpolytope::maxVertices, Tcpolytope::nFaces, and Tcpolytope::nVertices. Referenced by ChartMemSize().
Saves the information about the chart polytope (if any) to a given file.
Definition at line 1187 of file cpolytope.c. References Tcpolytope::bb, Tcpolytope::emptyPolytope, Tcpolytope::expandible, Tcpolytope::face, Tcpolytope::freeVertex, Tcpolytope::ID, Tcpolytope::indices, Tcpolytope::k, Tcpolytope::maxFaces, Tcpolytope::maxIndices, Tcpolytope::maxVertices, Tcpolytope::nExpandible, Tcpolytope::nFaces, Tcpolytope::nIndices, Tcpolytope::nVertices, Tcpolytope::open, PrintBox(), Tcpolytope::r, Tcpolytope::v, and Tcpolytope::vertex. Referenced by SaveChart().
Initializes the information about the chart polytope (if any) from a given file.
Definition at line 1252 of file cpolytope.c. References Tcpolytope::bb, Tcpolytope::emptyPolytope, Tcpolytope::expandible, Tcpolytope::face, Tcpolytope::freeVertex, Tcpolytope::ID, Tcpolytope::indices, Tcpolytope::k, Tcpolytope::maxFaces, Tcpolytope::maxIndices, Tcpolytope::maxVertices, NEW, Tcpolytope::nExpandible, Tcpolytope::nFaces, Tcpolytope::nIndices, NO_UINT, Tcpolytope::nVertices, Tcpolytope::open, Tcpolytope::r, ReadBox(), Tcpolytope::v, and Tcpolytope::vertex. Referenced by LoadChart().
Prints some debugging information about the polytope. Definition at line 1350 of file cpolytope.c. References DefinePolytope(), Tcpolytope::emptyPolytope, Tcpolytope::face, Tcpolytope::indices, Tcpolytope::maxFaces, Tcpolytope::maxIndices, Tcpolytope::maxVertices, Tcpolytope::nFaces, Tcpolytope::nIndices, and Tcpolytope::nVertices.
Deletes the structure allocated by DefinePolytope.
Definition at line 1380 of file cpolytope.c. References Tcpolytope::bb, DeleteBox(), Tcpolytope::emptyPolytope, Tcpolytope::expandible, Tcpolytope::face, Tcpolytope::freeVertex, Tcpolytope::ID, Tcpolytope::indices, Tcpolytope::maxFaces, Tcpolytope::maxIndices, Tcpolytope::maxVertices, Tcpolytope::nExpandible, Tcpolytope::nFaces, Tcpolytope::nIndices, NO_UINT, Tcpolytope::nVertices, and Tcpolytope::vertex. Referenced by DeleteChart(), GetChartNeighboursFromVertices(), PlotChart(), and PlotChartAsPolygon(). |
Follow us!