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

Implements

Index

Constructors

constructor

Properties

a

member

{Vertex}

memberof

VertTuple

instance

b

member

{Vertex}

memberof

VertTuple

instance

Readonly className

className: string = "Vector"

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

isDestroyed

isDestroyed: boolean
member

isDestroyed

memberof

VertTuple

instance

Readonly uid

uid: UID

The UID of this drawable object.

member

{UID}

memberof

VertTuple

instance
readonly

Methods

add

angle

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

    method

    angle

    instance
    memberof

    VertTuple

    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

clone

colinear

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

    The constant Vertex.EPSILON is used for tolerance.

    method

    colinear

    instance
    memberof

    VertTuple

    Parameters

    Returns boolean

    true if both lines are co-linear.

denominator

  • Get the denominator of this and the given line.

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

    method

    denominator

    instance
    memberof

    VertTuple

    Parameters

    Returns number

destroy

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

getClosestPoint

  • Get the closest point on this line to the specified point.

    method

    getClosestPoint

    instance
    memberof

    VertTuple

    Parameters

    • p: Vertex

      The point (vertex) to measre the distance to.

    Returns Vertex

    The point on the line that is closest to p.

getClosestT

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

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

    name

    getClosetT

    method

    getClosestT

    instance
    memberof

    VertTuple

    Parameters

    • p: XYCoords

      The point (vertex) to measure the distance to.

    Returns number

    The line position t of minimal distance to p.

getOrthogonal

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

    name

    getOrthogonal

    method

    getOrthogonal

    instance
    memberof

    Vector

    Returns Vector

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

hasPoint

  • hasPoint(point: XYCoords, insideBoundsOnly?: boolean): boolean
  • Check if the given point is located on this line. Optionally also check if that point is located between point a and b.

    method

    hasPoint

    instance
    memberof

    VertTuple

    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.

intersection

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

    method

    intersection

    instance
    memberof

    Line

    Parameters

    • line: Vector

      The second vector.

    Returns Vertex | null

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

inv

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

    Returns Vector

    this for chaining.

inverse

  • 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

length

  • length(): number

moveTo

normalize

perp

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

pointDistance

  • pointDistance(p: Vertex): number
  • The the minimal distance between this line and the specified point.

    method

    pointDistance

    instance
    memberof

    VertTuple

    Parameters

    • p: Vertex

      The point (vertex) to measre the distance to.

    Returns number

    The absolute minimal distance.

scale

setLength

  • Set the length of this vector to the given amount. This only works if this vector is not a null vector.

    method

    setLength

    memberof

    VertTuple

    Parameters

    • length: number

      The desired length.

    Returns VertTuple<Vector>

    this (for chaining)

sub

toString

  • toString(): string
  • Create a string representation of this line.

    method

    totring

    instance
    memberof

    VertTuple

    Returns string

    The string representing this line.

vertAt

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

    vertAt

    instance
    memberof

    VertTuple

    Parameters

    • t: number

      The position scalar.

    Returns Vertex

    The vertex a position t.

Object literals

Static utils

utils: object

buildArrowHead

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

    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 Array<Vertex>

Static Private vtutils

vtutils: object

dist2

Legend

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

Generated using TypeDoc