Classdesc

A vector (Vertex,Vertex) is a line with a visible direction.

Vectors are drawn with an arrow at their end point.
The Vector class extends the Line class.

Requires

VertTuple

Requires

Vertex

Hierarchy (view full)

Implements

Constructors

Properties

Member

Memberof

VertTuple

Instance

Member

Memberof

VertTuple

Instance

className: string = "Vector"

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

isDestroyed: boolean

Member

isDestroyed

Memberof

VertTuple

Instance

uid: string

The UID of this drawable object.

Member

Memberof

VertTuple

Instance

utils: {
    buildArrowHead: ((zA, zB, headlen, scaleX, scaleY) => Vertex[]);
} = ...

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[]

vtutils: {
    dist2: ((v, w) => number);
} = ...

Type declaration

  • dist2: ((v, w) => number)

Methods

  • Get the angle between this and the passed line (in radians).

    Parameters

    • Optional line: VertTuple<any>

      (optional) The line to calculate the angle to. If null the baseline (x-axis) will be used.

    Returns number

    this

    Method

    angle

    Instance

    Memberof

    VertTuple

  • Checks if this and the given line are co-linear.

    The constant Vertex.EPSILON is used for tolerance.

    Parameters

    Returns boolean

    true if both lines are co-linear.

    Method

    colinear

    Instance

    Memberof

    VertTuple

  • Get the denominator of this and the given line.

    If the denominator is zero (or close to zero) both line are co-linear.

    Parameters

    Returns number

    Method

    denominator

    Instance

    Memberof

    VertTuple

  • 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 closest point on this line to the specified point.

    Parameters

    • p: Vertex

      The point (vertex) to measre the distance to.

    Returns Vertex

    The point on the line that is closest to p.

    Method

    getClosestPoint

    Instance

    Memberof

    VertTuple

  • Get the closest position T from this line to the specified point.

    The counterpart for this function is Line.vertAt(Number).

    Parameters

    • p: XYCoords

      The point (vertex) to measure the distance to.

    Returns number

    The line position t of minimal distance to p.

    Name

    getClosetT

    Method

    getClosestT

    Instance

    Memberof

    VertTuple

  • Get the orthogonal "vector" of this vector (rotated by 90° clockwise).

    Returns Vector

    A new vector with the same length that stands on this vector's point a.

    Name

    getOrthogonal

    Method

    getOrthogonal

    Instance

    Memberof

    Vector

  • Check if the given point is located on this line. Optionally also check if that point is located between point a and b.

    Parameters

    • point: XYCoords

      The point to check.

    • Optional insideBoundsOnly: boolean

      If set to to true (default=false) the point must be between start and end point of the line.

    Returns boolean

    True if the given point is on this line.

    Method

    hasPoint

    Instance

    Memberof

    VertTuple

  • Get the intersection if this vector and the specified vector.

    Parameters

    • line: Vector

      The second vector.

    Returns Vertex

    The intersection (may lie outside the end-points).

    Method

    intersection

    Instance

    Memberof

    Line

  • This function computes the inverse of the vector, which means 'a' stays untouched.

    Returns Vector

    this for chaining.

  • The inverse of a vector is a vector with the same magnitude but oppose direction.

    Please not that the origin of this vector changes here: a->b becomes b->a.

    Returns Vector

  • Get the perpendicular of this vector which is located at a.

    Returns Vector

    A new vector being the perpendicular of this vector sitting on a.

  • The the minimal distance between this line and the specified point.

    Parameters

    • p: Vertex

      The point (vertex) to measre the distance to.

    Returns number

    The absolute minimal distance.

    Method

    pointDistance

    Instance

    Memberof

    VertTuple

  • Create a string representation of this line.

    Returns string

    The string representing this line.

    Method

    totring

    Instance

    Memberof

    VertTuple

  • Get line point at position t in [0 ... 1]:

    [P(0)]=[A]--------------------[P(t)]------[B]=[P(1)]


    The counterpart of this function is Line.getClosestT(Vertex).

    Parameters

    • t: number

      The position scalar.

    Returns Vertex

    The vertex a position t.

    Method

    vertAt

    Instance

    Memberof

    VertTuple

Generated using TypeDoc