Constructor
new Face()
- Source:
Example
// 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)
Members
Methods
append(edges, edge)
Append given edge after the last edge (and before the first edge).
This method mutates current object and does not return any value
This method mutates current object and does not return any value
- Source:
Parameters:
Name | Type | Description |
---|---|---|
edges |
PlanarSet
|
Container of edges |
edge |
Edge
|
Edge to be appended to the linked list |
area() → {number}
Returns the absolute value of the area of the face
- Source:
Returns:
- Type:
-
number
insert(edges, newEdge, edgeBefore)
Insert edge newEdge into the linked list after the edge edgeBefore
This method mutates current object and does not return any value
This method mutates current object and does not return any value
- Source:
Parameters:
Name | Type | Description |
---|---|---|
edges |
PlanarSet
|
Container of edges |
newEdge |
Edge
|
Edge to be inserted into linked list |
edgeBefore |
Edge
|
Edge to insert newEdge after it |
isEmpty() → {boolean}
Returns true if face is empty, false otherwise
- Source:
Returns:
- Type:
-
boolean
isSimple(edges) → {boolean}
Returns true if face of the polygon is simple (no self-intersection points found)
NOTE: this method is incomplete because it doe not exclude touching points
Real self intersection inverts orientation of the polygon.
But this is also good enough for the demonstration of the idea
- Source:
Parameters:
Name | Type | Description |
---|---|---|
edges |
Edges
|
reference to polygon.edges to provide search index |
Returns:
- Type:
-
boolean
orientation() → {number}
Return face orientation: one of Flatten.ORIENTATION.CCW, Flatten.ORIENTATION.CW, Flatten.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 counter clockwise, when positive - clockwise and when it is zero, polygon is not orientable. See https://mathinsight.org/greens_theorem_find_area
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 counter clockwise, when positive - clockwise and when it is zero, polygon is not orientable. See https://mathinsight.org/greens_theorem_find_area
- Source:
Returns:
- Type:
-
number
remove(edges, edge)
Remove the given edge from the linked list of the face
This method mutates current object and does not return any value
This method mutates current object and does not return any value
- Source:
Parameters:
Name | Type | Description |
---|---|---|
edges |
PlanarSet
|
Container of edges |
edge |
Edge
|
Edge to be removed |
reverse()
Reverse orientation of the face: first edge become last and vice a verse,
all edges starts and ends swapped, direction of arcs inverted.
- Source:
setArcLength()
Set arc_length property for each of the edges in the face.
Arc_length of the edge it the arc length from the first edge of the face
- Source:
signedArea() → {number}
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.
- Source:
Returns:
- Type:
-
number
svg() → {string}
Returns string to be assigned to "d" attribute inside defined "path"
- Source:
Returns:
- Type:
-
string