# Polytopes

`Meshes.Polytope`

— Type`Polytope{K,Dim,T}`

We say that a geometry is a K-polytope when it is a collection of "flat" sides that constitue a `K`

-dimensional subspace. They are called polygon and polyhedron respectively for 2D (`K=2`

) and 3D (`K=3`

) subspaces, embedded in a `Dim`

-dimensional space. The parameter `K`

is also known as the rank or parametric dimension of the polytope: https://en.wikipedia.org/wiki/Abstract_polytope.

The term polytope expresses a particular combinatorial structure. A polyhedron, for example, can be decomposed into faces. Each face can then be decomposed into edges, and edges into vertices. Some conventions act as a mapping between vertices and higher dimensional features (edges, faces, cells...), removing the need to store all features.

Additionally, the following property must hold in order for a geometry to be considered a polytope: the boundary of a (K+1)-polytope is a collection of K-polytopes, which may have (K-1)-polytopes in common. See https://en.wikipedia.org/wiki/Polytope.

**Notes**

- Type aliases are
`Polygon`

,`Polyhedron`

.

`Meshes.Segment`

— Type`Segment(p1, p2)`

An oriented line segment with end points `p1`

, `p2`

. The segment can be called as `s(t)`

with `t`

between `0`

and `1`

to interpolate linearly between its endpoints.

See also `Line`

.

`Meshes.Ngon`

— Type`Ngon(p1, p2, ..., pN)`

A N-gon is a polygon with `N`

vertices `p1`

, `p2`

, ..., `pN`

oriented counter-clockwise (CCW). In this case the number of vertices is fixed and known at compile time. Examples of N-gon are `Triangle`

(N=3), `Quadrangle`

(N=4), `Pentagon`

(N=5), etc.

**Notes**

Although the number of vertices

`N`

is known at compile time, we use abstract vectors to store the list of vertices. This design allows constructing N-gon from views of global vectors without expensive memory allocations.Type aliases are

`Triangle`

,`Quadrangle`

,`Pentagon`

,`Hexagon`

,`Heptagon`

,`Octagon`

,`Nonagon`

,`Decagon`

.

`Meshes.Chain`

— Type`Chain(p1, p2, ..., pn)`

A polygonal chain from a sequence of points `p1`

, `p2`

, ..., `pn`

. See https://en.wikipedia.org/wiki/Polygonal_chain.

`Meshes.PolyArea`

— Type`PolyArea(outer, [inner1, inner2, ..., innerk])`

A polygonal area with `outer`

chain, and optional inner chains `inner1`

, `inner2`

, ..., `innerk`

.

Chains can be a vector of `Point`

or a vector of tuples with coordinates for convenience.

Most algorithms assume that the outer chain is oriented counter-clockwise (CCW) and that all inner chains are oriented clockwise (CW).

`Meshes.Tetrahedron`

— Type`Tetrahedron(p1, p2, p3, p4)`

A tetrahedron with points `p1`

, `p2`

, `p3`

, `p4`

.

`Meshes.Pyramid`

— Type`Pyramid(p1, p2, p3, p4, p5)`

A pyramid with points `p1`

, `p2`

, `p3`

, `p4`

, `p5`

.

`Meshes.Hexahedron`

— Type`Hexahedron(p1, p2, ..., p8)`

A hexahedron with points `p1`

, `p2`

, ..., `p8`

.