dacha
    Preparing search index...

    Class Vector

    A 2D vector with x and y coordinates.

    Index
    x y
    • Creates a new vector with the given x and y coordinates.

      Parameters

      • x: number

        X coordinate of the vector

      • y: number

        Y coordinate of the vector

      Returns Vector

    x: number

    X coordinate of the vector

    y: number

    Y coordinate of the vector

    • get magnitude(): number

      Returns the Euclidean length of the vector.

      Returns number

      Magnitude of the vector

    • get squaredMagnitude(): number

      Returns the squared Euclidean length of the vector.

      Useful for distance comparisons that do not need the exact magnitude.

      Returns number

      Squared magnitude of the vector

    • Adds another vector to the current vector in place.

      Parameters

      • vector: Vector

        Vector to add

      Returns Vector

      The current vector after the addition

    • Creates a new vector with the same coordinates.

      Returns Vector

      A new vector with the same x and y coordinates

    • Checks whether another vector has the same coordinates.

      Parameters

      • vector: Vector

        Vector to compare with

      Returns boolean

      True if the vectors are equal, false otherwise

    • Multiplies the current vector by a scalar in place.

      Parameters

      • number: number

        Number to multiply by

      Returns Vector

      The current vector after scaling

    • Normalizes the current vector to unit length in place.

      If the vector magnitude is zero, it remains unchanged.

      Returns Vector

      The current vector after normalization