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

A quaternion. More...

Public Member Functions

 QuaternionProxy (float x, float y, float z, float w)
 Constructor.
 
void Set (float newX, float newY, float newZ, float newW)
 Set the components of a quaternion.
 
void SetFromToRotation (Vector3Proxy fromDirection, Vector3Proxy toDirection)
 Set the quaternion to a rotation between two directions.
 
void SetLookRotation (Vector3Proxy forward)
 Set the quaternion to a rotation that points in a direction.
 
void SetLookRotation (Vector3Proxy forward, Vector3Proxy up)
 Set the quaternion to a rotation that points in a direction.
 
void ToAngleAxis (out float angle, out Vector3Proxy axis)
 Convert the quaternion to an angle-axis representation.
 

Static Public Member Functions

static QuaternionProxy AngleAxis (float angle, Vector3Proxy axis)
 Create a quaternion from an angle-axis representation.
 
static QuaternionProxy Euler (float x, float y, float z)
 Create a quaternion from an euler angle representation.
 
static QuaternionProxy Euler (Vector3Proxy euler)
 Create a quaternion from an euler angle representation.
 
static QuaternionProxy FromToRotation (Vector3Proxy fromDirection, Vector3Proxy toDirection)
 Create a quaternion with a rotation between two directions.
 
static QuaternionProxy LookRotation (Vector3Proxy forward)
 Create a quaternion with a rotation that points in a direction.
 
static QuaternionProxy LookRotation (Vector3Proxy forward, Vector3Proxy up)
 Create a quaternion with a rotation that points in a direction.
 
static QuaternionProxy Normalize (QuaternionProxy a)
 Normalise a quaternion to a magnitude of 1.
 
static QuaternionProxy Inverse (QuaternionProxy a)
 Get the inverse of a quaternion.
 
static float Angle (QuaternionProxy a, QuaternionProxy b)
 Get the angle between two quaternion rotations.
 
static float Dot (QuaternionProxy a, QuaternionProxy b)
 Get the dot product between two quaternions.
 
static QuaternionProxy Lerp (QuaternionProxy a, QuaternionProxy b, float t)
 Linearly interpolate between two quaternions by t (clamping t to [0, 1]).
 
static QuaternionProxy LerpUnclamped (QuaternionProxy a, QuaternionProxy b, float t)
 Linearly interpolate between two quaternions by t (not clamping t).
 
static QuaternionProxy Slerp (QuaternionProxy a, QuaternionProxy b, float t)
 Spherically interpolate between two quaternions by t (clamping t to [0, 1]).
 
static QuaternionProxy SlerpUnclamped (QuaternionProxy a, QuaternionProxy b, float t)
 Spherically interpolate between two quaternions by t (not clamping t).
 
static QuaternionProxy RotateTowards (QuaternionProxy fromRotation, QuaternionProxy toRotation, float step)
 Create a quaternion with a rotation from "fromRotation" towards "toRotation".
 
static QuaternionProxy SnapAngles (QuaternionProxy q, float snapIntervalAngle)
 Snap a quaternion's euler angles.
 
static Vector3Proxy operator* (QuaternionProxy rotation, Vector3Proxy point)
 Rotate a point vector by a quaternion.
 
static QuaternionProxy operator* (QuaternionProxy a, QuaternionProxy b)
 Combine two quaternion rotations.
 
static bool operator== (QuaternionProxy a, QuaternionProxy b)
 Compare two quaternions.
 
static bool operator!= (QuaternionProxy a, QuaternionProxy b)
 Compare two quaternions.
 

Properties

float X [get, set]
 The quaternion's x component.
 
float Y [get, set]
 The quaternion's y component.
 
float Z [get, set]
 The quaternion's z component.
 
float W [get, set]
 The quaternion's w component.
 
float this[int index] [get, set]
 The quaternion component at the specified index.
 
static QuaternionProxy Identity [get]
 The identity quaternion.
 
