Class representing a face (closed loop) in a [polygon]Polygon object. Face is a circular bidirectional linked list of [edges]Edge. Face object cannot be instantiated with a constructor. Instead, use [polygon.addFace()]Polygon#addFace method.
Note, that face only set entry point to the linked list of edges but does not contain edges by itself. Container of edges is a property of the polygon object.

// Face implements "next" iterator which enables to iterate edges in for loop:
for (let edge of face) {
console.log(edge.shape.length) // do something
}

// Instead, it is possible to iterate edges as linked list, starting from face.first:
let edge = face.first;
do {
console.log(edge.shape.length); // do something
edge = edge.next;
} while (edge != face.first)

Hierarchy (view full)

Constructors

Properties

first: undefined | LinkedListElement
last: undefined | LinkedListElement

Accessors

  • get box(): Box
  • Return bounding box of the face.

    Returns Box

  • get edges(): Edge[]
  • Return array of edges from first to last

    Returns Edge[]

  • get perimeter(): number
  • Get all edges length.

    Returns number

  • get shapes(): (Segment | Arc)[]
  • Return array of shapes which comprise face

    Returns (Segment | Arc)[]

  • get size(): number
  • Return the number of elements in the list

    Returns number

    number of elements in the list

Methods

  • Append edge after the last edge of the face (and before the first edge).

    Parameters

    • edge: Edge

      Edge to be appended to the linked list

    Returns Face

  • Returns the absolute value of the area of the face

    Returns number

  • Returns edge which contains given point

    Parameters

    Returns undefined | Edge

  • Insert edge newEdge into the linked list after the edge edgeBefore

    Parameters

    • newEdge: Edge

      Edge to be inserted into linked list

    • edgeBefore: Edge

      Edge to insert newEdge after it

    Returns Face

  • Return true if the list is empty

    Returns boolean

  • Return face orientation: one of ORIENTATION.CCW, ORIENTATION.CW, ORIENTATION.NOT_ORIENTABLE
    According to Green theorem the area of a closed curve may be calculated as double integral, and the sign of the integral will be defined by the direction of the curve. When the integral ("signed area") will be negative, direction is counterclockwise, when positive - clockwise and when it is zero, polygon is not orientable. See https://mathinsight.org/greens_theorem_find_area

    Returns number

  • Get point on face boundary at given length, null if length is out of range.

    Parameters

    • length: number

      The length along the face boundary

    Returns null | Point

  • Remove the given edge from the linked list of the face

    Parameters

    • edge: Edge

      Edge to be removed

    Returns Face

  • Reverse orientation of the face: first edge become last and vice a verse, all edges starts and ends swapped, direction of arcs inverted. If face was oriented clockwise, it becomes counterclockwise and vice versa

    Returns Face

  • Set arcLength property for each of the edges in the face. ArcLength of the edge it the arc length from the first edge of the face

    Returns void

  • Set arcLength property for the given edge in the face. ArcLength of the edge it the arc length from the first edge of the face

    Parameters

    Returns void

  • Append array of shapes to the face, add edges to the polygon edges container.

    Parameters

    Returns void

  • Returns signed area of the simple face. Face is simple if it has no self intersections that change its orientation. Then the area will be positive if the orientation of the face is clockwise, and negative if orientation is counterclockwise. It may be zero if polygon is degenerated.

    Returns number

  • Returns new polygon created from one face

    Returns Polygon

  • Get segments from array of points. Zero length segments are skipped.

    Parameters

    Returns Segment[]

  • Throw an error if a circular loop is detected in the linked list

    Parameters

    Returns void