Constructor
new DCEL(points=opt, edges=opt)
Create a new DCEL.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
points= |
Array |
<optional> |
The vertices of the DCEL. [[x1, y1], [x2, y2], ...]. |
edges= |
Array |
<optional> |
The edges of the DCEL. [[start1, end1], [start2, end2]...]. Starts and Ends are indices of vertices. |
Members
faces :Array.<Face>
The faces of the DCEL.
Type:
- Array.<Face>
hedges :Array.<Hedge>
The half edges of the DCEL.
Type:
- Array.<Hedge>
vertices :Array.<Vertex>
The vertices of the DCEL.
Type:
- Array.<Vertex>
Methods
addEdge(x1, y1, x2, y2)
Add an edge to the DCEL.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
number | The x coordinate of the start vertex. |
y1 |
number | The y coordinate of the start vertex. |
x2 |
number | The x coordinate of the end vertex. |
y2 |
number | The y coordinate of the end vertex. |
dispose()
Dispose old datas.
externalFaces() → {Array.<Face>}
Get all external (area <= 0) faces
Returns:
- External faces
- Type
- Array.<Face>
findHedge(x1, y1, x2, y2) → {Hedge|null}
Find half edge by start and end vertices coordinates.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
number | The x coordinate of the start vertex. |
y1 |
number | The y coordinate of the start vertex. |
x2 |
number | The x coordinate of the end vertex. |
y2 |
number | The y coordinate of the end vertex. |
Returns:
- The half edge.
- Type
- Hedge | null
findVertex(x, y) → {Vertex|null}
Find vertex by x and y coordinate.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x coordinate of the vertex. |
y |
number | The y coordinate of the vertex. |
Returns:
- The vertex.
- Type
- Vertex | null
internalFaces() → {Array.<Face>}
Get all internal (area > 0) faces
Returns:
- Internal faces
- Type
- Array.<Face>
removeEdge(x1, y1, x2, y2)
Remove an edge from the DCEL.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
number | The x coordinate of the start vertex. |
y1 |
number | The y coordinate of the start vertex. |
x2 |
number | The x coordinate of the end vertex. |
y2 |
number | The y coordinate of the end vertex. |
setDatas(points=opt, edges=opt)
Set the vertices and edges of the DCEL.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
points= |
Array |
<optional> |
The vertices of the DCEL. [[x1, y1], [x2, y2], ...]. |
edges= |
Array |
<optional> |
The edges of the DCEL. [[start1, end1], [start2, end2]...]. Starts and Ends are indices of vertices. |
splitEdge(x1, y1, x2, y2, splitX, splitY)
Split an edge of the DCEL.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
number | The x coordinate of the start vertex. |
y1 |
number | The y coordinate of the start vertex. |
x2 |
number | The x coordinate of the end vertex. |
y2 |
number | The y coordinate of the end vertex. |
splitX |
number | The x coordinate of the split vertex. |
splitY |
number | The y coordinate of the split vertex. |