GearBlocks
The GearBlocks Lua scripting API
Public Member Functions | Static Public Member Functions | Properties | List of all members
SmashHammer.Scripting.Vector2Proxy Struct Reference

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.
 

Detailed Description

A 2D vector.

Static methods available in Lua via the "Vector2" global, for example:

local vec = Vector2.__new( 1, 2 )
vec = Vector2.Normalize( vec )

Constructor & Destructor Documentation

◆ Vector2Proxy()

SmashHammer.Scripting.Vector2Proxy.Vector2Proxy ( float  x,
float  y 
)

Constructor.

Parameters
xThe x component to initialise with.
yThe y component to initialise with.

Member Function Documentation

◆ Normalize()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Normalize ( Vector2Proxy  a)
static

Normalise a vector to a magnitude of 1.

Parameters
aThe vector to normalise.
Returns
The normalised vector.

◆ ClampMagnitude()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.ClampMagnitude ( Vector2Proxy  a,
float  maxLength 
)
static

Get the vector with a clamped magnitude.

Parameters
aThe vector to clamp.
maxLengthThe value to clamp the magnitude by.
Returns
The new clamped vector.

◆ Min()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Min ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Get the component-wise minimum of two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The new vector with the smallest components of each vector.

◆ Max()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Max ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Get the component-wise maximum of two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The new vector with the largest components of each vector.

◆ Scale()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Scale ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Get the component-wise multiplication of two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The new vector with the multiplied components.

◆ Distance()

static float SmashHammer.Scripting.Vector2Proxy.Distance ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Get the distance between two point vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The distance between the two points.

◆ Angle()

static float SmashHammer.Scripting.Vector2Proxy.Angle ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Get the angle between two direction vectors.

Parameters
aThe "from" vector.
bThe "to" vector.
Returns
The angle between the directions.

◆ SignedAngle()

static float SmashHammer.Scripting.Vector2Proxy.SignedAngle ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Get the signed angle between two direction vectors.

Parameters
aThe "from" vector.
bThe "to" vector.
Returns
The angle between the a and b directions.

◆ Dot()

static float SmashHammer.Scripting.Vector2Proxy.Dot ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Get the dot product between two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The vector dot product.

◆ Cross() [1/2]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Cross ( Vector2Proxy  a)
static

Get the cross product.

Parameters
aThe vector to cross.
Returns
The vector cross product.

◆ Cross() [2/2]

static float SmashHammer.Scripting.Vector2Proxy.Cross ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Get the cross product between two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The vector cross product.

◆ Reflect()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Reflect ( Vector2Proxy  a,
Vector2Proxy  surfaceNormal 
)
static

Reflect a direction vector off a surface.

Parameters
aThe vector to reflect.
surfaceNormalThe surface normal.
Returns
The reflected direction vector.

◆ Rotate()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Rotate ( Vector2Proxy  a,
float  angle 
)
static

Rotate a vector.

Parameters
aThe vector to rotate.
angleThe angle to rotate by.
Returns
The rotated vector.

◆ Lerp()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Lerp ( Vector2Proxy  a,
Vector2Proxy  b,
float  t 
)
static

Linearly interpolate between two point vectors by t (clamping t to [0, 1]).

Parameters
aThe first vector.
bThe second vector.
tThe interpolation amount.
Returns
The interpolated point.

◆ LerpUnclamped()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.LerpUnclamped ( Vector2Proxy  a,
Vector2Proxy  b,
float  t 
)
static

Linearly interpolate between two point vectors by t (not clamping t).

Parameters
aThe first vector.
bThe second vector.
tThe interpolation amount.
Returns
The interpolated point.

◆ MoveTowards()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.MoveTowards ( Vector2Proxy  fromPoint,
Vector2Proxy  toPoint,
float  step 
)
static

Create a point vector moved from "fromPoint" towards "toPoint".

Parameters
fromPointMove from.
toPointMove to.
stepDistance to move by.
Returns
The new point vector.

◆ Abs()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Abs ( Vector2Proxy  vec)
static

Get the component-wise absolute of a vector.

Parameters
vecThe vector.
Returns
The new vector with the absolute components.

◆ Mod()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Mod ( Vector2Proxy  vec,
float  divisor 
)
static

Get the component-wise modulus of a vector.

Parameters
vecThe vector.
divisorThe divisor for the modulus.
Returns
The new vector with the modulus of the components and the divisor.

◆ Clamp()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Clamp ( Vector2Proxy  vec,
Vector2Proxy  min,
Vector2Proxy  max 
)
static

Get the vector clamped component-wise.

Parameters
vecThe vector.
minMinimum components to clamp to.
maxMaximum components to clamp to.
Returns
The new vector with the clamped components.

◆ Clamp01()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Clamp01 ( Vector2Proxy  vec)
static

Get the vector clamped component-wise between zero and one.

Parameters
vecThe vector.
Returns
The new vector with the clamped components.

◆ Round() [1/5]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Round ( Vector2Proxy  vec)
static

Get the vector rounded component-wise.

Parameters
vecThe vector.
Returns
The new vector with the rounded components.

◆ Round() [2/5]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Round ( Vector2Proxy  vec,
float  roundTo 
)
static