Vector3Proxy EulerAngles [get, set]
 The euler angle representation of the quaternion.
 
QuaternionProxy Normalized [get]
 The normalised quaternion.
 
readonly float Magnitude [get]
 The quaternion's magnitude.
 

Detailed Description

A quaternion.

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

local q = Quaternion.__new( 1, 2, 3, 4 )
q = Quaternion.Normalize( q )

Constructor & Destructor Documentation

◆ QuaternionProxy()

SmashHammer.Scripting.QuaternionProxy.QuaternionProxy ( float  x,
float  y,
float  z,
float  w 
)

Constructor.

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

Member Function Documentation

◆ AngleAxis()

static QuaternionProxy SmashHammer.Scripting.QuaternionProxy.AngleAxis ( float  angle,
Vector3Proxy  axis 
)
static

Create a quaternion from an angle-axis representation.

Parameters
angleAngle around the axis.
axisRotation axis.
Returns
The new quaternion.

◆ Euler() [1/2]

static QuaternionProxy SmashHammer.Scripting.QuaternionProxy.Euler ( float  x,
float  y,
float  z 
)
static

Create a quaternion from an euler angle representation.

Parameters
xRotation angle around x axis.
yRotation angle around y axis.
zRotation angle around z axis.
Returns
The new quaternion.

◆ Euler() [2/2]

static QuaternionProxy SmashHammer.Scripting.QuaternionProxy.Euler ( Vector3Proxy  euler)
static

Create a quaternion from an euler angle representation.

Parameters
eulerA vector containing the euler angles.
Returns
The new quaternion.

◆ FromToRotation()

static QuaternionProxy SmashHammer.Scripting.QuaternionProxy.FromToRotation ( Vector3Proxy  fromDirection,
Vector3Proxy  toDirection 
)
static

Create a quaternion with a rotation between two directions.

Parameters
fromDirectionDirection to rotate from.
toDirectionDirection to rotate to.
Returns
The new quaternion.

◆ LookRotation() [1/2]

static QuaternionProxy SmashHammer.Scripting.QuaternionProxy.LookRotation ( Vector3Proxy  forward)
static

Create a quaternion with a rotation that points in a direction.

Parameters
forwardDirection to point in.
Returns
The new quaternion.

◆ LookRotation() [2/2]

static QuaternionProxy SmashHammer.Scripting.QuaternionProxy.LookRotation ( Vector3Proxy  forward,
Vector3Proxy  up 
)
static

Create a quaternion with a rotation that points in a direction.

Parameters
forwardDirection to point in.
upSpecifies the up direction.
Returns
The new quaternion.

◆ Normalize()

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

Normalise a quaternion to a magnitude of 1.

Parameters
aThe quaternion to normalise.
Returns
The normalised quaternion.

◆ Inverse()

static QuaternionProxy SmashHammer.Scripting.QuaternionProxy.Inverse ( QuaternionProxy  a)
static

Get the inverse of a quaternion.

Parameters
aThe quaternion to invert.
Returns
The new quaternion containing the inverse.

◆ Angle()

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

Get the angle between two quaternion rotations.

Parameters
aThe first quaternion.
bThe second quaternion.
Returns
The angle between the rotations.

◆ Dot()

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

Get the dot product between two quaternions.

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

◆ Lerp()

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

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

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

◆ LerpUnclamped()

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

Linearly interpolate between two quaternions by t (not clamping t).

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

◆ Slerp()

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

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

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

◆ SlerpUnclamped()

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

Spherically interpolate between two quaternions by t (not clamping t).

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

◆ RotateTowards()

static QuaternionProxy SmashHammer.Scripting.QuaternionProxy.RotateTowards ( QuaternionProxy  fromRotation,
QuaternionProxy  toRotation,
float  step 
)
static

Create a quaternion with a rotation from "fromRotation" towards "toRotation".

Parameters
fromRotationRotate from.
toRotationRotate to.
stepAngular step to rotate by.
Returns
The new rotation quaternion.

