Options
All
  • Public
  • Public/Protected
  • All
Menu
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

XYCoords

requires

geomutils

Hierarchy

  • Triangle

Implements

Index

Constructors

constructor

Properties

a

member

{Vertex}

memberof

Triangle

instance

b

member

{Vertex}

memberof

Triangle

instance

c

member

{Vertex}

memberof

Triangle

instance

Private center

center: Vertex
member

{Vertex}

memberof

Triangle

instance

Readonly className

className: string = "Triangle"

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

Private radius

radius: number
member

{number}

memberof

Triangle

instance

Private radius_squared

radius_squared: number
member

{number}

memberof

Triangle

instance

Static Readonly Private EPSILON

EPSILON: number = 0.000001

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

Methods

bounds

  • Get the rectangular bounds for this triangle.

    method

    bounds

    instance
    memberof

    Triangle

    Returns Bounds

    • The min/max bounds of this triangle.

calcCircumcircle

  • calcCircumcircle(): void
  • 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).

    method

    calcCircumcircle

    instance
    memberof

    Triangle

    Returns void

    void

containsPoint

  • containsPoint(p: Vertex): boolean
  • Checks if the passed vertex (p) is inside this triangle.

    Note: matrix determinants rock.

    method

    containsPoint

    instance
    memberof

    Triangle

    Parameters

    • p: Vertex

      The vertex to check.

    Returns boolean

determinant

  • determinant(): number
  • Get the determinant of this triangle.

    method

    determinant

    instance
    memberof

    Triangle

    Returns number

    • The determinant (float).

getArea

  • getArea(): number
  • 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.

    method

    getArea

    instance
    memberof

    Triangle

    Returns number

    The non-negative area of this triangle.

getCentroid

  • Get the centroid of this triangle.

    The centroid is the average midpoint for each side.

    method

    getCentroid

    instance
    memberof

    Triangle

    Returns Vertex

    The centroid

getCircumcircle

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

    method

    getCircumcircle

    instance
    memberof

    Triangle

    Returns Circle

    • { center:Vertex, radius:float }

getIncenter

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

getIncircle

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

getIncircularTriangle

  • Get that inner triangle which defines the maximal incircle.

    Returns Triangle

    The triangle of those points in this triangle that define the incircle.

getThirdVertex

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

    method

    getThirdVertex

    instance
    memberof

    Triangle

    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.

inCircumcircle

  • inCircumcircle(v: Vertex): boolean
  • Check if the passed vertex is inside this triangle's circumcircle.

    method

    inCircumcircle

    instance
    memberof

    Triangle

    Parameters

    • v: Vertex

      The vertex to check.

    Returns boolean

isAdjacent

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

    method

    isAdjacent

    instance
    memberof

    Triangle

    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.

scaleToCentroid

  • scaleToCentroid(factor: number): Triangle
  • Scale the triangle towards its centroid.

    method

    scaleToCentroid

    instance
    memberof

    Triangle

    Parameters

    • factor: number

    Returns Triangle

    this (for chaining)

toPolygon

  • Convert this triangle to a polygon instance.

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

    method

    toPolygon

    instance
    memberof

    Triangle

    Returns Polygon

    A new polygon representing this triangle.

toSVGString

  • toSVGString(options: { className?: string }): string
  • Create an SVG representation of this triangle.

    method

    toSVGString

    instance
    memberof

    Triangle

    Parameters

    • options: { className?: string }

      An optional set of options, like 'className'.

      • Optional className?: string

    Returns string

    The SVG string.

toString

  • toString(): string
  • Converts this triangle into a human-readable string.

    method

    toString

    instance
    memberof

    Triangle

    Returns string

Static fromArray

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

    method

    fromArray

    static
    memberof

    Vertex

    Parameters

    • arr: Array<Vertex>

      The required array with at least three vertices.

    Returns Triangle

Object literals

Static Private utils

utils: object

max3

  • max3(a: number, b: number, c: number): number

min3

  • min3(a: number, b: number, c: number): number

Private pointIsInTriangle

  • pointIsInTriangle(px: number, py: number, p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number): boolean
  • 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

  • signedArea(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number): number
  • Parameters

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

    Returns number

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Private property
  • Private method
  • Static property
  • Static method

Generated using TypeDoc