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

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

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

    • Optional epsilon: number

      [optional] A tolerance.

    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

  • 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