Classdesc

A vertex is a pair of two numbers.

It is used to identify a 2-dimensional point on the x-y-plane.

Requires

IVertexAttr

Requires

SVGSerializable

Requires

UID

Requires

UIDGenerator

Requires

VertexAttr

Requires

VertexListeners

Requires

XYCoords

Implements

Constructors

  • The constructor for the vertex class.

    Parameters

    • Optional x: number | XYCoords

      The x-coordinate of the new vertex.

    • Optional y: number

      The y-coordinate of the new vertex.

    Returns Vertex

    Name

    Vertex

Properties

Member

Memberof

Instance

className: string = "Vertex"

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

isDestroyed: boolean

Member

isDestroyed

Memberof

Vertex

Instance

listeners: VertexListeners

Member

Memberof

Instance

uid: string

The UID of this drawable object.

Member

Memberof

Vertex

Instance

x: number

Member

Memberof

Vertex

Instance

y: number

Member

Memberof

Vertex

Instance

EPSILON: 0.000001 = 1.0e-6

An epsilon for comparison

ZERO: Vertex = ...
utils: {
    buildArrowHead: ((zA, zB, headlen, scaleX, scaleY) => Vertex[]);
    arrayToJSON(vertices, precision?): string;
} = ...

Type declaration

  • buildArrowHead: ((zA, zB, headlen, scaleX, scaleY) => Vertex[])

    Generate a four-point arrow head, starting at the vector end minus the arrow head length.

    The first vertex in the returned array is guaranteed to be the located at the vector line end minus the arrow head length.

    Due to performance all params are required.

    The params scaleX and scaleY are required for the case that the scaling is not uniform (x and y scaling different). Arrow heads should not look distored on non-uniform scaling.

    If unsure use 1.0 for scaleX and scaleY (=no distortion). For headlen use 8, it's a good arrow head size.

    Example: buildArrowHead( new Vertex(0,0), new Vertex(50,100), 8, 1.0, 1.0 )

      • (zA, zB, headlen, scaleX, scaleY): Vertex[]
      • Parameters

        • zA: XYCoords

          The start vertex of the vector to calculate the arrow head for.

        • zB: XYCoords

          The end vertex of the vector.

        • headlen: number

          The length of the arrow head (along the vector direction. A good value is 12).

        • scaleX: number

          The horizontal scaling during draw.

        • scaleY: number

          the vertical scaling during draw.

        Returns Vertex[]

  • arrayToJSON:function
    • Convert the given vertices (array) to a JSON string.

      Parameters

      • vertices: XYCoords[]
      • Optional precision: number

        (optional) The numeric precision to be used (number of precision digits).

      Returns string

