Classes
Members
Methods
equalTo(v) → {boolean}
Returns true if vectors are equal up to DP_TOL
tolerance
- Source:
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector
|
Returns:
- Type:
-
boolean
multiply(scalar) → {Vector}
Returns new vector multiplied by scalar
- Source:
Parameters:
Name | Type | Description |
---|---|---|
scalar |
number
|
Returns:
- Type:
-
Vector
dot(v) → {number}
Returns scalar product (dot product) of two vectors
dot_product = (this * v)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector
|
Other vector |
Returns:
- Type:
-
number
cross(v) → {number}
Returns vector product (cross product) of two vectors
cross_product = (this x v)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector
|
Other vector |
Returns:
- Type:
-
number
normalize() → {Vector}
Returns unit vector.
Throw error if given vector has zero length
Throw error if given vector has zero length
- Source:
Returns:
- Type:
-
Vector
rotate(angle) → {Vector}
Returns new vector rotated by given angle,
positive angle defines rotation in counter clockwise direction,
negative - in clockwise direction
- Source:
Parameters:
Name | Type | Description |
---|---|---|
angle |
number
|
Angle in radians |
Returns:
- Type:
-
Vector
rotate90CCW() → {Vector}
Returns vector rotated 90 degrees counter clockwise
- Source:
Returns:
- Type:
-
Vector
add(v) → {Vector}
Return result of addition of other vector to this vector as a new vector
- Source:
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector
|
Other vector |
Returns:
- Type:
-
Vector
subtract(v) → {Vector}
Return result of subtraction of other vector from current vector as a new vector
- Source:
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector
|
Another vector |
Returns:
- Type:
-
Vector
angleTo(v) → {number}
Return angle between this vector and other vector.
Angle is measured from 0 to 2*PI in the counter clockwise direction from current vector to other.
Angle is measured from 0 to 2*PI in the counter clockwise direction from current vector to other.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector
|
Another vector |
Returns:
- Type:
-
number
projectionOn(v) → {Vector}
Return vector projection of the current vector on another vector
- Source:
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector
|
Another vector |
Returns:
- Type:
-
Vector
toJSON() → {Object}
This method returns an object that defines how data will be
serialized when called JSON.stringify() method
- Source:
Returns:
- Type:
-
Object