Stores and manipulates a twodimensional vector comprised of the components x and y

           +y
            |__ +x

Authors

Lukas Scheuerle, Jirka Dell'Oro-Friedl, HFU, 2019

Hierarchy (view full)

Implements

Constructors

Properties

x: number
y: number

Accessors

  • get magnitudeSquared(): number
  • Returns the square of the magnitude of the vector without calculating a square root. Faster for simple proximity evaluation.

    Returns number

  • get type(): string
  • Retrieves the type of this mutable subclass as the name of the runtime class

    Returns string

    The type of the mutable

Methods

  • Returns true if the coordinates of this and the given vector are to be considered identical within the given tolerance TODO: examine, if tolerance as criterium for the difference is appropriate with very large coordinate values or if _tolerance should be multiplied by coordinate value

    Parameters

    • _compare: Vector2
    • _tolerance: number = Number.EPSILON

    Returns boolean

  • Collect applicable attributes of the instance and copies of their values in a Mutator-object. By default, a mutator cannot be extended, since extensions are not available in the object the mutator belongs to. A mutator may be reduced by the descendants of Mutable to contain only the properties needed.

    Returns Mutator

  • Uses the standard array.map functionality to perform the given function on all components of this vector and return a new vector with the results

    Parameters

    • _function: ((value, index, array) => number)
        • (value, index, array): number
        • Parameters

          • value: number
          • index: number
          • array: ArrayLike<number>

          Returns number

    Returns Vector2

  • Updates the attribute values of the instance according to the state of the mutator. The mutation may be restricted to a subset of the mutator and the event dispatching suppressed. Uses mutateBase, but can be overwritten in subclasses

    Parameters

    • _mutator: Mutator
    • _selection: string[] = null
    • _dispatchMutate: boolean = true

    Returns Promise<void>

  • Transforms this vector by the given matrix, including or exluding the translation. Including is the default, excluding will only rotate and scale this vector.

    Parameters

    • _mtxTransform: Matrix3x3
    • _includeTranslation: boolean = true

    Returns Vector2

  • Calculates the cross product of two Vectors. Due to them being only 2 Dimensional, the result is a single number, which implicitly is on the Z axis. It is also the signed magnitude of the result.

    Parameters

    Returns number

  • Calculates the orthogonal vector to the given vector. Rotates counterclockwise by default.

    ↑ => ← => ↓ => → => ↑
    

    Parameters

    • _vector: Vector2

      Vector to get the orthogonal equivalent of

    • _clockwise: boolean = false

      Should the rotation be clockwise instead of the default counterclockwise? default: false

    Returns Vector2

    A Vector that is orthogonal to and has the same magnitude as the given Vector.

  • Creates and returns a vector through transformation of the given vector by the given matrix

    Parameters

    Returns Vector2

  • A shorthand for writing new Vector2(x, 0).

    Parameters

    • _scale: number = 1

      The number to write in the x coordinate. Default: 1

    Returns Vector2

    A new vector with the values (_scale, 0)

  • A shorthand for writing new Vector2(0, y).

    Parameters

    • _scale: number = 1

      The number to write in the y coordinate. Default: 1

    Returns Vector2

    A new vector with the values (0, _scale)