2 Dimensional Vector Class
Item Index
Methods
add
-
out
-
a
-
b
Adds two vec2's
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the first operand
-
b
Vec2the second operand
Returns:
out
add3
-
out
-
a
-
b
-
c
Adds three vec2's
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the first operand
-
b
Vec2the second operand
-
c
Vec2the third operand
Returns:
out
clone
-
a
Creates a new vec2 initialized with values from an existing vector
Parameters:
-
a
Vec2vector to clone
Returns:
out
copy
-
out
-
a
Copy the values from one vec2 to another
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the 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:
-
out
Vec3the receiving vector
-
a
Vec2the first operand
-
b
Vec2the second operand
Returns:
out
distance
-
a
-
b
Calculates the euclidian distance between two vec2's
Parameters:
-
a
Vec2the first operand
-
b
Vec2the second operand
Returns:
CallExpression
divide
-
out
-
a
-
b
Divides two vec2's
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the first operand
-
b
Vec2the second operand
Returns:
out
dot
-
a
-
b
Calculates the dot product of two vec2's
Parameters:
-
a
Vec2the first operand
-
b
Vec2the 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:
-
out
Vec2the receiving vector
-
a
Vec2vector to invert
Returns:
out
Alias for {@link vec2.divide}
Alias for {@link vec2.subtract}
length
-
a
Calculates the length of a vec2
Parameters:
-
a
Vec2vector 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:
-
a
Arraythe array of vectors to iterate over
-
stride
NumberNumber of elements between the start of each vec2. If 0 assumes tightly packed
-
offset
NumberNumber of elements to skip at the beginning of the array
-
count
NumberNumber of vec2s to iterate over. If 0 iterates over entire array
-
fn
FunctionFunction 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:
-
out
Vec2the receiving vector
-
a
Vec2the first operand
-
b
Vec2the second operand
-
t
Numberinterpolation amount between the two inputs
Returns:
out
max
-
out
-
a
-
b
Returns the maximum of two vec2's
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the first operand
-
b
Vec2the second operand
Returns:
out
min
-
out
-
a
-
b
Returns the minimum of two vec2's
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the first operand
-
b
Vec2the second operand
Returns:
out
multiply
-
out
-
a
-
b
Multiplies two vec2's
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the first operand
-
b
Vec2the second operand
Returns:
out
negate
-
out
-
a
Negates the components of a vec2
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2vector to negate
Returns:
out
normalize
-
out
-
a
Normalize a vec2
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2vector to normalize
Returns:
out
normalizeAndScale
-
out
-
a
-
b
Normalize a vec2
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2vector to normalize
-
b
Object
Returns:
out
projectionToSegment
-
out
-
p
-
a
-
b
Calculates the shortest projection between a point and a line defined by two vec2's
Parameters:
-
out
Object -
p
Vec2the point
-
a
Vec2the first operand
-
b
Vec2the second operand
Returns:
CallExpression
random
-
out
-
scale
Generates a random vector with the given scale
Parameters:
-
out
Vec2the receiving vector
-
scale
Object
Returns:
out
scale
-
out
-
a
-
b
Scales a vec2 by a scalar number
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the vector to scale
-
b
Numberamount 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:
-
out
Vec2the receiving vector
-
a
Vec2the first operand
-
b
Vec2the second operand
-
scale
Numberthe 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:
-
a
Vec2the first operand
-
b
Vec2the second operand
Returns:
BinaryExpression
squaredLength
-
a
Calculates the squared length of a vec2
Parameters:
-
a
Vec2vector to calculate squared length of
Returns:
BinaryExpression
str
-
a
Returns a string representation of a vector
Parameters:
-
a
Object
Returns:
BinaryExpression
subtract
-
out
-
a
-
b
Subtracts vector b from vector a
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the first operand
-
b
Vec2the second operand
Returns:
out
transformMat2
-
out
-
a
-
m
Transforms the vec2 with a mat2
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the vector to transform
-
m
Mat2matrix to transform with
Returns:
out
transformMat2d
-
out
-
a
-
m
Transforms the vec2 with a mat2d
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the vector to transform
-
m
Mat2dmatrix to transform with
Returns:
out
transformMat3
-
out
-
a
-
m
Transforms the vec2 with a mat3 3rd vector component is implicitly '1'
Parameters:
-
out
Vec2the receiving vector
-
a
Vec2the vector to transform
-
m
Mat3matrix 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:
-
out
Vec2the receiving vector
-
a
Vec2the vector to transform
-
m
Mat4matrix to transform with
Returns:
out