Vector2
F2.G.Vector2
Vector2
provides operations for 2-dimensinal vectors.
Methods
create()
create()
Create a new 2-dimensional vector, [0, 0] is returned.
Returns: Type Array
length(v)
length(v)
The length of the vector.
Parameters:
Name | Type | Description |
| Array | vector to calculate length |
Returns: Type Number
normalize(out, v)
normalize(out, v)
Normalize the vector.
Parameters:
Name | Type | Description |
| Array | stores the normalization result |
| Array | vector to normalize |
Returns: Type Array
add(out, v1, v2)
add(out, v1, v2)
Add the two vectors v1, v2.
Parameters:
Name | Type | Description |
| Array | stores the result |
| Array | vector v1 to add |
| Array | vector v2 to add |
Returns: Type Array
sub(out, v1, v2)
sub(out, v1, v2)
Subtraction of the two vectors v1, v2.
Parameters:
Name | Type | Description |
| Array | stores the result |
| Array | vector v1 to subtraction |
| Array | vector v2 to subtraction |
Returns: Type Array
scale(out, v, s)
scale(out, v, s)
Scale the vector.
Parameters:
Name | Type | Description |
| Array | stores the result |
| Array | vector to scale |
| Array | scale vector [ sx, sy ] |
Returns: Type Array
dot(v1, v2)
dot(v1, v2)
Calculates the dot product of two vec2's.
Parameters:
Name | Type | Description |
| Array | the first operand |
| Array | the second operand |
Returns: Type Number
direction(v1, v2)
direction(v1, v2)
Calculate the direction formed by two vectors v1, v2.
Parameters:
Name | Type | Description |
| Array | the first operand |
| Array | the second operand |
Returns: Type Boolean
angleTo(v1, v2, direction)
angleTo(v1, v2, direction)
Calculate the angle between the two vectors v1, v2.
Parameters:
Name | Type | Description |
| Array | the first operand |
| Array | the second operand |
| Boolean | the direction of two vector2's |
Returns: Type Number
zero(v)
zero(v)
Determine if vector v is 0 vector.
Parameters:
Name | Type | Description |
| Array | the vector |
Returns: Type Boolean
clone(v)
clone(v)
Creates a new vec2 initialized with values from an existing vector.
Parameters:
Name | Type | Description |
| Array | vector to clone |
Returns: Type Array
min(out, v1, v2)
min(out, v1, v2)
Returns the minimum of two vec2's.
Parameters:
Name | Type | Description |
| Array | store the result |
| Array | the first operand |
| Array | the second operand |
Returns: Type Array
max(out, v1, v2)
max(out, v1, v2)
Returns the maximum of two vec2's.
Parameters:
Name | Type | Description |
| Array | store the result |
| Array | the first operand |
| Array | the second operand |
Returns: Type Array
transformMat2d(out, v, m)
transformMat2d(out, v, m)
Transforms the vector with a matrix.
Parameters:
Name | Type | Description |
| Array | store the result |
| Array | the vector to transform |
| Array | matrix to transform with |
Returns: Type Array
Last updated