Vector2

Hierarchy

Index

Constructors

constructor

  • new Vector2(x: number, y: number): Vector2
  • Creates a new Vector2 from the given x and y coordinates.

    Parameters

    • x: number
    • y: number

    Returns Vector2

Properties

x

x: number

y

y: number

Methods

add

  • Returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates.

    Parameters

    Returns Vector2

addInPlace

  • Set the Vector2 coordinates by adding the given Vector2 coordinates. Returns the updated Vector2.

    Parameters

    Returns Vector2

addToRef

  • Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates. Returns the Vector2.

    Parameters

    Returns Vector2

addVector3

  • Returns a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates.

    Parameters

    Returns Vector2

asArray

  • asArray(): number[]
  • Returns a new array with 2 elements : the Vector2 coordinates.

    Returns number[]

clone

  • Returns a new Vector2 copied from the Vector2.

    Returns Vector2

copyFrom

  • Sets the Vector2 coordinates with the given Vector2 coordinates. Returns the updated Vector2.

    Parameters

    Returns Vector2

copyFromFloats

  • copyFromFloats(x: number, y: number): Vector2
  • Sets the Vector2 coordinates with the given floats. Returns the updated Vector2.

    Parameters

    • x: number
    • y: number

    Returns Vector2

divide

  • Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates.

    Parameters

    Returns Vector2

divideInPlace

  • Divides the current Vector3 coordinates by the given ones. Returns the updated Vector3.

    Parameters

    Returns Vector2

divideToRef

  • Sets the "result" coordinates with the Vector2 divided by the given one coordinates. Returns the Vector2.

    Parameters

    Returns Vector2

equals

  • equals(otherVector: Vector2): boolean
  • Boolean : True if the given vector coordinates strictly equal the current Vector2 ones.

    Parameters

    Returns boolean

equalsWithEpsilon

  • equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean
  • Boolean : True if the given vector coordinates are close to the current ones by a distance of epsilon.

    Parameters

    • otherVector: Vector2
    • Optional epsilon: number

    Returns boolean

getClassName

  • getClassName(): string
  • Returns the string "Vector2"

    Returns string

getHashCode

  • getHashCode(): number
  • Returns the Vector2 hash code as a number.

    Returns number

length

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

    Returns number

lengthSquared

  • lengthSquared(): number
  • Returns the vector squared length (float);

    Returns number

multiply

  • Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates.

    Parameters

    Returns Vector2

multiplyByFloats

  • multiplyByFloats(x: number, y: number): Vector2
  • Returns a new Vector2 set with the Vector2 coordinates multiplied by the given floats.

    Parameters

    • x: number
    • y: number

    Returns Vector2

multiplyInPlace

  • Multiplies in place the current Vector2 coordinates by the given ones. Returns the updated Vector2.

    Parameters

    Returns Vector2

multiplyToRef

  • Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates. Returns the Vector2.

    Parameters

    Returns Vector2

negate

  • Returns a new Vector2 with current Vector2 negated coordinates.

    Returns Vector2

normalize

  • Normalize the vector. Returns the updated Vector2.

    Returns Vector2

scale

  • Returns a new Vector2 scaled by "scale" from the current Vector2.

    Parameters

    • scale: number

    Returns Vector2

scaleAndAddToRef

  • Scale the current Vector2 values by a factor and add the result to a given Vector2

    Parameters

    • scale: number

      defines the scale factor

    • result: Vector2

      defines the Vector2 object where to store the result

    Returns Vector2

    the unmodified current Vector2

scaleInPlace

  • scaleInPlace(scale: number): Vector2
  • Multiply the Vector2 coordinates by scale. Returns the updated Vector2.

    Parameters

    • scale: number

    Returns Vector2

scaleToRef

  • Scale the current Vector2 values by a factor to a given Vector2

    Parameters

    • scale: number

      defines the scale factor

    • result: Vector2

      defines the Vector2 object where to store the result

    Returns Vector2

    the unmodified current Vector2

set

  • set(x: number, y: number): Vector2
  • Sets the Vector2 coordinates with the given floats. Returns the updated Vector2.

    Parameters

    • x: number
    • y: number

    Returns Vector2

subtract

  • Returns a new Vector2 set with the subtracted coordinates of the given one from the current Vector2.

    Parameters

    Returns Vector2

subtractInPlace

  • Sets the current Vector2 coordinates by subtracting from it the given one coordinates. Returns the updated Vector2.

    Parameters

    Returns Vector2

subtractToRef

  • Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates. Returns the Vector2.

    Parameters

    Returns Vector2

toArray

  • Sets the Vector2 coordinates in the given array or Float32Array from the given index. Returns the Vector2.

    Parameters

    Returns Vector2

toString

  • toString(): string
  • Returns a string with the Vector2 coordinates.

    Returns string

Static CatmullRom

  • Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2.

    Parameters

    Returns Vector2

Static Center

  • Returns a new Vecto2 located at the center of the vectors "value1" and "value2".

    Parameters

    Returns Vector2

Static Clamp

  • Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.

    Parameters

    Returns Vector2

Static Distance

  • Returns the distance (float) between the vectors "value1" and "value2".

    Parameters

    Returns number

Static DistanceOfPointFromSegment

  • Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".

    Parameters

    Returns number

Static DistanceSquared

  • Returns the squared distance (float) between the vectors "value1" and "value2".

    Parameters

    Returns number

Static Dot

  • Returns the dot product (float) of the vector "left" and the vector "right".

    Parameters

    Returns number

Static FromArray

  • FromArray(array: ArrayLike<number>, offset?: number): Vector2
  • Returns a new Vector2 set from the given index element of the given array.

    Parameters

    • array: ArrayLike<number>
    • Optional offset: number

    Returns Vector2

Static FromArrayToRef

  • FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void
  • Sets "result" from the given index element of the given array.

    Parameters

    • array: ArrayLike<number>
    • offset: number
    • result: Vector2

    Returns void

Static Hermite

  • Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".

    Parameters

    Returns Vector2

Static Lerp

  • Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".

    Parameters

    Returns Vector2

Static Maximize

  • Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.

    Parameters

    Returns Vector2

Static Minimize

  • Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.

    Parameters

    Returns Vector2

Static Normalize

  • Returns a new Vector2 equal to the normalized given vector.

    Parameters

    Returns Vector2

Static One

  • Returns a new Vector2(1, 1)

    Returns Vector2

Static PointInTriangle

  • Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"

    Parameters

    Returns boolean

Static Transform

  • Returns a new Vecto2 set with the transformed coordinates of the given vector by the given transformation matrix.

    Parameters

    Returns Vector2

Static TransformToRef

  • Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates.

    Parameters

    Returns void

Static Zero

  • Returns a new Vector2(0, 0)

    Returns Vector2

Generated using TypeDoc