◆ SnapAngles()

static QuaternionProxy SmashHammer.Scripting.QuaternionProxy.SnapAngles ( QuaternionProxy  q,
float  snapIntervalAngle 
)
static

Snap a quaternion's euler angles.

Parameters
qThe quaternion to snap.
snapIntervalAngleThe interval to snap angles by.
Returns
The snapped quaternion.

◆ operator*() [1/2]

static Vector3Proxy SmashHammer.Scripting.QuaternionProxy.operator* ( QuaternionProxy  rotation,
Vector3Proxy  point 
)
static

Rotate a point vector by a quaternion.

Parameters
rotationThe rotation quaternion.
pointThe point vector.
Returns
The rotated vector.

◆ operator*() [2/2]

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

Combine two quaternion rotations.

Parameters
aThe first quaternion.
bThe second quaternion.
Returns
The combined rotation quaternion.

◆ operator==()

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

Compare two quaternions.

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

◆ operator!=()

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

Compare two quaternions.

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

◆ Set()

void SmashHammer.Scripting.QuaternionProxy.Set ( float  newX,
float  newY,
float  newZ,
float  newW 
)

Set the components of a quaternion.

Parameters
newXThe x component of the quaternion.
newYThe y component of the quaternion.
newZThe z component of the quaternion.
newWThe w component of the quaternion.

◆ SetFromToRotation()

void SmashHammer.Scripting.QuaternionProxy.SetFromToRotation ( Vector3Proxy  fromDirection,
Vector3Proxy  toDirection 
)

Set the quaternion to a rotation between two directions.

Parameters
fromDirectionDirection to rotate from.
toDirectionDirection to rotate to.

◆ SetLookRotation() [1/2]

void SmashHammer.Scripting.QuaternionProxy.SetLookRotation ( Vector3Proxy  forward)

Set the quaternion to a rotation that points in a direction.

Parameters
forwardDirection to point in.

◆ SetLookRotation() [2/2]

void SmashHammer.Scripting.QuaternionProxy.SetLookRotation ( Vector3Proxy  forward,
Vector3Proxy  up 
)

Set the quaternion to a rotation that points in a direction.

Parameters
forwardDirection to point in.
upSpecifies the up direction.

◆ ToAngleAxis()

void SmashHammer.Scripting.QuaternionProxy.ToAngleAxis ( out float  angle,
out Vector3Proxy  axis 
)

Convert the quaternion to an angle-axis representation.

Parameters
angleAngle around the axis.
axisRotation axis.

Property Documentation

◆ X

float SmashHammer.Scripting.QuaternionProxy.X
getset

The quaternion's x component.

The x component of this quaternion.

◆ Y

float SmashHammer.Scripting.QuaternionProxy.Y
getset

The quaternion's y component.

The y component of this quaternion.

◆ Z

float SmashHammer.Scripting.QuaternionProxy.Z
getset

The quaternion's z component.

The z component of this quaternion.

◆ W

float SmashHammer.Scripting.QuaternionProxy.W
getset

The quaternion's w component.

The w component of this quaternion.

◆ this[int index]

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

The quaternion component at the specified index.

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

The quaternion component.

◆ Identity

QuaternionProxy SmashHammer.Scripting.QuaternionProxy.Identity
staticget

The identity quaternion.

A new quaternion initialised to the identity rotation.

◆ EulerAngles

Vector3Proxy SmashHammer.Scripting.QuaternionProxy.EulerAngles
getset

The euler angle representation of the quaternion.

A vector containing the euler angles.

◆ Normalized

QuaternionProxy SmashHammer.Scripting.QuaternionProxy.Normalized
get

The normalised quaternion.

This quaternion normalised to a magnitude of 1.

◆ Magnitude

readonly float SmashHammer.Scripting.QuaternionProxy.Magnitude
get

The quaternion's magnitude.

The magnitude of this quaternion.