Classes
Members
Methods
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
angleTo(v) → {number}
Return angle between this vector and other vector.
Angle is measured from 0 to 2*PI in the counterclockwise direction from current vector to another.
Angle is measured from 0 to 2*PI in the counterclockwise direction from current vector to another.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector
|
Another 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
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
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
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
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
rotate(angle) → {Vector}
Returns new vector rotated by given angle,
positive angle defines rotation in counterclockwise direction,
negative - in clockwise direction
Vector only can be rotated around (0,0) point!
- Source:
Parameters:
Name | Type | Description |
---|---|---|
angle |
number
|
Angle in radians |
Returns:
- Type:
-
Vector
rotate90CCW() → {Vector}
Returns vector rotated 90 degrees counterclockwise
- Source:
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