|
GearBlocks
The GearBlocks Lua scripting API
|
A 2D vector. More...
Public Member Functions | |
| Vector2Proxy (float x, float y) | |
| Constructor. | |
| void | Normalize () |
| Normalise this vector to a magnitude of 1. | |
| void | Set (float newX, float newY) |
| Set the components of this vector. | |
Static Public Member Functions | |
| static Vector2Proxy | Normalize (Vector2Proxy a) |
| Normalise a vector to a magnitude of 1. | |
| static Vector2Proxy | ClampMagnitude (Vector2Proxy a, float maxLength) |
| Get the vector with a clamped magnitude. | |
| static Vector2Proxy | Min (Vector2Proxy a, Vector2Proxy b) |
| Get the component-wise minimum of two vectors. | |
| static Vector2Proxy | Max (Vector2Proxy a, Vector2Proxy b) |
| Get the component-wise maximum of two vectors. | |
| static Vector2Proxy | Scale (Vector2Proxy a, Vector2Proxy b) |
| Get the component-wise multiplication of two vectors. | |
| static float | Distance (Vector2Proxy a, Vector2Proxy b) |
| Get the distance between two point vectors. | |
| static float | Angle (Vector2Proxy a, Vector2Proxy b) |
| Get the angle between two direction vectors. | |
| static float | SignedAngle (Vector2Proxy a, Vector2Proxy b) |
| Get the signed angle between two direction vectors. | |
| static float | Dot (Vector2Proxy a, Vector2Proxy b) |
| Get the dot product between two vectors. | |
| static Vector2Proxy | Cross (Vector2Proxy a) |
| Get the cross product. | |
| static float | Cross (Vector2Proxy a, Vector2Proxy b) |
| Get the cross product between two vectors. | |
| static Vector2Proxy | Reflect (Vector2Proxy a, Vector2Proxy surfaceNormal) |
| Reflect a direction vector off a surface. | |
| static Vector2Proxy | Rotate (Vector2Proxy a, float angle) |
| Rotate a vector. | |
| static Vector2Proxy | Lerp (Vector2Proxy a, Vector2Proxy b, float t) |
| Linearly interpolate between two point vectors by t (clamping t to [0, 1]). | |
| static Vector2Proxy | LerpUnclamped (Vector2Proxy a, Vector2Proxy b, float t) |
| Linearly interpolate between two point vectors by t (not clamping t). | |
| static Vector2Proxy | MoveTowards (Vector2Proxy fromPoint, Vector2Proxy toPoint, float step) |
| Create a point vector moved from "fromPoint" towards "toPoint". | |
| static Vector2Proxy | Abs (Vector2Proxy vec) |
| Get the component-wise absolute of a vector. | |
| static Vector2Proxy | Mod (Vector2Proxy vec, float divisor) |
| Get the component-wise modulus of a vector. | |
| static Vector2Proxy | Clamp (Vector2Proxy vec, Vector2Proxy min, Vector2Proxy max) |
| Get the vector clamped component-wise. | |
| static Vector2Proxy | Clamp01 (Vector2Proxy vec) |
| Get the vector clamped component-wise between zero and one. | |
| static Vector2Proxy | Round (Vector2Proxy vec) |
| Get the vector rounded component-wise. | |
| static Vector2Proxy | Round (Vector2Proxy vec, float roundTo) |
| Get the vector rounded component-wise. | |
| static Vector2Proxy | Round (Vector2Proxy vec, float roundTo, Vector2Proxy offset) |
| Get the vector rounded component-wise. | |
| static Vector2Proxy | Round (Vector2Proxy vec, Vector2Proxy roundTo) |
| Get the vector rounded component-wise. | |
| static Vector2Proxy | Round (Vector2Proxy vec, Vector2Proxy roundTo, Vector2Proxy offset) |
| Get the vector rounded component-wise. | |
| static Vector2Proxy | Wrap (Vector2Proxy vec, float minWrapTo, float maxWrapTo) |
| Get the vector wrapped component-wise. | |
| static Vector2Proxy | Wrap (Vector2Proxy vec, Vector2Proxy minWrapTo, Vector2Proxy maxWrapTo) |
| Get the vector wrapped component-wise. | |
| static Vector2Proxy | operator+ (Vector2Proxy a, Vector2Proxy b) |
| Add two vectors. | |
| static Vector2Proxy | operator- (Vector2Proxy a) |
| Negate a vector. | |
| static Vector2Proxy | operator- (Vector2Proxy a, Vector2Proxy b) |
| Subract two vectors. | |
| static Vector2Proxy | operator* (Vector2Proxy a, float d) |
| Multiply a vector by a scalar. | |
| static Vector2Proxy | operator* (float d, Vector2Proxy a) |
| Multiply a vector by a scalar. | |
| static Vector2Proxy | operator* (Vector2Proxy a, Vector2Proxy b) |
| Multiply two vectors. | |
| static Vector2Proxy | operator/ (Vector2Proxy a, float d) |
| Divide a vector by a scalar. | |
| static Vector2Proxy | operator/ (Vector2Proxy a, Vector2Proxy b) |
| Divide one vector by another. | |
| static bool | operator== (Vector2Proxy a, Vector2Proxy b) |
| Compare two vectors. | |
| static bool | operator!= (Vector2Proxy a, Vector2Proxy b) |
| Compare two vectors. | |
Properties | |
| float | X [get, set] |
| The vector's x component. | |
| float | Y [get, set] |
| The vector's y component. | |
| float | this[int index] [get, set] |
| The vector component at the specified index. | |
| static Vector2Proxy | One [get] |
| The one vector. | |
| static Vector2Proxy | Zero [get] |
| The zero vector. | |
| static Vector2Proxy | Up [get] |
| The up vector. | |
| static Vector2Proxy | Down [get] |
| The down vector. | |
| static Vector2Proxy | Right [get] |
| The right vector. | |
| static Vector2Proxy | Left [get] |
| The left vector. | |
| float | SqrMagnitude [get] |
| The vector's square magnitude. | |
| Vector2Proxy | Normalized [get] |
| The normalised vector. | |
| float | Magnitude [get] |
| The vector's magnitude. | |
A 2D vector.
Static methods available in Lua via the "Vector2" global, for example:
| SmashHammer.Scripting.Vector2Proxy.Vector2Proxy | ( | float | x, |
| float | y | ||
| ) |
Constructor.
| x | The x component to initialise with. |
| y | The y component to initialise with. |
|
static |
Normalise a vector to a magnitude of 1.
| a | The vector to normalise. |
|
static |
Get the vector with a clamped magnitude.
| a | The vector to clamp. |
| maxLength | The value to clamp the magnitude by. |
|
static |
Get the component-wise minimum of two vectors.
| a | The first vector. |
| b | The second vector. |
|
static |
Get the component-wise maximum of two vectors.
| a | The first vector. |
| b | The second vector. |
|
static |
Get the component-wise multiplication of two vectors.
| a | The first vector. |
| b | The second vector. |
|
static |
Get the distance between two point vectors.
| a | The first vector. |
| b | The second vector. |
|
static |
Get the angle between two direction vectors.
| a | The "from" vector. |
| b | The "to" vector. |
|
static |
Get the signed angle between two direction vectors.
| a | The "from" vector. |
| b | The "to" vector. |
|
static |
Get the dot product between two vectors.
| a | The first vector. |
| b | The second vector. |
|
static |
Get the cross product.
| a | The vector to cross. |
|
static |
Get the cross product between two vectors.
| a | The first vector. |
| b | The second vector. |
|
static |
Reflect a direction vector off a surface.
| a | The vector to reflect. |
| surfaceNormal | The surface normal. |
|
static |
Rotate a vector.
| a | The vector to rotate. |
| angle | The angle to rotate by. |
|
static |
Linearly interpolate between two point vectors by t (clamping t to [0, 1]).
| a | The first vector. |
| b | The second vector. |
| t | The interpolation amount. |
|
static |
Linearly interpolate between two point vectors by t (not clamping t).
| a | The first vector. |
| b | The second vector. |
| t | The interpolation amount. |
|
static |
Create a point vector moved from "fromPoint" towards "toPoint".
| fromPoint | Move from. |
| toPoint | Move to. |
| step | Distance to move by. |
|
static |
Get the component-wise absolute of a vector.
| vec | The vector. |
|
static |
Get the component-wise modulus of a vector.
| vec | The vector. |
| divisor | The divisor for the modulus. |
|
static |
Get the vector clamped component-wise.
| vec | The vector. |
| min | Minimum components to clamp to. |
| max | Maximum components to clamp to. |
|
static |
Get the vector clamped component-wise between zero and one.
| vec | The vector. |
|
static |
Get the vector rounded component-wise.
| vec | The vector. |
|
static |
Get the vector rounded component-wise.
| vec | The vector. |
| roundTo | Value to round the components to. |
|
static |
Get the vector rounded component-wise.
| vec | The vector. |
| roundTo | Value to round the components to. |
| offset | Amount to offset the rounding by. |
|
static |
Get the vector rounded component-wise.
| vec | The vector. |
| roundTo | Components to round to. |
|
static |
Get the vector rounded component-wise.
| vec | The vector. |
| roundTo | Components to round to. |
| offset | Amount to offset the rounding by. |
|
static |
Get the vector wrapped component-wise.
| vec | The vector. |
| minWrapTo | Min value to wrap the components to. |
| maxWrapTo | Max value to wrap the components to. |
|
static |
Get the vector wrapped component-wise.
| vec | The vector. |
| minWrapTo | Min components to wrap to. |
| maxWrapTo | Max components to wrap to. |
|
static |
Add two vectors.
| a | The first vector. |
| b | The second vector. |
|
static |
Negate a vector.
| a | The vector. |
|
static |
Subract two vectors.
| a | The first vector. |
| b | The second vector. |
|
static |
Multiply a vector by a scalar.
| a | The vector. |
| d | The scalar value. |
|
static |
Multiply a vector by a scalar.
| d | The scalar value. |
| a | The vector. |
|
static |
Multiply two vectors.
| a | The first vector. |
| b | The second vector. |
|
static |
Divide a vector by a scalar.
| a | The vector. |
| d | The scalar value. |
|
static |
Divide one vector by another.
| a | The first vector. |
| b | The second vector. |
|
static |
Compare two vectors.
| a | The first vector. |
| b | The second vector. |
true if the vectors are equal; otherwise, false.
|
static |
Compare two vectors.
| a | The first vector. |
| b | The second vector. |
true if the vectors are not equal; otherwise, false.| void SmashHammer.Scripting.Vector2Proxy.Set | ( | float | newX, |
| float | newY | ||
| ) |
Set the components of this vector.
| newX | The x component of the vector. |
| newY | The y component of the vector. |
|
getset |
The vector's x component.
The x component of this vector.
|
getset |
The vector's y component.
The y component of this vector.
|
getset |
The vector component at the specified index.
| index | The component index:-
|
The vector component.
|
staticget |
The one vector.
A new vector with all components initialised to one.
|
staticget |
The zero vector.
A new vector with all components initialised to zero.
|
staticget |
The up vector.
A new vector initialised to (0, 1).
|
staticget |
The down vector.
A new vector initialised to (0, -1).
|
staticget |
The right vector.
A new vector initialised to (1, 0).
|
staticget |
The left vector.
A new vector initialised to (-1, 0).
|
get |
The vector's square magnitude.
The squared magnitude of this vector.
|
get |
The normalised vector.
This vector normalised to a magnitude of 1.
|
get |
The vector's magnitude.
The magnitude of this vector.