Options
All
• Public
• Public/Protected
• All

# Namespace vec2

## Functions

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

out

### angle

• Get the angle between two 2D vectors

#### Parameters

The first operand

The second operand

### ceil

• ceil(out: vec2, a: ReadonlyVec2): vec2
• Math.ceil the components of a vec2

#### Parameters

• ##### out: vec2

the receiving vector

vector to ceil

out

### clone

• Creates a new vec2 initialized with values from an existing vector

#### Parameters

vector to clone

#### Returns vec2

a new 2D vector

### copy

• copy(out: vec2, a: ReadonlyVec2): vec2
• Copy the values from one vec2 to another

#### Parameters

• ##### out: vec2

the receiving vector

the source vector

out

### create

• Creates a new, empty vec2

#### Returns vec2

a new 2D vector

### cross

• Computes the cross product of two vec2's Note that the cross product must by definition produce a 3D vector

#### Parameters

• ##### out: vec3

the receiving vector

the first operand

the second operand

out

### dist

• Calculates the euclidian distance between two vec2's

#### Parameters

the first operand

the second operand

#### Returns number

distance between a and b

### distance

• Calculates the euclidian distance between two vec2's

#### Parameters

the first operand

the second operand

#### Returns number

distance between a and b

### div

• Divides two vec2's

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

out

### divide

• Divides two vec2's

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

out

### dot

• Calculates the dot product of two vec2's

#### Parameters

the first operand

the second operand

#### Returns number

dot product of a and b

### equals

• Returns whether or not the vectors have approximately the same elements in the same position.

#### Parameters

The first vector.

The second vector.

#### Returns boolean

True if the vectors are equal, false otherwise.

### exactEquals

• Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)

#### Parameters

The first vector.

The second vector.

#### Returns boolean

True if the vectors are equal, false otherwise.

### floor

• floor(out: vec2, a: ReadonlyVec2): vec2
• Math.floor the components of a vec2

#### Parameters

• ##### out: vec2

the receiving vector

vector to floor

out

### forEach

• forEach(a: any, stride: any, offset: any, count: any, fn: any, arg: any): any

### fromValues

• fromValues(x: number, y: number): vec2
• Creates a new vec2 initialized with the given values

#### Parameters

• ##### x: number

X component

• ##### y: number

Y component

#### Returns vec2

a new 2D vector

### inverse

• inverse(out: vec2, a: ReadonlyVec2): vec2
• Returns the inverse of the components of a vec2

#### Parameters

• ##### out: vec2

the receiving vector

vector to invert

out

### len

• Calculates the length of a vec2

#### Parameters

vector to calculate length of

length of a

### length

• Calculates the length of a vec2

#### Parameters

vector to calculate length of

length of a

### lerp

• Performs a linear interpolation between two vec2's

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

• ##### t: number

interpolation amount, in the range [0-1], between the two inputs

out

### max

• Returns the maximum of two vec2's

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

out

### min

• Returns the minimum of two vec2's

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

out

### mul

• Multiplies two vec2's

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

out

### multiply

• Multiplies two vec2's

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

out

### negate

• negate(out: vec2, a: ReadonlyVec2): vec2
• Negates the components of a vec2

#### Parameters

• ##### out: vec2

the receiving vector

vector to negate

out

### normalize

• normalize(out: vec2, a: ReadonlyVec2): vec2
• Normalize a vec2

#### Parameters

• ##### out: vec2

the receiving vector

vector to normalize

out

### random

• random(out: vec2, scale?: number): vec2
• Generates a random vector with the given scale

#### Parameters

• ##### out: vec2

the receiving vector

out

### rotate

• Rotate a 2D vector

#### Parameters

• ##### out: vec2

The receiving vec2

The vec2 point to rotate

The origin of the rotation

The angle of rotation in radians

out

### round

• round(out: vec2, a: ReadonlyVec2): vec2
• Math.round the components of a vec2

#### Parameters

• ##### out: vec2

the receiving vector

vector to round

out

### scale

• scale(out: vec2, a: ReadonlyVec2, b: number): vec2
• Scales a vec2 by a scalar number

#### Parameters

• ##### out: vec2

the receiving vector

the vector to scale

• ##### b: number

amount to scale the vector by

#### Returns vec2

out

• Adds two vec2's after scaling the second operand by a scalar value

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

• ##### scale: number

the amount to scale b by before adding

out

### set

• set(out: vec2, x: number, y: number): vec2
• Set the components of a vec2 to the given values

#### Parameters

• ##### out: vec2

the receiving vector

• ##### x: number

X component

• ##### y: number

Y component

out

### sqrDist

• Calculates the squared euclidian distance between two vec2's

#### Parameters

the first operand

the second operand

#### Returns number

squared distance between a and b

### sqrLen

• Calculates the squared length of a vec2

#### Parameters

vector to calculate squared length of

#### Returns number

squared length of a

### squaredDistance

• Calculates the squared euclidian distance between two vec2's

#### Parameters

the first operand

the second operand

#### Returns number

squared distance between a and b

### squaredLength

• Calculates the squared length of a vec2

#### Parameters

vector to calculate squared length of

#### Returns number

squared length of a

### str

• Returns a string representation of a vector

#### Parameters

vector to represent as a string

#### Returns string

string representation of the vector

### sub

• Subtracts vector b from vector a

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

out

### subtract

• Subtracts vector b from vector a

#### Parameters

• ##### out: vec2

the receiving vector

the first operand

the second operand

out

### transformMat2

• Transforms the vec2 with a mat2

#### Parameters

• ##### out: vec2

the receiving vector

the vector to transform

matrix to transform with

out

### transformMat2d

• Transforms the vec2 with a mat2d

#### Parameters

• ##### out: vec2

the receiving vector

the vector to transform

matrix to transform with

out

### transformMat3

• Transforms the vec2 with a mat3 3rd vector component is implicitly '1'

#### Parameters

• ##### out: vec2

the receiving vector

the vector to transform

matrix to transform with

out

### transformMat4

• Transforms the vec2 with a mat4 3rd vector component is implicitly '0' 4th vector component is implicitly '1'

#### Parameters

• ##### out: vec2

the receiving vector

the vector to transform

matrix to transform with

out

### zero

• Set the components of a vec2 to zero

#### Parameters

• ##### out: vec2

the receiving vector

out