Class: Quaternion

Phaser.Math. Quaternion

A quaternion.


new Quaternion( [x] [, y] [, z] [, w])

Parameters:
Name Type Argument Description
x number <optional>

The x component.

y number <optional>

The y component.

z number <optional>

The z component.

w number <optional>

The w component.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 26)

Members


w :number

The w component of this Quaternion.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/math/Quaternion.js (Line 73)

x :number

The x component of this Quaternion.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/math/Quaternion.js (Line 46)

y :number

The y component of this Quaternion.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/math/Quaternion.js (Line 55)

z :number

The z component of this Quaternion.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/math/Quaternion.js (Line 64)

Methods


add(v)

Add a given Quaternion or Vector to this Quaternion. Addition is component-wise.

Parameters:
Name Type Description
v Phaser.Math.Quaternion | Phaser.Math.Vector4

The Quaternion or Vector to add to this Quaternion.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 151)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

calculateW()

Create a unit (or rotation) Quaternion from its x, y, and z components.

Sets the w component.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 672)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

conjugate()

Convert this Quaternion into its conjugate.

Sets the x, y and z components.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 563)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

copy(src)

Copy the components of a given Quaternion or Vector into this Quaternion.

Parameters:
Name Type Description
src Phaser.Math.Quaternion | Phaser.Math.Vector4

The Quaternion or Vector to copy the components from.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 98)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

dot(v)

Calculate the dot product of this Quaternion and the given Quaternion or Vector.

Parameters:
Name Type Description
v Phaser.Math.Quaternion | Phaser.Math.Vector4

The Quaternion or Vector to dot product with this Quaternion.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 276)
Returns:

The dot product of this Quaternion and the given Quaternion or Vector.

Type
number

fromMat3(mat)

Convert the given Matrix into this Quaternion.

Parameters:
Name Type Description
mat Phaser.Math.Matrix3

The Matrix to convert from.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 693)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

identity()

Reset this Matrix to an identity (default) Quaternion.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 399)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

invert()

Invert this Quaternion.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 535)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

length()

Calculate the length of this Quaternion.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 211)
Returns:

The length of this Quaternion.

Type
number

lengthSq()

Calculate the length of this Quaternion squared.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 229)
Returns:

The length of this Quaternion, squared.

Type
number

lerp(v [, t])

Linearly interpolate this Quaternion towards the given Quaternion or Vector.

Parameters:
Name Type Argument Default Description
v Phaser.Math.Quaternion | Phaser.Math.Vector4

The Quaternion or Vector to interpolate towards.

t number <optional>
0

The percentage of interpolation.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 291)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

multiply(b)

Multiply this Quaternion by the given Quaternion or Vector.

Parameters:
Name Type Description
b Phaser.Math.Quaternion | Phaser.Math.Vector4

The Quaternion or Vector to multiply this Quaternion by.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 442)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

normalize()

Normalize this Quaternion.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 247)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

rotateX(rad)

Rotate this Quaternion on the X axis.

Parameters:
Name Type Description
rad number

The rotation angle in radians.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 582)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

rotateY(rad)

Rotate this Quaternion on the Y axis.

Parameters:
Name Type Description
rad number

The rotation angle in radians.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 612)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

rotateZ(rad)

Rotate this Quaternion on the Z axis.

Parameters:
Name Type Description
rad number

The rotation angle in radians.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 642)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

rotationTo(a, b)

[description]

Parameters:
Name Type Description
a Phaser.Math.Vector3

[description]

b Phaser.Math.Vector3

[description]

Since: 3.0.0
Source: src/math/Quaternion.js (Line 319)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

scale(scale)

Scale this Quaternion by the given value.

Parameters:
Name Type Description
scale number

The value to scale this Quaternion by.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 191)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

set( [x] [, y] [, z] [, w])

Set the components of this Quaternion.

Parameters:
Name Type Argument Default Description
x number | object <optional>
0

The x component, or an object containing x, y, z, and w components.

y number <optional>
0

The y component.

z number <optional>
0

The z component.

w number <optional>
0

The w component.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 118)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

setAxes(view, right, up)

Set the axes of this Quaternion.

Parameters:
Name Type Description
view Phaser.Math.Vector3

The view axis.

right Phaser.Math.Vector3

The right axis.

up Phaser.Math.Vector3

The upwards axis.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 368)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

setAxisAngle(axis, rad)

Set the axis angle of this Quaternion.

Parameters:
Name Type Description
axis Phaser.Math.Vector3

The axis.

rad number

The angle in radians.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 417)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

slerp(b, t)

Smoothly linearly interpolate this Quaternion towards the given Quaternion or Vector.

Parameters:
Name Type Description
b Phaser.Math.Quaternion | Phaser.Math.Vector4

The Quaternion or Vector to interpolate towards.

t number

The percentage of interpolation.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 472)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion

subtract(v)

Subtract a given Quaternion or Vector from this Quaternion. Subtraction is component-wise.

Parameters:
Name Type Description
v Phaser.Math.Quaternion | Phaser.Math.Vector4

The Quaternion or Vector to subtract from this Quaternion.

Since: 3.0.0
Source: src/math/Quaternion.js (Line 171)
Returns:

This Quaternion.

Type
Phaser.Math.Quaternion