Class: Triangle
Triangle(a, b, c)
new Triangle(a, b, c)
The constructor.
Parameters:
Name | Type | Description |
---|---|---|
a |
Vertex | The first vertex of the triangle. |
b |
Vertex | The second vertex of the triangle. |
c |
Vertex | The third vertex of the triangle. |
- Source:
Methods
bounds() → {Bounds}
Get the rectangular bounds for this triangle.
- Source:
Returns:
- The min/max bounds of this triangle.
- Type
- Bounds
calcCircumcircle()
Re-compute the circumcircle of this triangle (if the vertices
have changed).
The circumcenter and radius are stored in this.center and
this.radius. There is a third result: radius_squared (for internal computations).
- Source:
Returns:
void
containsPoint(p) → {boolean}
Checks if the passed vertex (p) is inside this triangle.
Note: matrix determinants rock.
Parameters:
Name | Type | Description |
---|---|---|
p |
Vertex | The vertex to check. |
- Source:
Returns:
- Type
- boolean
determinant() → {number}
Get the determinant of this triangle.
- Source:
Returns:
- The determinant (float).
- Type
- number
getCentroid() → {Vertex}
Get the centroid of this triangle.
The centroid is the average midpoint for each side.
- Source:
Returns:
The centroid
- Type
- Vertex
getCircumcircle() → {Object}
Get the circumcircle of this triangle.
The circumcircle is that unique circle on which all three
vertices of this triangle are located on.
Please note that for performance reasons any changes to vertices will not reflect in changes
of the circumcircle (center or radius). Please call the calcCirumcircle() function
after triangle vertex changes.
- Source:
Returns:
- { center:Vertex, radius:float }
- Type
- Object
getThirdVertex(vert1, vert2) → {Vertex}
Get that vertex of this triangle (a,b,c) that is not vert1 nor vert2 of
the passed two.
Parameters:
Name | Type | Description |
---|---|---|
vert1 |
Vertex | The first vertex. |
vert2 |
Vertex | The second vertex. |
- Source:
Returns:
- The third vertex of this triangle that makes up the whole triangle with vert1 and vert2.
- Type
- Vertex
inCircumcircle(v) → {boolean}
Check if the passed vertex is inside this triangle's
circumcircle.
Parameters:
Name | Type | Description |
---|---|---|
v |
Vertex | The vertex to check. |
- Source:
Returns:
- Type
- boolean
isAdjacent(tri) → {boolean}
Check if this triangle and the passed triangle share an
adjacent edge.
For edge-checking Vertex.equals is used which uses an
an epsilon for comparison.
Parameters:
Name | Type | Description |
---|---|---|
tri |
Triangle | The second triangle to check adjacency with. |
- Source:
Returns:
- True if this and the passed triangle have at least one common edge.
- Type
- boolean
scaleToCentroid() → {Triangle}
Scale the triangle towards its centroid.
Parameters:
Type | Description |
---|---|
number | The scale factor to use. That can be any scalar. |
- Source:
Returns:
this (for chaining)
- Type
- Triangle
toPolygon() → {Polygon}
Convert this triangle to a polygon instance.
Plase note that this conversion does not perform a deep clone.
- Source:
Returns:
A new polygon representing this triangle.
- Type
- Polygon
toString() → {string}
Converts this triangle into a human-readable string.
- Source:
Returns:
- Type
- string
toSVGString(optionsopt) → {string}
Create an SVG representation of this triangle.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
object |
<optional> |
An optional set of options, like 'className'. |
- Source:
Returns:
The SVG string.
- Type
- string