
A simple Vector object for 2d positions.
Kind: global class
Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2BooleanBooleanNumberVector2NumberNumberNumberNumberNumberNumberVector2Vector2NumberNumberNumberArray.<Number>\*Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2Vector2NumberNumberNumberNumberNumberNumberNumberVector2Vector2Vector2Create the Vector object.
| Param | Type | Default | Description |
|---|---|---|---|
| x | number |
0 |
Vector X. |
| y | number |
0 |
Vector Y. |
Vector2Clone the vector.
Kind: instance method of Vector2
Returns: Vector2 - cloned vector.
Vector2Set vector value.
Kind: instance method of Vector2
Returns: Vector2 - this.
| Param | Type | Description |
|---|---|---|
| x | Number |
X component. |
| y | Number |
Y component. |
Vector2Copy values from other vector into self.
Kind: instance method of Vector2
Returns: Vector2 - this.
Vector2Return a new vector of this + other.
Kind: instance method of Vector2
Returns: Vector2 - result vector.
| Param | Type | Description |
|---|---|---|
| Other | Number | Vector2 |
Vector3 or number to add to all components. |
Vector2Return a new vector of this - other.
Kind: instance method of Vector2
Returns: Vector2 - result vector.
| Param | Type | Description |
|---|---|---|
| Other | Number | Vector2 |
Vector3 or number to sub from all components. |
Vector2Return a new vector of this / other.
Kind: instance method of Vector2
Returns: Vector2 - result vector.
| Param | Type | Description |
|---|---|---|
| Other | Number | Vector2 |
Vector3 or number to divide by all components. |
Vector2Return a new vector of this * other.
Kind: instance method of Vector2
Returns: Vector2 - result vector.
| Param | Type | Description |
|---|---|---|
| Other | Number | Vector2 |
Vector2 or number to multiply with all components. |
Vector2Return a round copy of this vector.
Kind: instance method of Vector2
Returns: Vector2 - result vector.
Vector2Return a floored copy of this vector.
Kind: instance method of Vector2
Returns: Vector2 - result vector.
Vector2Return a ceiled copy of this vector.
Kind: instance method of Vector2
Returns: Vector2 - result vector.
Vector2Set self values to be min values between self and a given vector.
Kind: instance method of Vector2
Returns: Vector2 - Self.
| Param | Type | Description |
|---|---|---|
| v | Vector2 |
Vector to min with. |
Vector2Set self values to be max values between self and a given vector.
Kind: instance method of Vector2
Returns: Vector2 - Self.
| Param | Type | Description |
|---|---|---|
| v | Vector2 |
Vector to max with. |
Vector2Create a clone vector that is the min result between self and a given vector.
Kind: instance method of Vector2
Returns: Vector2 - Result vector.
| Param | Type | Description |
|---|---|---|
| v | Vector2 |
Vector to min with. |
Vector2Create a clone vector that is the max result between self and a given vector.
Kind: instance method of Vector2
Returns: Vector2 - Result vector.
| Param | Type | Description |
|---|---|---|
| v | Vector2 |
Vector to max with. |
Vector2Return a normalized copy of this vector.
Kind: instance method of Vector2
Returns: Vector2 - result vector.
Vector2Get a copy of this vector rotated by radians.
Kind: instance method of Vector2
Returns: Vector2 - New vector with the length of this vector and direction rotated by given radians.
| Param | Type | Description |
|---|---|---|
| radians | Number |
Radians to rotate by. |
Vector2Get a copy of this vector rotated by degrees.
Kind: instance method of Vector2
Returns: Vector2 - New vector with the length of this vector and direction rotated by given degrees.
| Param | Type | Description |
|---|---|---|
| degrees | Number |
Degrees to rotate by. |
Vector2Add other vector values to self.
Kind: instance method of Vector2
Returns: Vector2 - this.
| Param | Type | Description |
|---|---|---|
| Other | Number | Vector2 |
Vector or number to add. |
Vector2Sub other vector values from self.
Kind: instance method of Vector2
Returns: Vector2 - this.
| Param | Type | Description |
|---|---|---|
| Other | Number | Vector2 |
Vector or number to substract. |
Vector2Divide this vector by other vector values.
Kind: instance method of Vector2
Returns: Vector2 - this.
| Param | Type | Description |
|---|---|---|
| Other | Number | Vector2 |
Vector or number to divide by. |
Vector2Multiply this vector by other vector values.
Kind: instance method of Vector2
Returns: Vector2 - this.
| Param | Type | Description |
|---|---|---|
| Other | Number | Vector2 |
Vector or number to multiply by. |
Vector2Round self.
Kind: instance method of Vector2
Returns: Vector2 - this.
Vector2Floor self.
Kind: instance method of Vector2
Returns: Vector2 - this.
Vector2Ceil self.
Kind: instance method of Vector2
Returns: Vector2 - this.
Vector2Return a normalized copy of this vector.
Kind: instance method of Vector2
Returns: Vector2 - this.
BooleanReturn if vector equals another vector.
Kind: instance method of Vector2
Returns: Boolean - if vectors are equal.
| Param | Type | Description |
|---|---|---|
| other | Vector2 |
Other vector to compare to. |
BooleanReturn if vector approximately equals another vector.
Kind: instance method of Vector2
Returns: Boolean - if vectors are equal.
| Param | Type | Description |
|---|---|---|
| other | Vector2 |
Other vector to compare to. |
| threshold | Number |
Distance threshold to consider as equal. Defaults to 1. |
NumberReturn vector length (aka magnitude).
Kind: instance method of Vector2
Returns: Number - Vector length.
Vector2Return a copy of this vector multiplied by a factor.
Kind: instance method of Vector2
Returns: Vector2 - result vector.
NumberGet degrees between this vector and another vector.
Kind: instance method of Vector2
Returns: Number - Angle between vectors in degrees.
| Param | Type | Description |
|---|---|---|
| other | Vector2 |
Other vector. |
NumberGet radians between this vector and another vector.
Kind: instance method of Vector2
Returns: Number - Angle between vectors in radians.
| Param | Type | Description |
|---|---|---|
| other | Vector2 |
Other vector. |
NumberGet degrees between this vector and another vector. Return values between 0 to 360.
Kind: instance method of Vector2
Returns: Number - Angle between vectors in degrees.
| Param | Type | Description |
|---|---|---|
| other | Vector2 |
Other vector. |
NumberGet radians between this vector and another vector. Return values between 0 to PI2.
Kind: instance method of Vector2
Returns: Number - Angle between vectors in radians.
| Param | Type | Description |
|---|---|---|
| other | Vector2 |
Other vector. |
NumberCalculate distance between this vector and another vectors.
Kind: instance method of Vector2
Returns: Number - Distance between vectors.
| Param | Type | Description |
|---|---|---|
| other | Vector2 |
Other vector. |
NumberCalculate squared distance between this vector and another vector.
Kind: instance method of Vector2
Returns: Number - Distance between vectors.
| Param | Type | Description |
|---|---|---|
| other | Vector2 |
Other vector. |
Vector2Return a clone and clamp its values to be between min and max.
Kind: instance method of Vector2
Returns: Vector2 - Clamped vector.
| Param | Type | Description |
|---|---|---|
| min | Vector2 |
Min vector. |
| max | Vector2 |
Max vector. |
Vector2Clamp this vector values to be between min and max.
Kind: instance method of Vector2
Returns: Vector2 - Self.
| Param | Type | Description |
|---|---|---|
| min | Vector2 |
Min vector. |
| max | Vector2 |
Max vector. |
NumberCalculate the dot product with another vector.
Kind: instance method of Vector2
Returns: Number - Dot product value.
| Param | Type | Description |
|---|---|---|
| other | Vector2 |
Vector to calculate dot with. |
NumberGet vector’s angle in degrees.
Kind: instance method of Vector2
Returns: Number - Vector angle in degrees.
NumberGet vector’s angle in radians.
Kind: instance method of Vector2
Returns: Number - Vector angle in degrees.
Convert to string.
Kind: instance method of Vector2
Array.<Number>Convert to array of numbers.
Kind: instance method of Vector2
Returns: Array.<Number> - Vector components as array.
\*Convert to dictionary.
Kind: instance method of Vector2
Returns: \* - Dictionary with {x,y}
| Param | Type | Description |
|---|---|---|
| minimized | Boolean |
If true, will not include keys that their values are 0. You can use fromDict on minimized dicts. |
Vector with 0,0 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector2
Vector with 1,1 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector2
Vector with 0.5,0.5 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector2
Vector with -1,0 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector2
Vector with 1,0 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector2
Vector with 0,1 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector2
Vector with 0,-1 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector2
Vector2Get vector (0,0).
Kind: static method of Vector2
Returns: Vector2 - result vector.
Vector2Get vector with 1,1 values.
Kind: static method of Vector2
Returns: Vector2 - result vector.
Vector2Get vector with 0.5,0.5 values.
Kind: static method of Vector2
Returns: Vector2 - result vector.
Vector2Get vector with -1,0 values.
Kind: static method of Vector2
Returns: Vector2 - result vector.
Vector2Get vector with 1,0 values.
Kind: static method of Vector2
Returns: Vector2 - result vector.
Vector2Get vector with 0,-1 values.
Kind: static method of Vector2
Returns: Vector2 - result vector.
Vector2Get vector with 0,1 values.
Kind: static method of Vector2
Returns: Vector2 - result vector.
Vector2Get a random vector with length of 1.
Kind: static method of Vector2
Returns: Vector2 - result vector.
Vector2Get vector from degrees.
Kind: static method of Vector2
Returns: Vector2 - result vector.
| Param | Type | Description |
|---|---|---|
| degrees | Number |
Angle to create vector from (0 = vector pointing right). |
Vector2Get vector from radians.
Kind: static method of Vector2
Returns: Vector2 - result vector.
| Param | Type | Description |
|---|---|---|
| radians | Number |
Angle to create vector from (0 = vector pointing right). |
Vector2Lerp between two vectors.
Kind: static method of Vector2
Returns: Vector2 - result vector.
| Param | Type | Description |
|---|---|---|
| p1 | Vector2 |
First vector. |
| p2 | Vector2 |
Second vector. |
| a | Number |
Lerp factor (0.0 - 1.0). |
NumberGet degrees between two vectors. Return values between -180 to 180.
Kind: static method of Vector2
Returns: Number - Angle between vectors in degrees.
| Param | Type | Description |
|---|---|---|
| p1 | Vector2 |
First vector. |
| p2 | Vector2 |
Second vector. |
NumberGet radians between two vectors. Return values between -PI to PI.
Kind: static method of Vector2
Returns: Number - Angle between vectors in radians.
| Param | Type | Description |
|---|---|---|
| p1 | Vector2 |
First vector. |
| p2 | Vector2 |
Second vector. |
NumberGet degrees between two vectors. Return values between 0 to 360.
Kind: static method of Vector2
Returns: Number - Angle between vectors in degrees.
| Param | Type | Description |
|---|---|---|
| p1 | Vector2 |
First vector. |
| p2 | Vector2 |
Second vector. |
NumberGet radians between two vectors. Return values between 0 to PI2.
Kind: static method of Vector2
Returns: Number - Angle between vectors in radians.
| Param | Type | Description |
|---|---|---|
| p1 | Vector2 |
First vector. |
| p2 | Vector2 |
Second vector. |
NumberCalculate distance between two vectors.
Kind: static method of Vector2
Returns: Number - Distance between vectors.
| Param | Type | Description |
|---|---|---|
| p1 | Vector2 |
First vector. |
| p2 | Vector2 |
Second vector. |
NumberReturn cross product between two vectors.
Kind: static method of Vector2
Returns: Number - Cross between vectors.
| Param | Type | Description |
|---|---|---|
| p1 | Vector2 |
First vector. |
| p2 | Vector2 |
Second vector. |
NumberReturn dot product between two vectors.
Kind: static method of Vector2
Returns: Number - Dot between vectors.
| Param | Type | Description |
|---|---|---|
| p1 | Vector2 |
First vector. |
| p2 | Vector2 |
Second vector. |
Vector2Parse and return a vector object from string in the form of “x,y”.
Kind: static method of Vector2
Returns: Vector2 - Parsed vector.
| Param | Type | Description |
|---|---|---|
| str | String |
String to parse. |
Vector2Create vector from array of numbers.
Kind: static method of Vector2
Returns: Vector2 - Vector instance.
| Param | Type | Description |
|---|---|---|
| arr | Array.<Number> |
Array of numbers to create vector from. |
Vector2Create vector from a dictionary.
Kind: static method of Vector2
Returns: Vector2 - Newly created vector.
| Param | Type | Description |
|---|---|---|
| data | \* |
Dictionary with {x,y}. |