2 Dimensional Vector Class
Item Index
Methods
add
-
out -
a -
b
Adds two vec2's
Parameters:
-
outVec2the receiving vector
-
aVec2the first operand
-
bVec2the second operand
Returns:
out
add3
-
out -
a -
b -
c
Adds three vec2's
Parameters:
-
outVec2the receiving vector
-
aVec2the first operand
-
bVec2the second operand
-
cVec2the third operand
Returns:
out
clone
-
a
Creates a new vec2 initialized with values from an existing vector
Parameters:
-
aVec2vector to clone
Returns:
out
copy
-
out -
a
Copy the values from one vec2 to another
Parameters:
-
outVec2the receiving vector
-
aVec2the source vector
Returns:
out
create
()
Creates a new, empty vec2
Returns:
out
cross
-
out -
a -
b
Computes the cross product of two vec2's Note that the cross product must by definition produce a 3D vector
Parameters:
-
outVec3the receiving vector
-
aVec2the first operand
-
bVec2the second operand
Returns:
out
distance
-
a -
b
Calculates the euclidian distance between two vec2's
Parameters:
-
aVec2the first operand
-
bVec2the second operand
Returns:
CallExpression
divide
-
out -
a -
b
Divides two vec2's
Parameters:
-
outVec2the receiving vector
-
aVec2the first operand
-
bVec2the second operand
Returns:
out
dot
-
a -
b
Calculates the dot product of two vec2's
Parameters:
-
aVec2the first operand
-
bVec2the second operand
Returns:
BinaryExpression
fromValues
-
x -
y
Creates a new vec2 initialized with the given values
Returns:
out
inverse
-
out -
a
Returns the inverse of the components of a vec2
Parameters:
-
outVec2the receiving vector
-
aVec2vector to invert
Returns:
out
Alias for {@link vec2.divide}
Alias for {@link vec2.subtract}
length
-
a
Calculates the length of a vec2
Parameters:
-
aVec2vector to calculate length of
Returns:
CallExpression
Alias for {@link vec2.squaredLength}
Alias for {@link vec2.length}
Alias for {@link vec2.multiply}
Alias for {@link vec2.distance}
-
a -
stride -
offset -
count -
fn -
[arg]
Perform some operation over an array of vec2s.
Parameters:
-
aArraythe array of vectors to iterate over
-
strideNumberNumber of elements between the start of each vec2. If 0 assumes tightly packed
-
offsetNumberNumber of elements to skip at the beginning of the array
-
countNumberNumber of vec2s to iterate over. If 0 iterates over entire array
-
fnFunctionFunction to call for each vector in the array
-
[arg]Object optionaladditional argument to pass to fn
Returns:
a
Alias for {@link vec2.squaredDistance}
lerp
-
out -
a -
b -
t
Performs a linear interpolation between two vec2's
Parameters:
-
outVec2the receiving vector
-
aVec2the first operand
-
bVec2the second operand
-
tNumberinterpolation amount between the two inputs
Returns:
out
max
-
out -
a -
b
Returns the maximum of two vec2's
Parameters:
-
outVec2the receiving vector
-
aVec2the first operand
-
bVec2the second operand
Returns:
out
min
-
out -
a -
b
Returns the minimum of two vec2's
Parameters:
-
outVec2the receiving vector
-
aVec2the first operand
-
bVec2the second operand
Returns:
out
multiply
-
out -
a -
b
Multiplies two vec2's
Parameters:
-
outVec2the receiving vector
-
aVec2the first operand
-
bVec2the second operand
Returns:
out
negate
-
out -
a
Negates the components of a vec2
Parameters:
-
outVec2the receiving vector
-
aVec2vector to negate
Returns:
out
normalize
-
out -
a
Normalize a vec2
Parameters:
-
outVec2the receiving vector
-
aVec2vector to normalize
Returns:
out
normalizeAndScale
-
out -
a -
b
Normalize a vec2
Parameters:
-
outVec2the receiving vector
-
aVec2vector to normalize
-
bObject
Returns:
out
projectionToSegment
-
out -
p -
a -
b
Calculates the shortest projection between a point and a line defined by two vec2's
Parameters:
-
outObject -
pVec2the point
-
aVec2the first operand
-
bVec2the second operand
Returns:
CallExpression
random
-
out -
scale
Generates a random vector with the given scale
Parameters:
-
outVec2the receiving vector
-
scaleObject
Returns:
out
scale
-
out -
a -
b
Scales a vec2 by a scalar number
Parameters:
-
outVec2the receiving vector
-
aVec2the vector to scale
-
bNumberamount to scale the vector by
Returns:
out
scaleAndAdd
-
out -
a -
b -
scale
Adds two vec2's after scaling the second operand by a scalar value
Parameters:
-
outVec2the receiving vector
-
aVec2the first operand
-
bVec2the second operand
-
scaleNumberthe amount to scale b by before adding
Returns:
out
set
-
out -
x -
y
Set the components of a vec2 to the given values
Returns:
out
squaredDistance
-
a -
b
Calculates the squared euclidian distance between two vec2's
Parameters:
-
aVec2the first operand
-
bVec2the second operand
Returns:
BinaryExpression
squaredLength
-
a
Calculates the squared length of a vec2
Parameters:
-
aVec2vector to calculate squared length of
Returns:
BinaryExpression
str
-
a
Returns a string representation of a vector
Parameters:
-
aObject
Returns:
BinaryExpression
subtract
-
out -
a -
b
Subtracts vector b from vector a
Parameters:
-
outVec2the receiving vector
-
aVec2the first operand
-
bVec2the second operand
Returns:
out
transformMat2
-
out -
a -
m
Transforms the vec2 with a mat2
Parameters:
-
outVec2the receiving vector
-
aVec2the vector to transform
-
mMat2matrix to transform with
Returns:
out
transformMat2d
-
out -
a -
m
Transforms the vec2 with a mat2d
Parameters:
-
outVec2the receiving vector
-
aVec2the vector to transform
-
mMat2dmatrix to transform with
Returns:
out
transformMat3
-
out -
a -
m
Transforms the vec2 with a mat3 3rd vector component is implicitly '1'
Parameters:
-
outVec2the receiving vector
-
aVec2the vector to transform
-
mMat3matrix to transform with
Returns:
out
transformMat4
-
out -
a -
m
Transforms the vec2 with a mat4 3rd vector component is implicitly '0' 4th vector component is implicitly '1'
Parameters:
-
outVec2the receiving vector
-
aVec2the vector to transform
-
mMat4matrix to transform with
Returns:
out
