Classdesc

A triangle class for triangulations.

The class was written for a Delaunay trinagulation demo so it might contain some strange and unexpected functions.

Requires

Bounds

Requires

Circle

Requires

Line

Requires

Vertex

Requires

Polygon

Requires

SVGSerializale

Requires

UID

Requires

UIDGenerator

Requires

geomutils

Implements

Constructors

Properties

Member

Memberof

Triangle

Instance

Member

Memberof

Triangle

Instance

Member

Memberof

Triangle

Instance

center: Vertex

Member

Memberof

Triangle

Instance

className: string = "Triangle"

Required to generate proper CSS classes and other class related IDs.

isDestroyed: boolean

Member

isDestroyed

Memberof

Triangle

Instance

radius: number

Member

Memberof

Triangle

Instance

radius_squared: number

Member

Memberof

Triangle

Instance

uid: string

The UID of this drawable object.

Member

Memberof

Triangle

Instance

EPSILON: number = 1.0e-6

An epsilon for comparison. This should be the same epsilon as in Vertex.

utils: {
    max3(a, b, c): number;
    min3(a, b, c): number;
    pointIsInTriangle(px, py, p0x, p0y, p1x, p1y, p2x, p2y): boolean;
    signedArea(p0x, p0y, p1x, p1y, p2x, p2y): number;
} = ...

Type declaration

  • max3:function
  • min3:function
  • pointIsInTriangle:function
    • Private

      Used by the containsPoint() function.

      Parameters

      • px: number
      • py: number
      • p0x: number
      • p0y: number
      • p1x: number
      • p1y: number
      • p2x: number
      • p2y: number

      Returns boolean

  • signedArea:function

Methods

  • 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).

    Returns void

    void

    Method

    calcCircumcircle

    Instance

    Memberof

    Triangle

  • Checks if the passed vertex (p) is inside this triangle.

    Note: matrix determinants rock.

    Parameters

    • p: Vertex

      The vertex to check.

    Returns boolean

    Method

    containsPoint

    Instance

    Memberof

    Triangle

  • This function should invalidate any installed listeners and invalidate this object. After calling this function the object might not hold valid data any more and should not be used.

    Returns void

  • Get the determinant of this triangle.

    Returns number

    • The determinant (float).

    Method

    determinant

    Instance

    Memberof

    Triangle

  • Get the area of this triangle. The returned area is never negative.

    If you are interested in the signed area, please consider using the Triangle.utils.signedArea helper function. This method just returns the absolute value of the signed area.

    Returns number

    The non-negative area of this triangle.

    Method

    getArea

    Instance

    Memberof

    Triangle

  • 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.

    Returns Circle

    • { center:Vertex, radius:float }

    Method

    getCircumcircle

    Instance

    Memberof

    Triangle

  • Get the incenter of this triangle (which is the center of the circumcircle).

    Note: due to performance reasonst the incenter is buffered inside the triangle because computing it is relatively expensive. If a, b or c have changed you should call the calcCircumcircle() function first, otherwise you might get wrong results.

    Returns Vertex

    Vertex The incenter of this triangle.

  • Get the incircle of this triangle. That is the circle that touches each side of this triangle in exactly one point.

    Note this just calls getIncircularTriangle().getCircumcircle()

    Returns Circle

    The incircle of this triangle.

  • Get that vertex of this triangle (a,b,c) that is not vert1 nor vert2 of the passed two.

    Parameters

    • vert1: Vertex

      The first vertex.

    • vert2: Vertex

      The second vertex.

    Returns Vertex

    • The third vertex of this triangle that makes up the whole triangle with vert1 and vert2.

    Method

    getThirdVertex

    Instance

    Memberof

    Triangle

  • Check if the passed vertex is inside this triangle's circumcircle.

    Parameters

    • v: Vertex

      The vertex to check.

    Returns boolean

    Method

    inCircumcircle

    Instance

    Memberof

    Triangle

  • 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

    • tri: Triangle

      The second triangle to check adjacency with.

    Returns boolean

    • True if this and the passed triangle have at least one common edge.

    Method

    isAdjacent

    Instance

    Memberof

    Triangle

  • Convert this triangle to a polygon instance.

    Plase note that this conversion does not perform a deep clone.

    Returns Polygon

    A new polygon representing this triangle.

    Method

    toPolygon

    Instance

    Memberof

    Triangle

  • Create a new triangle from the given array of vertices.

    The array must have at least three vertices, otherwise an error will be raised. This function will not create copies of the vertices.

    Parameters

    • arr: Vertex[]

      The required array with at least three vertices.

    Returns Triangle

    Method

    fromArray

    Static

    Memberof

    Vertex