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

A 3D vector. More...

Public Member Functions

 Vector3Proxy (float x, float y, float z)
 Constructor.
 
void Normalize ()
 Normalise this vector to a magnitude of 1.
 
void Set (float newX, float newY, float newZ)
 Set the components of this vector.
 

Static Public Member Functions

static Vector3Proxy Normalize (Vector3Proxy a)
 Normalise a vector to a magnitude of 1.
 
static Vector3Proxy ClampMagnitude (Vector3Proxy a, float maxLength)
 Get the vector with a clamped magnitude.
 
static Vector3Proxy Min (Vector3Proxy a, Vector3Proxy b)
 Get the component-wise minimum of two vectors.
 
static Vector3Proxy Max (Vector3Proxy a, Vector3Proxy b)
 Get the component-wise maximum of two vectors.
 
static Vector3Proxy Scale (Vector3Proxy a, Vector3Proxy b)
 Get the component-wise multiplication of two vectors.
 
static float Distance (Vector3Proxy a, Vector3Proxy b)
 Get the distance between two point vectors.
 
static float Angle (Vector3Proxy a, Vector3Proxy b)
 Get the angle between two direction vectors.
 
static float SignedAngle (Vector3Proxy a, Vector3Proxy b, Vector3Proxy axis)
 Get the signed angle between two direction vectors in relation to an axis vector.
 
static float Dot (Vector3Proxy a, Vector3Proxy b)
 Get the dot product between two vectors.
 
static Vector3Proxy Cross (Vector3Proxy a, Vector3Proxy b)
 Get the cross product between two vectors.
 
static Vector3Proxy Project (Vector3Proxy a, Vector3Proxy normal)
 Project one vector onto another.
 
static Vector3Proxy ProjectOnPlane (Vector3Proxy a, Vector3Proxy planeNormal)
 Project a vector onto a plane.
 
static Vector3Proxy Reflect (Vector3Proxy a, Vector3Proxy planeNormal)
 Reflect a direction vector off a plane.
 
static Vector3Proxy Lerp (Vector3Proxy a, Vector3Proxy b, float t)
 Linearly interpolate between two point vectors by t (clamping t to [0, 1]).
 
static Vector3Proxy LerpUnclamped (Vector3Proxy a, Vector3Proxy b, float t)
 Linearly interpolate between two point vectors by t (not clamping t).
 
static Vector3Proxy Slerp (Vector3Proxy a, Vector3Proxy b, float t)
 Spherically interpolate between two direction vectors by t (clamping t to [0, 1]).
 
static Vector3Proxy SlerpUnclamped (Vector3Proxy a, Vector3Proxy b, float t)
 Spherically interpolate between two direction vectors by t (not clamping t).
 
static Vector3Proxy MoveTowards (Vector3Proxy fromPoint, Vector3Proxy toPoint, float step)
 Create a point vector moved from "fromPoint" towards "toPoint".
 
static Vector3Proxy RotateTowards (Vector3Proxy fromDirection, Vector3Proxy toDirection, float angleStep, float magStep)
 Create a direction vector rotated from "fromDirection" towards "toDirection".
 
static Vector3Proxy Abs (Vector3Proxy vec)
 Get the component-wise absolute of a vector.
 
static Vector3Proxy Mod (Vector3Proxy vec, float divisor)
 Get the component-wise modulus of a vector.
 
static Vector3Proxy Clamp (Vector3Proxy vec, Vector3Proxy min, Vector3Proxy max)
 Get the vector clamped component-wise.
 
static Vector3Proxy Clamp01 (Vector3Proxy vec)
 Get the vector clamped component-wise between zero and one.
 
static Vector3Proxy Round (Vector3Proxy vec)
 Get the vector rounded component-wise.
 
static Vector3Proxy Round (Vector3Proxy vec, float roundTo)
 Get the vector rounded component-wise.
 
static Vector3Proxy Round (Vector3Proxy vec, float roundTo, Vector3Proxy offset)
 Get the vector rounded component-wise.
 
static Vector3Proxy Round (Vector3Proxy vec, Vector3Proxy roundTo)
 Get the vector rounded component-wise.
 
static Vector3Proxy Round (Vector3Proxy vec, Vector3Proxy roundTo, Vector3Proxy offset)
 Get the vector rounded component-wise.
 
