Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vector

The Vector is class that provides methods for manipulating vectors.

Hierarchy

Index

Constructors

constructor

  • new Vector(x?: number, y?: number): Vector

Properties

x

x: number

y

y: number

Static Private prTemp

prTemp: Vector[] = ...

Private temporary vectors

Static Readonly temp

temp: Vector[] = ...

Temporary vectors

Static Readonly zero

zero: Vector = ...

Zero-vector

Methods

add

clone

copy

divide

  • divide(divisor: number): Vector
  • Divides the vector by the given divisor.

    Parameters

    • divisor: number

      The divisor

    Returns Vector

    The divided vector

divideOut

  • Divides the vector by the given divisor and sets it's value to output(original vector does not changes).

    Parameters

    • divisor: number

      The divisor

    • output: Vector

    Returns Vector

    The divided vector

length

  • length(): number
  • Returns the length of the vector.

    Returns number

    The length of the vector

lengthSquared

  • lengthSquared(): number
  • Returns the squared length of the vector.

    Returns number

    The squared length of the vector

neg

negOut

  • Rotates the vector by 180 degrees and sets it's value to output(original vector does not changes).

    Parameters

    Returns Vector

    A negated vector

normalise

rotate

  • rotate(angle: number): Vector
  • Rotates the vector by the given angle.

    Parameters

    • angle: number

    Returns Vector

    A rotated vector

rotate270

rotate270Out

  • Rotates the vector by 270 degrees and sets it's value to output(original vector does not changes).

    Parameters

    Returns Vector

    The rotated vector

rotate90

rotate90Out

  • Rotates the vector by 90 degrees and sets it's value to output(original vector does not changes).

    Parameters

    Returns Vector

    The rotated vector

rotateOut

  • Rotates the vector by the given angle and sets it's value to output(original vector does not changes).

    Parameters

    • angle: number
    • output: Vector

    Returns Vector

    A rotated vector

scale

  • scale(scalar: number): Vector
  • Scales the vector by the given scalar.

    Parameters

    • scalar: number

      The scalar

    Returns Vector

    The scaled vector

scaleOut

  • Scales the vector by the given scalar and sets it's value to output(original vector does not changes).

    Parameters

    • scalar: number

      The scalar

    • output: Vector

    Returns Vector

    The scaled vector

set

  • set(x: number, y: number): Vector
  • Sets the coordinates of a vector to the given values.

    Parameters

    • x: number
    • y: number

    Returns Vector

    The vector

subtract

Static add

Static angle

  • angle(vectorA: Vector, vectorB?: undefined | Vector): number
  • Returns the angle between two vectors. If vectorB is undefined than returns the angle between vectorA and 'x' axis.

    Parameters

    Returns number

    The angle

Static cross

  • Returns the cross product of two vectors.

    Parameters

    Returns number

    The cross product of two vectors

Static dist

  • Returns the distance between two vectors.

    Parameters

    Returns number

    The distance between two vectors

Static distSquared

  • Returns the squared distance between two vectors.

    Parameters

    Returns number

    The squared distance between two vectors

Static distSquaredToZero

  • distSquaredToZero(vectorA: Vector, vectorB: Vector): number
  • Returns the squared distance between line segment and zero.

    Parameters

    Returns number

    The squared distance

Static dot

  • Returns the dot product of two vectors.

    Parameters

    Returns number

    The dot product of two vectors

Static interpolate

Static interpolateT

Static lineSegmentsIntersection

Static lineSegmentsIntersectionFraction

  • Returns the intersection fraction between two line segments.

    Parameters

    Returns undefined | number

    The intersection fraction

Static side

  • Returns true if the 'c' is on the left side of the line segment 'a-b' or false if not.

    Parameters

    Returns boolean

    True if the 'c' is on the left side of the line segment 'a-b' or false if not

Static subtract

Static zeroSide

  • Returns true if zero-vector is on the left side of the line segment 'a-b' or false if not.

    Parameters

    Returns boolean

    True if the zero-vector is on the left side of the line segment 'a-b' or false if not

Static zeroT

Generated using TypeDoc