Module ncine.vec2
The table containing 2-components vector related functions
Functions
ncine.vec2.create (x, y) | Creates a vec2 table from its components |
ncine.vec2.add (vec0, vec1) | Adds two vectors together, component-wise |
ncine.vec2.add (vec0, scalar) | Adds a scalar to the vector components |
ncine.vec2.sub (vec0, vec1) | Subtracts the second vector from the first one, component-wise |
ncine.vec2.sub (vec, scalar) | Subtracts the scalar from the vector components |
ncine.vec2.mul (vec0, vec1) | Multiplies two vectors together, component-wise |
ncine.vec2.mul (vec, scalar) | Multiplies the vector components by the scalar |
ncine.vec2.div (vec0, vec1) | Divides the first vector by the second one, component-wise |
ncine.vec2.div (vec, scalar) | Divides the vector components by the scalar |
ncine.vec2.length (vec) | Returns the length of the vector |
ncine.vec2.sqrlength (vec) | Returns the squared length of the vector |
ncine.vec2.normalized (vec) | Returns a normalized version of the vector |
ncine.vec2.dot (vec0, vec1) | Returns the dot product between the two vectors |
Tables
ncine.vec2 | A two component vector |
Functions
- ncine.vec2.create (x, y)
-
Creates a vec2 table from its components
Parameters:
- x number The X component
- y number The Y component
Returns:
- ncine.vec2.add (vec0, vec1)
-
Adds two vectors together, component-wise
Parameters:
- vec0 ncine.vec2
- vec1 ncine.vec2
Returns:
- ncine.vec2.add (vec0, scalar)
-
Adds a scalar to the vector components
Parameters:
- vec0 ncine.vec2
- scalar number
Returns:
- ncine.vec2.sub (vec0, vec1)
-
Subtracts the second vector from the first one, component-wise
Parameters:
- vec0 ncine.vec2
- vec1 ncine.vec2
Returns:
- ncine.vec2.sub (vec, scalar)
-
Subtracts the scalar from the vector components
Parameters:
- vec ncine.vec2
- scalar number
Returns:
- ncine.vec2.mul (vec0, vec1)
-
Multiplies two vectors together, component-wise
Parameters:
- vec0 ncine.vec2
- vec1 ncine.vec2
Returns:
- ncine.vec2.mul (vec, scalar)
-
Multiplies the vector components by the scalar
Parameters:
- vec ncine.vec2
- scalar number
Returns:
- ncine.vec2.div (vec0, vec1)
-
Divides the first vector by the second one, component-wise
Parameters:
- vec0 ncine.vec2
- vec1 ncine.vec2
Returns:
- ncine.vec2.div (vec, scalar)
-
Divides the vector components by the scalar
Parameters:
- vec ncine.vec2
- scalar number
Returns:
- ncine.vec2.length (vec)
-
Returns the length of the vector
Parameters:
- vec ncine.vec2
Returns:
-
number
- ncine.vec2.sqrlength (vec)
-
Returns the squared length of the vector
Parameters:
- vec ncine.vec2
Returns:
-
number
- ncine.vec2.normalized (vec)
-
Returns a normalized version of the vector
Parameters:
- vec ncine.vec2
Returns:
- ncine.vec2.dot (vec0, vec1)
-
Returns the dot product between the two vectors
Parameters:
- vec0 ncine.vec2
- vec1 ncine.vec2
Returns:
-
number