# Namespace: vec2

# Table of contents

# Type aliases

# Functions

# Type aliases

# valueType

Ƭ valueType: vec2type

# Functions

# add

add(out: vec2type, a: vec2type, b: vec2type): vec2type

Adds two vec2's

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the first operand
b vec2type the second operand

Returns: vec2type

out


# angle

angle(a: vec2type, b: vec2type): number

Get the angle between two 2D vectors

# Parameters
Name Type Description
a vec2type The first operand
b vec2type The second operand

Returns: number

The angle in radians


# ceil

ceil(out: vec2type, a: vec2type): vec2type

Math.ceil the components of a vec2

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type vector to ceil

Returns: vec2type

out


# clone

clone(a: vec2type): vec2type

Creates a new vec2 initialized with values from an existing vector

# Parameters
Name Type Description
a vec2type vector to clone

Returns: vec2type

a new 2D vector


# copy

copy(out: vec2type, a: vec2type): vec2type

Copy the values from one vec2 to another

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the source vector

Returns: vec2type

out


# create

create(): vec2type

Creates a new, empty vec2

Returns: vec2type

a new 2D vector


# cross

cross(out: vec2type, a: vec2type, b: vec2type): vec2type

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

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the first operand
b vec2type the second operand

Returns: vec2type

out


# distance

distance(a: vec2type, b: vec2type): number

Calculates the euclidian distance between two vec2's

# Parameters
Name Type Description
a vec2type the first operand
b vec2type the second operand

Returns: number

distance between a and b


# divide

divide(out: vec2type, a: vec2type, b: vec2type): vec2type

Divides two vec2's

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the first operand
b vec2type the second operand

Returns: vec2type

out


# dot

dot(a: vec2type, b: vec2type): number

Calculates the dot product of two vec2's

# Parameters
Name Type Description
a vec2type the first operand
b vec2type the second operand

Returns: number

dot product of a and b


# equals

equals(a: vec2type, b: vec2type): boolean

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

# Parameters
Name Type Description
a vec2type The first vector.
b vec2type The second vector.

Returns: boolean

True if the vectors are equal, false otherwise.


# exactEquals

exactEquals(a: vec2type, b: vec2type): boolean

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

# Parameters
Name Type Description
a vec2type The first vector.
b vec2type The second vector.

Returns: boolean

True if the vectors are equal, false otherwise.


# floor

floor(out: vec2type, a: vec2type): vec2type

Math.floor the components of a vec2

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type vector to floor

Returns: vec2type

out


# forEach

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

Perform some operation over an array of vec2s.

function

# Parameters
Name Type Description
a any the array of vectors to iterate over
stride any Number of elements between the start of each vec2. If 0 assumes tightly packed
offset any Number of elements to skip at the beginning of the array
count any Number of vec2s to iterate over. If 0 iterates over entire array
fn any Function to call for each vector in the array
arg any -

Returns: any

a


# fromValues

fromValues(x: number, y: number): vec2type

Creates a new vec2 initialized with the given values

# Parameters
Name Type Description
x number X component
y number Y component

Returns: vec2type

a new 2D vector


# inverse

inverse(out: vec2type, a: vec2type): vec2type

Returns the inverse of the components of a vec2

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type vector to invert

Returns: vec2type

out


# length

length(a: vec2type): number

Calculates the length of a vec2

# Parameters
Name Type Description
a vec2type vector to calculate length of

Returns: number

length of a


# lerp

lerp(out: vec2type, a: vec2type, b: vec2type, t: number): vec2type

Performs a linear interpolation between two vec2's

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the first operand
b vec2type the second operand
t number interpolation amount, in the range [0-1], between the two inputs

Returns: vec2type

out


# max

max(out: vec2type, a: vec2type, b: vec2type): vec2type

Returns the maximum of two vec2's

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the first operand
b vec2type the second operand

Returns: vec2type

out


# min

min(out: vec2type, a: vec2type, b: vec2type): vec2type

Returns the minimum of two vec2's

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the first operand
b vec2type the second operand

Returns: vec2type

out


# multiply

multiply(out: vec2type, a: vec2type, b: vec2type): vec2type

Multiplies two vec2's

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the first operand
b vec2type the second operand

Returns: vec2type

out


# negate

negate(out: vec2type, a: vec2type): vec2type

Negates the components of a vec2

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type vector to negate

Returns: vec2type

out


# normalize

normalize(out: vec2type, a: vec2type): vec2type

Normalize a vec2

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type vector to normalize

Returns: vec2type

out


# random

random(out: vec2type, scale: number): vec2type

Generates a random vector with the given scale

# Parameters
Name Type Description
out vec2type the receiving vector
scale number -

Returns: vec2type

out


# rotate

rotate(out: vec2type, a: vec2type, b: vec2type, rad: number): vec2type

Rotate a 2D vector

# Parameters
Name Type Description
out vec2type The receiving vec2
a vec2type The vec2 point to rotate
b vec2type The origin of the rotation
rad number The angle of rotation in radians

Returns: vec2type

out


# round

round(out: vec2type, a: vec2type): vec2type

Math.round the components of a vec2

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type vector to round

Returns: vec2type

out


# scale

scale(out: vec2type, a: vec2type, b: number): vec2type

Scales a vec2 by a scalar number

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the vector to scale
b number amount to scale the vector by

Returns: vec2type

out


# scaleAndAdd

scaleAndAdd(out: vec2type, a: vec2type, b: vec2type, scale: number): vec2type

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

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the first operand
b vec2type the second operand
scale number the amount to scale b by before adding

Returns: vec2type

out


# set

set(out: vec2type, x: number, y: number): vec2type

Set the components of a vec2 to the given values

# Parameters
Name Type Description
out vec2type the receiving vector
x number X component
y number Y component

Returns: vec2type

out


# squaredDistance

squaredDistance(a: vec2type, b: vec2type): number

Calculates the squared euclidian distance between two vec2's

# Parameters
Name Type Description
a vec2type the first operand
b vec2type the second operand

Returns: number

squared distance between a and b


# squaredLength

squaredLength(a: vec2type): number

Calculates the squared length of a vec2

# Parameters
Name Type Description
a vec2type vector to calculate squared length of

Returns: number

squared length of a


# str

str(a: vec2type): string

Returns a string representation of a vector

# Parameters
Name Type Description
a vec2type vector to represent as a string

Returns: string

string representation of the vector


# subtract

subtract(out: vec2type, a: vec2type, b: vec2type): vec2type

Subtracts vector b from vector a

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the first operand
b vec2type the second operand

Returns: vec2type

out


# transformMat2

transformMat2(out: vec2type, a: vec2type, m: vec2type): vec2type

Transforms the vec2 with a mat2

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the vector to transform
m vec2type matrix to transform with

Returns: vec2type

out


# transformMat2d

transformMat2d(out: vec2type, a: vec2type, m: vec2type): vec2type

Transforms the vec2 with a mat2d

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the vector to transform
m vec2type matrix to transform with

Returns: vec2type

out


# transformMat3

transformMat3(out: vec2type, a: vec2type, m: vec2type): vec2type

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

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the vector to transform
m vec2type matrix to transform with

Returns: vec2type

out


# transformMat4

transformMat4(out: vec2type, a: vec2type, m: vec2type): vec2type

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

# Parameters
Name Type Description
out vec2type the receiving vector
a vec2type the vector to transform
m vec2type matrix to transform with

Returns: vec2type

out


# zero

zero(out: vec2type): vec2type

Set the components of a vec2 to zero

# Parameters
Name Type Description
out vec2type the receiving vector

Returns: vec2type

out

vjmap / Exports / vec3