new Vector()
A vector holds three integer values, x, y and z. By default if you want to use only x and y, z will be zero.
Properties:
| Name | Type | Description |
|---|---|---|
x |
Number | x |
y |
Number | y |
z |
Number | z |
Methods
(static) divide(scalar) → {Vector}
Divides a vector by a scalar
Parameters:
| Name | Type | Description |
|---|---|---|
scalar |
Number | the value you want to divide the vector by |
Returns:
A new vector with the vector scaled by division based on the number given
- Type
- Vector
(static) dot(other) → {Number}
Calculates the dot product between the two vectors
Parameters:
| Name | Type | Description |
|---|---|---|
other |
Vector | the vector to perform the dot product with |
Returns:
the dot product between the two vectors
- Type
- Number
(static) magnitude() → {Number}
Returns the magnitude of the vector
Returns:
The magnitude of the vector
- Type
- Number
(static) multiply(scalar) → {Vector}
Multiplies a vector by a scalar
Parameters:
| Name | Type | Description |
|---|---|---|
scalar |
Number | the value you want to multiply to the vector |
Returns:
A new vector with the vector scaled by multiplication based on the number given
- Type
- Vector
(static) normalize() → {Vector}
Normalizes the vector by dividing it by it's own magnitude.
Returns:
A new vector of normalized vector
- Type
- Vector
add(other) → {Vector}
Adds two Vectors together
Parameters:
| Name | Type | Description |
|---|---|---|
other |
Vector | the vector you want to add |
Returns:
A new vector with the two vectors added
- Type
- Vector
constructor()
Creates the Vector object
subtract(other) → {Vector}
Subtracts two Vectors
Parameters:
| Name | Type | Description |
|---|---|---|
other |
Vector | the vector you want to subtract |
Returns:
A new vector with the two vectors subtracted
- Type
- Vector