kick.math.Vec2 Class
Vec2 - 2 dimensional vector Any javascript array containing at least 2 numeric elements can serve as a vec2
Item Index
Methods
- add static
- array static
- clone static
- copy static
- create static
- cross static
- distance static
- divide static
- dot static
- equal static
- forEach static
- fromValues static
- length static
- lerp static
- max static
- min static
- multiply static
- negate static
- normalize static
- scale static
- set static
- squaredDistance static
- squaredLength static
- str static
- subtract static
- transformMat2 static
- transformMat2d static
- transformMat3 static
- transformMat4 static
- wrapArray static
Methods
add
-
out
-
a
-
b
Adds two vec2's
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the first operand
-
b
kick.math.Vec2the second operand
Returns:
out
array
-
count
-
ref
Create a continuous array in memory mapped to vec2.
Parameters:
-
count
NumberNumber of vec 2 to be layed out in memory
-
ref
ObjectOptional, if set a memory reference is set to ref.mem
Returns:
New vec2
clone
-
a
Parameters:
-
a
kick.math.Vec2vector to clone
Returns:
a new 2D vector
copy
-
out
-
a
Copies the values of one vec2 to another
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the source vector
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
kick.math.Vec3the receiving vector
-
a
kick.math.Vec2the first operand
-
b
kick.math.Vec2the second operand
Returns:
out
distance
-
a
-
b
Calculates the euclidian distance between two vec2's
Parameters:
-
a
kick.math.Vec2the first operand
-
b
kick.math.Vec2the second operand
Returns:
distance between a and b
divide
-
out
-
a
-
b
Divides two vec2's
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the first operand
-
b
kick.math.Vec2the second operand
Returns:
out
dot
-
a
-
b
Calculates the dot product of two vec2's
Parameters:
-
a
kick.math.Vec2the first operand
-
b
kick.math.Vec2the second operand
Returns:
dot product of a and b
equal
-
vec
-
vec2
-
epsilon
Test to see if vectors are equal (difference is less than epsilon)
Parameters:
-
vec
kick.math.Vec2first operand
-
vec2
kick.math.Vec2second operand
-
epsilon
NumberOptional - default value is
Returns:
true if two vectors are equals
forEach
-
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
fromValues
-
x
-
y
Creates a new vec2 initialized with the given values
Parameters:
-
x
NumberX component
-
y
NumberY component
Returns:
a new 2D vector
length
-
a
Calculates the length of a vec2
Parameters:
-
a
kick.math.Vec2vector to calculate length of
Returns:
length of a
lerp
-
out
-
a
-
b
-
t
Performs a linear interpolation between two vec2's
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the first operand
-
b
kick.math.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
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the first operand
-
b
kick.math.Vec2the second operand
Returns:
out
min
-
out
-
a
-
b
Returns the minimum of two vec2's
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the first operand
-
b
kick.math.Vec2the second operand
Returns:
out
multiply
-
out
-
a
-
b
Multiplies two vec2's
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the first operand
-
b
kick.math.Vec2the second operand
Returns:
out
negate
-
out
-
a
Negates the components of a vec2
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2vector to negate
Returns:
out
normalize
-
out
-
a
Normalize a vec2
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2vector to normalize
Returns:
out
scale
-
out
-
a
-
b
Scales a vec2 by a scalar number
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the vector to scale
-
b
Numberamount to scale the vector by
Returns:
out
set
-
out
-
x
-
y
Set the components of a vec2 to the given values
Parameters:
-
out
kick.math.Vec2the receiving vector
-
x
NumberX component
-
y
NumberY component
Returns:
out
squaredDistance
-
a
-
b
Calculates the squared euclidian distance between two vec2's
Parameters:
-
a
kick.math.Vec2the first operand
-
b
kick.math.Vec2the second operand
Returns:
squared distance between a and b
squaredLength
-
a
Calculates the squared length of a vec2
Parameters:
-
a
kick.math.Vec2vector to calculate squared length of
Returns:
squared length of a
str
-
vec
Returns a string representation of a vector
Parameters:
-
vec
kick.math.Vec2vec2 to represent as a string
Returns:
string representation of vec
subtract
-
out
-
a
-
b
Subtracts two vec2's
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the first operand
-
b
kick.math.Vec2the second operand
Returns:
out
transformMat2
-
out
-
a
-
m
Transforms the vec2 with a mat2
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the vector to transform
-
m
kick.math.Mat2matrix to transform with
Returns:
out
transformMat2d
-
out
-
a
-
m
Transforms the vec2 with a mat2d
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the vector to transform
-
m
kick.math.Mat2dmatrix to transform with
Returns:
out
transformMat3
-
out
-
a
-
m
Transforms the vec2 with a mat3 3rd vector component is implicitly '1'
Parameters:
-
out
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the vector to transform
-
m
kick.math.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
kick.math.Vec2the receiving vector
-
a
kick.math.Vec2the vector to transform
-
m
kick.math.Mat4matrix to transform with
Returns:
out
wrapArray
-
array
See kick.math.Vec4.wrapArray
Parameters:
-
array
Float32Array
Returns:
of vec2