vec2

vec2()

2 Dimensional Vector

Methods

inneradd$8(out, a, b)vec2

Adds two vec2's
Name Type Description
out vec2 the receiving vector
a vec2 the first operand
b vec2 the second operand
Returns:
out

innerangle$1(a, b)Number

Get the angle between two 2D vectors
Name Type Description
a vec2 The first operand
b vec2 The second operand
Returns:
The angle in radians

innerceil$2(out, a)vec2

Math.ceil the components of a vec2
Name Type Description
out vec2 the receiving vector
a vec2 vector to ceil
Returns:
out

innerclone$8(a)vec2

Creates a new vec2 initialized with values from an existing vector
Name Type Description
a vec2 vector to clone
Returns:
a new 2D vector

innercopy$8(out, a)vec2

Copy the values from one vec2 to another
Name Type Description
out vec2 the receiving vector
a vec2 the source vector
Returns:
out

innercreate$8()vec2

Creates a new, empty vec2
Returns:
a new 2D vector

innercross$2(out, a, b)vec3

Computes the cross product of two vec2's Note that the cross product must by definition produce a 3D vector
Name Type Description
out vec3 the receiving vector
a vec2 the first operand
b vec2 the second operand
Returns:
out

innerdist$2()

Alias for vec2.distance

innerdistance$2(a, b)Number

Calculates the euclidian distance between two vec2's
Name Type Description
a vec2 the first operand
b vec2 the second operand
Returns:
distance between a and b

innerdiv$2()

Alias for vec2.divide

innerdivide$2(out, a, b)vec2

Divides two vec2's
Name Type Description
out vec2 the receiving vector
a vec2 the first operand
b vec2 the second operand
Returns:
out

innerdot$4(a, b)Number

Calculates the dot product of two vec2's
Name Type Description
a vec2 the first operand
b vec2 the second operand
Returns:
dot product of a and b

innerequals$9(a, b)Boolean

Returns whether or not the vectors have approximately the same elements in the same position.
Name Type Description
a vec2 The first vector.
b vec2 The second vector.
Returns:
True if the vectors are equal, false otherwise.

innerexactEquals$8(a, b)Boolean

Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
Name Type Description
a vec2 The first vector.
b vec2 The second vector.
Returns:
True if the vectors are equal, false otherwise.

innerfloor$2(out, a)vec2

Math.floor the components of a vec2
Name Type Description
out vec2 the receiving vector
a vec2 vector to floor
Returns:
out

innerforEach$2(a, stride, offset, count, fn, arg)Array

Perform some operation over an array of vec2s.
Name Type Description
a Array the array of vectors to iterate over
stride Number Number of elements between the start of each vec2. If 0 assumes tightly packed
offset Number Number of elements to skip at the beginning of the array
count Number Number of vec2s to iterate over. If 0 iterates over entire array
fn function Function to call for each vector in the array
arg Object optional additional argument to pass to fn
Returns:
a

innerfromValues$8(x, y)vec2

Creates a new vec2 initialized with the given values
Name Type Description
x Number X component
y Number Y component
Returns:
a new 2D vector

innerinverse$2(out, a)vec2

Returns the inverse of the components of a vec2
Name Type Description
out vec2 the receiving vector
a vec2 vector to invert
Returns:
out

innerlen$4()

Alias for vec2.length

innerlength$4(a)Number

Calculates the length of a vec2
Name Type Description
a vec2 vector to calculate length of
Returns:
length of a

innerlerp$4(out, a, b, t)vec2

Performs a linear interpolation between two vec2's
Name Type Description
out vec2 the receiving vector
a vec2 the first operand
b vec2 the second operand
t Number interpolation amount, in the range [0-1], between the two inputs
Returns:
out

innermax$2(out, a, b)vec2

Returns the maximum of two vec2's
Name Type Description
out vec2 the receiving vector
a vec2 the first operand
b vec2 the second operand
Returns:
out

innermin$2(out, a, b)vec2