Get the vector rounded component-wise.

Parameters
vecThe vector.
roundToValue to round the components to.
Returns
The new vector with the rounded components.

◆ Round() [3/5]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Round ( Vector2Proxy  vec,
float  roundTo,
Vector2Proxy  offset 
)
static

Get the vector rounded component-wise.

Parameters
vecThe vector.
roundToValue to round the components to.
offsetAmount to offset the rounding by.
Returns
The new vector with the rounded components.

◆ Round() [4/5]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Round ( Vector2Proxy  vec,
Vector2Proxy  roundTo 
)
static

Get the vector rounded component-wise.

Parameters
vecThe vector.
roundToComponents to round to.
Returns
The new vector with the rounded components.

◆ Round() [5/5]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Round ( Vector2Proxy  vec,
Vector2Proxy  roundTo,
Vector2Proxy  offset 
)
static

Get the vector rounded component-wise.

Parameters
vecThe vector.
roundToComponents to round to.
offsetAmount to offset the rounding by.
Returns
The new vector with the rounded components.

◆ Wrap() [1/2]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Wrap ( Vector2Proxy  vec,
float  minWrapTo,
float  maxWrapTo 
)
static

Get the vector wrapped component-wise.

Parameters
vecThe vector.
minWrapToMin value to wrap the components to.
maxWrapToMax value to wrap the components to.
Returns
The new vector with the wrapped components.

◆ Wrap() [2/2]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Wrap ( Vector2Proxy  vec,
Vector2Proxy  minWrapTo,
Vector2Proxy  maxWrapTo 
)
static

Get the vector wrapped component-wise.

Parameters
vecThe vector.
minWrapToMin components to wrap to.
maxWrapToMax components to wrap to.
Returns
The new vector with the wrapped components.

◆ operator+()

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.operator+ ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Add two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The vector addition.

◆ operator-() [1/2]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.operator- ( Vector2Proxy  a)
static

Negate a vector.

Parameters
aThe vector.
Returns
The negated vector.

◆ operator-() [2/2]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.operator- ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Subract two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The vector subtraction.

◆ operator*() [1/3]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.operator* ( Vector2Proxy  a,
float  d 
)
static

Multiply a vector by a scalar.

Parameters
aThe vector.
dThe scalar value.
Returns
The vector multiplication.

◆ operator*() [2/3]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.operator* ( float  d,
Vector2Proxy  a 
)
static

Multiply a vector by a scalar.

Parameters
dThe scalar value.
aThe vector.
Returns
The vector multiplication.

◆ operator*() [3/3]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.operator* ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Multiply two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The vector multiplication.

◆ operator/() [1/2]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.operator/ ( Vector2Proxy  a,
float  d 
)
static

Divide a vector by a scalar.

Parameters
aThe vector.
dThe scalar value.
Returns
The vector division.

◆ operator/() [2/2]

static Vector2Proxy SmashHammer.Scripting.Vector2Proxy.operator/ ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Divide one vector by another.

Parameters
aThe first vector.
bThe second vector.
Returns
The vector division.

◆ operator==()

static bool SmashHammer.Scripting.Vector2Proxy.operator== ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Compare two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
true if the vectors are equal; otherwise, false.

◆ operator!=()

static bool SmashHammer.Scripting.Vector2Proxy.operator!= ( Vector2Proxy  a,
Vector2Proxy  b 
)
static

Compare two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
true if the vectors are not equal; otherwise, false.

◆ Set()

void SmashHammer.Scripting.Vector2Proxy.Set ( float  newX,
float  newY 
)

Set the components of this vector.

Parameters
newXThe x component of the vector.
newYThe y component of the vector.

Property Documentation

◆ X

float SmashHammer.Scripting.Vector2Proxy.X
getset

The vector's x component.

The x component of this vector.

◆ Y

float SmashHammer.Scripting.Vector2Proxy.Y
getset

The vector's y component.

The y component of this vector.

◆ this[int index]

float SmashHammer.Scripting.Vector2Proxy.this[int index]
getset

The vector component at the specified index.

Parameters
indexThe component index:-
0 x
1 y

The vector component.

◆ One

Vector2Proxy SmashHammer.Scripting.Vector2Proxy.One
staticget

The one vector.

A new vector with all components initialised to one.

◆ Zero

Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Zero
staticget

The zero vector.

A new vector with all components initialised to zero.

◆ Up

Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Up
staticget

The up vector.

A new vector initialised to (0, 1).

◆ Down

Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Down
staticget

The down vector.

A new vector initialised to (0, -1).

◆ Right

Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Right
staticget

The right vector.

A new vector initialised to (1, 0).

◆ Left

Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Left
staticget

The left vector.

A new vector initialised to (-1, 0).

◆ SqrMagnitude

float SmashHammer.Scripting.Vector2Proxy.SqrMagnitude
get

The vector's square magnitude.

The squared magnitude of this vector.

◆ Normalized

Vector2Proxy SmashHammer.Scripting.Vector2Proxy.Normalized
get

The normalised vector.

This vector normalised to a magnitude of 1.

◆ Magnitude

float SmashHammer.Scripting.Vector2Proxy.Magnitude
get

The vector's magnitude.

The magnitude of this vector.