static Vector3Proxy Wrap (Vector3Proxy vec, float minWrapTo, float maxWrapTo)
 Get the vector wrapped component-wise.
 
static Vector3Proxy Wrap (Vector3Proxy vec, Vector3Proxy minWrapTo, Vector3Proxy maxWrapTo)
 Get the vector wrapped component-wise.
 
static Vector3Proxy operator+ (Vector3Proxy a, Vector3Proxy b)
 Add two vectors.
 
static Vector3Proxy operator- (Vector3Proxy a)
 Negate a vector.
 
static Vector3Proxy operator- (Vector3Proxy a, Vector3Proxy b)
 Subract two vectors.
 
static Vector3Proxy operator* (Vector3Proxy a, float d)
 Multiply a vector by a scalar.
 
static Vector3Proxy operator* (float d, Vector3Proxy a)
 Multiply a vector by a scalar.
 
static Vector3Proxy operator/ (Vector3Proxy a, float d)
 Divide a vector by a scalar.
 
static bool operator== (Vector3Proxy a, Vector3Proxy b)
 Compare two vectors.
 
static bool operator!= (Vector3Proxy a, Vector3Proxy b)
 Compare two vectors.
 

Properties

float X [get, set]
 The vector's x component.
 
float Y [get, set]
 The vector's y component.
 
float Z [get, set]
 The vector's z component.
 
float this[int index] [get, set]
 The vector component at the specified index.
 
static Vector3Proxy One [get]
 The one vector.
 
static Vector3Proxy Zero [get]
 The zero vector.
 
static Vector3Proxy Up [get]
 The up vector.
 
static Vector3Proxy Down [get]
 The down vector.
 
static Vector3Proxy Right [get]
 The right vector.
 
static Vector3Proxy Left [get]
 The left vector.
 
static Vector3Proxy Forward [get]
 The forward vector.
 
static Vector3Proxy Back [get]
 The back vector.
 
float SqrMagnitude [get]
 The vector's square magnitude.
 
Vector3Proxy Normalized [get]
 The normalised vector.
 
float Magnitude [get]
 The vector's magnitude.
 

Detailed Description

A 3D vector.

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

local vec = Vector3.__new( 1, 2, 3 )
vec = Vector3.Normalize( vec )

Constructor & Destructor Documentation

◆ Vector3Proxy()

SmashHammer.Scripting.Vector3Proxy.Vector3Proxy ( float  x,
float  y,
float  z 
)

Constructor.

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

Member Function Documentation

◆ Normalize()

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

Normalise a vector to a magnitude of 1.

Parameters
aThe vector to normalise.
Returns
The normalised vector.