Returns the minimum of two vec2's
Name Type Description
out vec2 the receiving vector
a vec2 the first operand
b vec2 the second operand
Returns:
out

innermul$8()

Alias for vec2.multiply

innermultiply$8(out, a, b)vec2

Multiplies two vec2's
Name Type Description
out vec2 the receiving vector
a vec2 the first operand
b vec2 the second operand
Returns:
out

innernegate$2(out, a)vec2

Negates the components of a vec2
Name Type Description
out vec2 the receiving vector
a vec2 vector to negate
Returns:
out

innernormalize$4(out, a)vec2

Normalize a vec2
Name Type Description
out vec2 the receiving vector
a vec2 vector to normalize
Returns:
out

innerrandom$3(out, scale)vec2

Generates a random vector with the given scale
Name Type Description
out vec2 the receiving vector
scale Number optional Length of the resulting vector. If ommitted, a unit vector will be returned
Returns:
out

innerrotate$4(out, a, b, c)vec2

Rotate a 2D vector
Name Type Description
out vec2 The receiving vec2
a vec2 The vec2 point to rotate
b vec2 The origin of the rotation
c Number The angle of rotation
Returns:
out

innerround$2(out, a)vec2

Math.round the components of a vec2
Name Type Description
out vec2 the receiving vector
a vec2 vector to round
Returns:
out

innerscale$8(out, a, b)vec2

Scales a vec2 by a scalar number
Name Type Description
out vec2 the receiving vector
a vec2 the vector to scale
b Number amount to scale the vector by
Returns:
out

innerscaleAndAdd$2(out, a, b, scale)vec2

Adds two vec2's after scaling the second operand by a scalar value
Name Type Description
out vec2 the receiving vector
a vec2 the first operand
b vec2 the second operand
scale Number the amount to scale b by before adding
Returns:
out

innerset$8(out, x, y)vec2

Set the components of a vec2 to the given values
Name Type Description
out vec2 the receiving vector
x Number X component
y Number Y component
Returns:
out

innersqrDist$2()

Alias for vec2.squaredDistance

innersqrLen$4()

Alias for vec2.squaredLength

innersquaredDistance$2(a, b)Number

Calculates the squared euclidian distance between two vec2's
Name Type Description
a vec2 the first operand
b vec2 the second operand
Returns:
squared distance between a and b

innersquaredLength$4(a)Number

Calculates the squared length of a vec2
Name Type Description
a vec2 vector to calculate squared length of
Returns:
squared length of a

innerstr$8(a)String

Returns a string representation of a vector
Name Type Description
a vec2 vector to represent as a string
Returns:
string representation of the vector

innersub$6()

Alias for vec2.subtract

innersubtract$6(out, a, b)vec2

Subtracts vector b from vector a
Name Type Description
out vec2 the receiving vector
a vec2 the first operand
b vec2 the second operand
Returns:
out

innertransformMat2(out, a, m)vec2

Transforms the vec2 with a mat2
Name Type Description
out vec2 the receiving vector
a vec2 the vector to transform
m mat2 matrix to transform with
Returns:
out

innertransformMat2d(out, a, m)vec2

Transforms the vec2 with a mat2d
Name Type Description
out vec2 the receiving vector
a vec2 the vector to transform
m mat2d matrix to transform with
Returns:
out

innertransformMat3$1(out, a, m)vec2

Transforms the vec2 with a mat3 3rd vector component is implicitly '1'
Name Type Description
out vec2 the receiving vector
a vec2 the vector to transform
m mat3 matrix to transform with
Returns:
out

innertransformMat4$2(out, a, m)vec2

Transforms the vec2 with a mat4 3rd vector component is implicitly '0' 4th vector component is implicitly '1'
Name Type Description
out vec2 the receiving vector
a vec2 the vector to transform
m mat4 matrix to transform with
Returns:
out

innerzero$2(out)vec2

Set the components of a vec2 to zero
Name Type Description
out vec2 the receiving vector
Returns:
out