@minecraft/math
    Preparing search index...

    Class Vector2Utils

    Utilities operating on Vector2 objects. All methods are static and do not modify the input objects.

    Index

    Constructors

    Methods

    • add

      Add two vectors to produce a new vector

      Parameters

      • v1: Vector2
      • v2: Partial<Vector2>

      Returns Vector2

    • clamp

      Clamps the components of a vector to limits to produce a new vector

      Parameters

      • v: Vector2
      • Optionallimits: { max?: Partial<Vector2>; min?: Partial<Vector2> }

      Returns Vector2

    • distance

      Calculate the distance between two vectors

      Parameters

      • a: Vector2
      • b: Vector2

      Returns number

    • dot

      Calculate the dot product of two vectors

      Parameters

      • a: Vector2
      • b: Vector2

      Returns number

    • equals

      Check the equality of two vectors

      Parameters

      • v1: Vector2
      • v2: Vector2

      Returns boolean

    • floor

      Floor the components of a vector to produce a new vector

      Parameters

      • v: Vector2

      Returns Vector2

    • fromString

      Gets a Vector2 from the string representation produced by Vector2Utils.toString. If any numeric value is not a number or the format is invalid, undefined is returned.

      Parameters

      • str: string

        The string to parse

      • Optionaldelimiter: string

        The delimiter used to separate the components. Defaults to the same as the default for Vector2Utils.toString

      Returns undefined | Vector2

    • lerp

      Constructs a new vector using linear interpolation on each component from two vectors.

      Parameters

      • a: Vector2
      • b: Vector2
      • t: number

      Returns Vector2

    • magnitude

      The magnitude of a vector

      Parameters

      • v: Vector2

      Returns number

    • multiply

      Element-wise multiplication of two vectors together. Not to be confused with Vector2Utils.dot product

      Parameters

      • a: Vector2
      • b: Vector2

      Returns Vector2

    • normalize

      Takes a vector 3 and normalizes it to a unit vector

      Parameters

      • v: Vector2

      Returns Vector2

    • scale

      Multiple all entries in a vector by a single scalar value producing a new vector

      Parameters

      • v1: Vector2
      • scale: number

      Returns Vector2

    • slerp

      Constructs a new vector using spherical linear interpolation on each component from two vectors.

      Parameters

      • a: Vector2
      • b: Vector2
      • t: number

      Returns Vector2

    • subtract

      Subtract two vectors to produce a new vector (v1-v2)

      Parameters

      • v1: Vector2
      • v2: Partial<Vector2>

      Returns Vector2

    • toString

      Create a string representation of a vector2

      Parameters

      • v: Vector2
      • Optionaloptions: { decimals?: number; delimiter?: string }

      Returns string