◆ ClampMagnitude()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.ClampMagnitude ( Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Min ( Vector3Proxy  a,
Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Max ( Vector3Proxy  a,
Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Scale ( Vector3Proxy  a,
Vector3Proxy  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.Vector3Proxy.Distance ( Vector3Proxy  a,
Vector3Proxy  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.Vector3Proxy.Angle ( Vector3Proxy  a,
Vector3Proxy  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.Vector3Proxy.SignedAngle ( Vector3Proxy  a,
Vector3Proxy  b,
Vector3Proxy  axis 
)
static

Get the signed angle between two direction vectors in relation to an axis vector.

Parameters
aThe "from" vector.
bThe "to" vector.
axisThe rotation axis.
Returns
The angle between the a and b directions, rotating around axis.

◆ Dot()

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

Get the dot product between two vectors.

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

◆ Cross()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Cross ( Vector3Proxy  a,
Vector3Proxy  b 
)
static

Get the cross product between two vectors.

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

◆ Project()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Project ( Vector3Proxy  a,
Vector3Proxy  normal 
)
static

Project one vector onto another.

Parameters
aThe vector to project.
normalThe vector to project on to.
Returns
The projected vector.

◆ ProjectOnPlane()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.ProjectOnPlane ( Vector3Proxy  a,
Vector3Proxy  planeNormal 
)
static

Project a vector onto a plane.

Parameters
aThe vector to project.
planeNormalThe plane normal.
Returns
The projected vector.

◆ Reflect()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Reflect ( Vector3Proxy  a,
Vector3Proxy  planeNormal 
)
static

Reflect a direction vector off a plane.

Parameters
aThe vector to reflect.
planeNormalThe plane normal.
Returns
The reflected direction vector.

◆ Lerp()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Lerp ( Vector3Proxy  a,
Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.LerpUnclamped ( Vector3Proxy  a,
Vector3Proxy  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.

◆ Slerp()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Slerp ( Vector3Proxy  a,
Vector3Proxy  b,
float  t 
)
static

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

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

◆ SlerpUnclamped()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.SlerpUnclamped ( Vector3Proxy  a,
Vector3Proxy  b,
float  t 
)
static

Spherically interpolate between two direction vectors by t (not clamping t).

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

◆ MoveTowards()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.MoveTowards ( Vector3Proxy  fromPoint,
Vector3Proxy  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.

◆ RotateTowards()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.RotateTowards ( Vector3Proxy  fromDirection,
Vector3Proxy  toDirection,
float  angleStep,
float  magStep 
)
static

Create a direction vector rotated from "fromDirection" towards "toDirection".

Parameters
fromDirectionRotate from.
toDirectionRotate to.
angleStepAngular step to rotate by.
magStepMagnitude step to change by.
Returns
The new direction vector.

◆ Abs()

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

Get the component-wise absolute of a vector.

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

◆ Mod()

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Mod ( Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Clamp ( Vector3Proxy  vec,
Vector3Proxy  min,
Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Clamp01 ( Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Round ( Vector3Proxy  vec)
static

Get the vector rounded component-wise.

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

◆ Round() [2/5]

static Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Round ( Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Round ( Vector3Proxy  vec,
float  roundTo,
Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Round ( Vector3Proxy  vec,
Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Round ( Vector3Proxy  vec,
Vector3Proxy  roundTo,
Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Wrap ( Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Wrap ( Vector3Proxy  vec,
Vector3Proxy  minWrapTo,
Vector3Proxy  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 Vector3Proxy SmashHammer.Scripting.Vector3Proxy.operator+ ( Vector3Proxy  a,
Vector3Proxy  b 
)
static

Add two vectors.

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

◆ operator-() [1/2]

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

Negate a vector.

Parameters
aThe vector.
Returns
The negated vector.

◆ operator-() [2/2]

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

Subract two vectors.

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

◆ operator*() [1/2]

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

Multiply a vector by a scalar.

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

◆ operator*() [2/2]

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

Multiply a vector by a scalar.

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

◆ operator/()

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

Divide a vector by a scalar.

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

◆ operator==()

static bool SmashHammer.Scripting.Vector3Proxy.operator== ( Vector3Proxy  a,
Vector3Proxy  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.Vector3Proxy.operator!= ( Vector3Proxy  a,
Vector3Proxy  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.Vector3Proxy.Set ( float  newX,
float  newY,
float  newZ 
)

Set the components of this vector.

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

Property Documentation

◆ X

float SmashHammer.Scripting.Vector3Proxy.X
getset

The vector's x component.

The x component of this vector.

◆ Y

float SmashHammer.Scripting.Vector3Proxy.Y
getset

The vector's y component.

The y component of this vector.

◆ Z

float SmashHammer.Scripting.Vector3Proxy.Z
getset

The vector's z component.

The z component of this vector.

◆ this[int index]

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

The vector component at the specified index.

Parameters
indexThe component index:-
0 x
1 y
2 z

The vector component.

◆ One

Vector3Proxy SmashHammer.Scripting.Vector3Proxy.One
staticget

The one vector.

A new vector with all components initialised to one.

◆ Zero

Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Zero
staticget

The zero vector.

A new vector with all components initialised to zero.

◆ Up

Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Up
staticget

The up vector.

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

◆ Down

Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Down
staticget

The down vector.

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

◆ Right

Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Right
staticget

The right vector.

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

◆ Left

Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Left
staticget

The left vector.

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

◆ Forward

Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Forward
staticget

The forward vector.

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

◆ Back

Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Back
staticget

The back vector.

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

◆ SqrMagnitude

float SmashHammer.Scripting.Vector3Proxy.SqrMagnitude
get

The vector's square magnitude.

The squared magnitude of this vector.

◆ Normalized

Vector3Proxy SmashHammer.Scripting.Vector3Proxy.Normalized
get

The normalised vector.

This vector normalised to a magnitude of 1.

◆ Magnitude

float SmashHammer.Scripting.Vector3Proxy.Magnitude
get

The vector's magnitude.

The magnitude of this vector.