#### Surfaces and Turns

##### Tuesday, Jan 28, 2020

In this note we describe how to determine if a two-complex is an oriented surface (possibly with boundary), with polygons oriented according to the orientation of the surface. Some cases may be missed below, so please check the description in addition to implementing it. Assume that we are given a two-complex `complex: TwoComplex`

.

##### First steps

- Check that the complex is valid, using
`complex.checkComplex`

(also check if that method covers all checks). - Check that every vertex is the initial vertex of an edge.
- Check that every edge is in
*at most*one face, and appears at most once in the boundary (for this and the next checks, may help to consider`complex.faces.toVector.flatMap(_.boundary)`

). - For closed surfaces, check that each edge
`e`

is in some face. If you allow boundary, check that at least one of`e`

and`e.flip`

is in a face.

##### Some functions for checking

We use some functions for checking that we have a surface. These will be extended for non-negative quadrangulation.

`succOpt: Edge -> Option[Edge]`

- given an edge, find a face whose boundary contains`e`

(if it exists, it is unique); take the*next*edge along the boundary.`predOpt: Edge -> Option[Edge]`

- given an edge, find a face whose boundary contains`e`

(if it exists, it is unique); take the*previous*edge along the boundary.`rotateLeftOpt: Edge -> Option[Edge]`

-`succOpt`

mapped by flip; gives the edge with same terminal vertex obtained by left rotation.`rotateRightOpt: Edge -> Option[Edge]`

- gives the edge with same terminal vertex obtained by right rotation.

##### Checking for surfaces.

- For a
*closed surface*, if we start with an edge`e`

with`v == e.terminal`

, using left rotations, (by iterating) we should get all edges with terminal vertex`v`

. - For a
*surface with boundary*, if we start with an edge`e`

with`v == e.terminal`

, using left and right rotations, (by iterating) we should get all edges with terminal vertex`e.terminal`

.

##### Other steps.

These will be useful for non-positive quadrangulations. The terminology makes sense if each vertex has valence at least $5$.

- We can define a
*slight left*(optional) step which given`e`

takes its successor, then flips and then takes successor again. - We can also define
*slight right*using flips and predecessors.