Methods

  • Set both coordinates of this vertex to their absolute value (abs(x), abs(y)).

    Returns Vertex

    this

    Method

    abs

    Instance

    Memberof

    Vertex

  • Add the passed amount to x- and y- component of this vertex.

    This function works with add( {number}, {number} ) and add( {Vertex} ), as well.

    Parameters

    • x: number | XYCoords

      The amount to add to x (or a vertex itself).

    • Optional y: number

      The amount to add to y.

    Returns Vertex

    this

    Method

    add

    Instance

    Memberof

    Vertex

  • Add the passed amounts to the x-component of this vertex.

    Parameters

    • amountX: number

    Returns Vertex

    this

    Method

    addX

    Instance

    Memberof

    Vertex

  • Add the passed amounts to the x- and y- components of this vertex.

    Parameters

    • amountX: number
    • amountY: number

    Returns Vertex

    this

    Method

    addXY

    Instance

    Memberof

    Vertex

  • Add the passed amounts to the y-component of this vertex.

    Parameters

    • amountY: number

    Returns Vertex

    this

    Method

    addY

    Instance

    Memberof

    Vertex

  • Get the angle of this point (relative to (0,0) or to the given other origin point).

    Parameters

    • Optional origin: XYCoords

      The vertex to measure the angle from.

    Returns number

    Method

    angle

    Instance

    Memberof

    Vertex

  • Create a copy of this vertex.

    Returns Vertex

    A new vertex, an exact copy of this.

    Method

    clone

    Instance

    Memberof

    Vertex

  • 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 difference to the passed point.

    The difference is (vert.x-this.x, vert.y-this.y).

    Parameters

    • vert: XYCoords

      The vertex to measure the x-y-difference to.

    Returns Vertex

    A new vertex.

    Method

    difference

    Instance

    Memberof

    Vertex

  • Get the distance to the passed point (in euclidean metric)

    Parameters

    • vert: XYCoords

      The vertex to measure the distance to.

    Returns number

    Method

    distance

    Instance

    Memberof

    Vertex

  • Check if this vertex equals the passed one.
    This function uses an internal epsilon as tolerance.

    Parameters

    • vertex: XYCoords

      The vertex to compare this with.

    Returns boolean

    Method

    equals

    Instance

    Memberof

    Vertex

  • Set the x-component if this vertex to the inverse of its value.

    Returns Vertex

    this

    Method

    invX

    Instance

    Memberof

    Vertex

  • Set the y-component if this vertex to the inverse of its value.

    Returns Vertex

    this

    Method

    invY

    Instance

    Memberof

    Vertex

  • Perform a linear interpolation towards the given target vertex. The amount value t is relative, t=0.0 means no change, t=1.0 means this point will be moved to the exact target position.

    t=0.5 will move this point to the middle of the connecting linear segment.

    Parameters

    • target: XYCoords

      The target position to lerp this vertex to.

    • t: number

      The relative amount, usually in [0..1], but other values will work, too.

    Returns Vertex

  • Perform a linear interpolation towards the given target vertex (absolute variant). The amount value t is absolute, which means the lerp amount is a direct distance value. This point will have move the amount of the passed distance u.

    Parameters

    • target: XYCoords

      The target position to lerp this vertex to.

    • u: number

    Returns Vertex

  • This is a vector-like behavior and 'rotates' this vertex around given center.

    Parameters

    • angle: number

      The angle to 'rotate' this vertex; 0.0 means no change.

    • center: XYCoords

      The center of rotation; default is (0,0).

    Returns Vertex

    this

    Method

    rotate

    Instance

    Memberof

    Vertex

  • This is a vector-like behavior and 'scales' this vertex towards/from a given center by one uniform scale factor.

    Parameters

    • factor: number

      The factor to 'scale' this vertex; 1.0 means no change.

    • Optional center: XYCoords

      The origin of scaling; default is (0,0).

    Returns Vertex

    this

    Method

    scale

    Instance

    Memberof

    Vertex

  • This is a vector-like behavior and 'scales' this vertex towards/from a given center by two independent x- and y- scale factors.

    Parameters

    • factors: XYCoords
    • Optional center: XYCoords

      The origin of scaling; default is (0,0).

    Returns Vertex

    this

    Method

    scale

    Instance

    Memberof

    Vertex

  • Set the x- and y- component of this vertex.

    Parameters

    • x: number | XYCoords

      The new x-component.

    • Optional y: number

      The new y-component.

    Returns Vertex

    this

    Method

    set

    Instance

    Memberof

    Vertex

  • Set the x-component of this vertex.

    Parameters

    • x: number

      The new x-component.

    Returns Vertex

    this

    Method

    setX

    Instance

    Memberof

    Vertex

  • Set the y-component of this vertex.

    Parameters

    • y: number

      The new y-component.

    Returns Vertex

    this

    Method

    setY

    Instance

    Memberof

    Vertex

  • Substract the passed amount from x- and y- component of this vertex.

    This function works with sub( {number}, {number} ) and sub( {Vertex} ), as well.

    Parameters

    • x: number | XYCoords

      The amount to substract from x (or a vertex itself).

    • Optional y: number

      The amount to substract from y.

    Returns Vertex

    this

    Method

    sub

    Instance

    Memberof

    Vertex

  • Substract the passed amounts from the x-component of this vertex.

    Parameters

    • amountX: number

    Returns Vertex

    this

    Method

    addX

    Instance

    Memberof

    Vertex

  • Substract the passed amounts from the x- and y- components of this vertex.

    Parameters

    • amountX: number
    • amountY: number

    Returns Vertex

    this

    Method

    subXY

    Instance

    Memberof

    Vertex

  • Substract the passed amounts from the y-component of this vertex.

    Parameters

    • amountY: number

    Returns Vertex

    this

    Method

    subY

    Instance

    Memberof

    Vertex

  • Get a string representation of this vertex.

    Parameters

    • Optional precision: number

    Returns string

    The string representation of this vertex.

    Method

    toString

    Instance

    Memberof

    Vertex

  • Create a new random vertex inside the given viewport.

    Parameters

    Returns Vertex

    A new vertex with a random position.

Generated using TypeDoc