Photon Quantum 3.0.0

Static Public Member Functions | List of all members
Quantum.FPMathUtils Class Reference

Unity specific FixedPoint math utilities. All conversions between Unity float into Quantum FP (e.g. Vector2 to FPVector2) are considered non-deterministic and should never be used in the Quantum simulation directly. More...

Static Public Member Functions

static FP FlipRotation (this FP r)
 Inverts the FP if QUNATUM_XY is not defined. More...
 
static void LoadLookupTables (Boolean force=false)
 Load the lookup tables from the resources folders. More...
 
static Vector2 RoundToInt (this Vector2 v)
 Rounds all components of the Unity vector to the nearest integer. More...
 
static Vector3 RoundToInt (this Vector3 v)
 Rounds all components of the Unity vector to the nearest integer. More...
 
static Color ToColor (this ColorRGBA clr)
 Obsolete More...
 
static Color32 ToColor32 (this ColorRGBA clr)
 Obsolete More...
 
static FP ToFP (this Single v)
 Convert a float to an FP, with rounding towards zero. To round towards nearest representable FP, use ToRoundedFP. This is always considered to be unsafe and non-deterministic and should never be used in conjunction with the simulation. More...
 
static FPMatrix4x4 ToFPMatrix4X4 (this Matrix4x4 m)
 Converts a Unity Matrix4x4 to a Quantum FPMatrix4x4, with each component being rounded towards the nearest representable FP. More...
 
static FPQuaternion ToFPQuaternion (this Quaternion r)
 Convert a Unity quaternion to a Quantum FPQuaternion. More...
 
static FP ToFPRotation2D (this Quaternion r)
 Converts a Unity quaternion to 2D rotation in radians by only using the y (or z axis if QUANTUM_XY is defined) More...
 
static FP ToFPRotation2DDegrees (this Quaternion r)
 Converts a Unity quaternion to 2D rotation in degrees by only using the y (or z axis if QUANTUM_XY is defined) More...
 
static FPVector2 ToFPVector2 (this Vector2 v)
 Converts a Unity Vector2 to a Quantum FPVector2, with each component being rounded towards zero. To round towards the nearest representable FP, use ToRoundedFPVector2. More...
 
static FPVector2 ToFPVector2 (this Vector3 v)
 Converts a Unity Vector3 to a Quantum FPVector2 by removing the y component (removing the z component if QUANTUM_XY is defined). Each component is rounded towards zero. More...
 
static FPVector3 ToFPVector3 (this Vector3 v)
 Converts a Unity Vector3 to a Quantum FPVector3, with each component being rounded towards zero. More...
 
static FP ToFPVerticalPosition (this Vector3 v)
 Extracts the vertical position of a Unity Vector3 and converts it to a Quantum FP. Will use the inverse z component if QUANTUM_XY is defined. More...
 
static FP ToRoundedFP (this Single v)
 Convert a float to an FP, with rounding to the nearest representable FP. This is always considered to be unsafe and non-deterministic and should never be used in conjunction with the simulation. More...
 
static FPVector2 ToRoundedFPVector2 (this Vector3 v)
 Converts a Unity Vector3 to a Quantum FPVector2 by removing the y component (removing the z component if QUANTUM_XY is defined). Each component is rounded towards the nearest representable FP. More...
 
static FPVector3 ToRoundedFPVector3 (this Vector3 v)
 Converts a Unity vector3 to a Quantum FPVector3, with each component being rounded towards the nearest representable FP. More...
 
static Quaternion ToUnityQuaternion (this FP r)
 Creates a Quaternion from a y rotation in radians. Internally checks QUANTUM_XY to rotate around z instead. More...
 
static Quaternion ToUnityQuaternion (this FPQuaternion r)
 Converts a Quantum FPQuaternion to a Unity Quaternion. More...
 
static Quaternion ToUnityQuaternion (this FPQuaternion r, bool swizzle)
 Converts a Quantum FPQuaternion to a Unity Quaternion with swizzling the y and z axis. More...
 
static Quaternion ToUnityQuaternionDegrees (this FP r)
 Create a Quaternion from a y rotation in degrees. Internally checks QUANTUM_XY to rotate around z instead. More...
 
static Vector2 ToUnityVector2 (this FPVector2 v)
 Converts a Quantum FPVector2 to a Unity Vector2. More...
 
static Vector2 ToUnityVector2 (this FPVector3 v)
 Obsolete More...
 
static Vector3 ToUnityVector3 (this FPVector2 v)
 Converts a Quantum vector2 to a Unity vector3 by setting the y component to 0. (sets the z component to 0 if QUANTUM_XY is defined). More...
 
static Vector3 ToUnityVector3 (this FPVector3 v)
 Converts a Quantum vector3 to a Unity vector3. More...
 
static Vector3 ToUnityVector3 (this FPVector3 v, bool quantumXYSwizzle)
 Use this version of ToUnityVector3() when converting a 3D position from the XZ plane in the simulation to the 2D XY plane in Unity. More...
 
static Vector2Int ToVector2Int (this IntVector2 v)
 Converts a Quantum IntVector2 into a Unity Vector2Int. More...
 
static Vector3Int ToVector3Int (this IntVector3 v)
 Converts a Quantum IntVector3 object to a Unity Vector3Int. More...
 

Detailed Description

Unity specific FixedPoint math utilities. All conversions between Unity float into Quantum FP (e.g. Vector2 to FPVector2) are considered non-deterministic and should never be used in the Quantum simulation directly.

Member Function Documentation

◆ LoadLookupTables()

static void Quantum.FPMathUtils.LoadLookupTables ( Boolean  force = false)
inlinestatic

Load the lookup tables from the resources folders.

Parameters
forceWill reload the table if set to true

◆ ToFP()

static FP Quantum.FPMathUtils.ToFP ( this Single  v)
inlinestatic

Convert a float to an FP, with rounding towards zero. To round towards nearest representable FP, use ToRoundedFP. This is always considered to be unsafe and non-deterministic and should never be used in conjunction with the simulation.

See also
FP.FromFloat_UNSAFE

◆ ToRoundedFP()

static FP Quantum.FPMathUtils.ToRoundedFP ( this Single  v)
inlinestatic

Convert a float to an FP, with rounding to the nearest representable FP. This is always considered to be unsafe and non-deterministic and should never be used in conjunction with the simulation.

See also
FP.FromRoundedFloat_UNSAFE

◆ FlipRotation()

static FP Quantum.FPMathUtils.FlipRotation ( this FP  r)
inlinestatic

Inverts the FP if QUNATUM_XY is not defined.

Parameters
r2D rotation
Returns
Inverted value.

◆ ToUnityQuaternionDegrees()

static Quaternion Quantum.FPMathUtils.ToUnityQuaternionDegrees ( this FP  r)
inlinestatic

Create a Quaternion from a y rotation in degrees. Internally checks QUANTUM_XY to rotate around z instead.

Parameters
rRotation in degrees
Returns
Unity rotation

◆ ToUnityQuaternion() [1/3]

static Quaternion Quantum.FPMathUtils.ToUnityQuaternion ( this FP  r)
inlinestatic

Creates a Quaternion from a y rotation in radians. Internally checks QUANTUM_XY to rotate around z instead.

Parameters
rRotation in radians
Returns
Unity rotation

◆ ToUnityQuaternion() [2/3]

static Quaternion Quantum.FPMathUtils.ToUnityQuaternion ( this FPQuaternion  r)
inlinestatic

Converts a Quantum FPQuaternion to a Unity Quaternion.

Parameters
rRotation
Returns
Unity rotation

◆ ToUnityQuaternion() [3/3]

static Quaternion Quantum.FPMathUtils.ToUnityQuaternion ( this FPQuaternion  r,
bool  swizzle 
)
inlinestatic

Converts a Quantum FPQuaternion to a Unity Quaternion with swizzling the y and z axis.

Parameters
rRotation
swizzleTrue if the rotation should swizzle
Returns
Unity rotation

◆ ToFPQuaternion()

static FPQuaternion Quantum.FPMathUtils.ToFPQuaternion ( this Quaternion  r)
inlinestatic

Convert a Unity quaternion to a Quantum FPQuaternion.

Parameters
rRotation
Returns
Quantum rotation

◆ ToFPRotation2DDegrees()

static FP Quantum.FPMathUtils.ToFPRotation2DDegrees ( this Quaternion  r)
inlinestatic

Converts a Unity quaternion to 2D rotation in degrees by only using the y (or z axis if QUANTUM_XY is defined)

Parameters
rUnity rotation
Returns
2D rotation in degree

◆ ToFPRotation2D()

static FP Quantum.FPMathUtils.ToFPRotation2D ( this Quaternion  r)
inlinestatic

Converts a Unity quaternion to 2D rotation in radians by only using the y (or z axis if QUANTUM_XY is defined)

Parameters
rUnity rotation
Returns
2D rotation in radian

◆ ToFPVector2() [1/2]

static FPVector2 Quantum.FPMathUtils.ToFPVector2 ( this Vector2  v)
inlinestatic

Converts a Unity Vector2 to a Quantum FPVector2, with each component being rounded towards zero. To round towards the nearest representable FP, use ToRoundedFPVector2.

Parameters
vUnity vector2
Returns
Quantum vector2

◆ ToUnityVector2() [1/2]

static Vector2 Quantum.FPMathUtils.ToUnityVector2 ( this FPVector2  v)
inlinestatic

Converts a Quantum FPVector2 to a Unity Vector2.

Parameters
vQuantum vector2
Returns
Unity vector2

◆ ToFPVector2() [2/2]

static FPVector2 Quantum.FPMathUtils.ToFPVector2 ( this Vector3  v)
inlinestatic

Converts a Unity Vector3 to a Quantum FPVector2 by removing the y component (removing the z component if QUANTUM_XY is defined). Each component is rounded towards zero.

Parameters
vUnity vector3
Returns
Quantum vector2
See also
FP.FromFloat_UNSAFE

◆ ToRoundedFPVector2()

static FPVector2 Quantum.FPMathUtils.ToRoundedFPVector2 ( this Vector3  v)
inlinestatic

Converts a Unity Vector3 to a Quantum FPVector2 by removing the y component (removing the z component if QUANTUM_XY is defined). Each component is rounded towards the nearest representable FP.

Parameters
vUnity vector3
Returns
Quantum vector2
See also
FP.FromRoundedFloat_UNSAFE

◆ ToFPVerticalPosition()

static FP Quantum.FPMathUtils.ToFPVerticalPosition ( this Vector3  v)
inlinestatic

Extracts the vertical position of a Unity Vector3 and converts it to a Quantum FP. Will use the inverse z component if QUANTUM_XY is defined.

Parameters
vUnity vector3
Returns
The height component

◆ ToFPVector3()

static FPVector3 Quantum.FPMathUtils.ToFPVector3 ( this Vector3  v)
inlinestatic

Converts a Unity Vector3 to a Quantum FPVector3, with each component being rounded towards zero.

Parameters
vUnity vector3
Returns
Quantum vector3

◆ ToVector3Int()

static Vector3Int Quantum.FPMathUtils.ToVector3Int ( this IntVector3  v)
inlinestatic

Converts a Quantum IntVector3 object to a Unity Vector3Int.

Parameters
vThe IntVector3 object to convert.
Returns
The converted Unity Vector3Int.

◆ ToVector2Int()

static Vector2Int Quantum.FPMathUtils.ToVector2Int ( this IntVector2  v)
inlinestatic

Converts a Quantum IntVector2 into a Unity Vector2Int.

Parameters
vThe Quantum IntVector2 to convert.
Returns
The converted Unity Vector2Int.

◆ ToFPMatrix4X4()

static FPMatrix4x4 Quantum.FPMathUtils.ToFPMatrix4X4 ( this Matrix4x4  m)
inlinestatic

Converts a Unity Matrix4x4 to a Quantum FPMatrix4x4, with each component being rounded towards the nearest representable FP.

Parameters
mThe Unity Matrix4x4
Returns
Quantum Matrix4x4

◆ ToRoundedFPVector3()

static FPVector3 Quantum.FPMathUtils.ToRoundedFPVector3 ( this Vector3  v)
inlinestatic

Converts a Unity vector3 to a Quantum FPVector3, with each component being rounded towards the nearest representable FP.

Parameters
vUnity vector3
Returns
Quantum vector3

◆ ToUnityVector3() [1/3]

static Vector3 Quantum.FPMathUtils.ToUnityVector3 ( this FPVector2  v)
inlinestatic

Converts a Quantum vector2 to a Unity vector3 by setting the y component to 0. (sets the z component to 0 if QUANTUM_XY is defined).

Parameters
vQuantum vector2
Returns
Unity vector3

◆ ToUnityVector3() [2/3]

static Vector3 Quantum.FPMathUtils.ToUnityVector3 ( this FPVector3  v)
inlinestatic

Converts a Quantum vector3 to a Unity vector3.

Parameters
vQuantum vector3
Returns
Unity vector3

◆ ToUnityVector3() [3/3]

static Vector3 Quantum.FPMathUtils.ToUnityVector3 ( this FPVector3  v,
bool  quantumXYSwizzle 
)
inlinestatic

Use this version of ToUnityVector3() when converting a 3D position from the XZ plane in the simulation to the 2D XY plane in Unity.

◆ ToUnityVector2() [2/2]

static Vector2 Quantum.FPMathUtils.ToUnityVector2 ( this FPVector3  v)
inlinestatic

Obsolete

◆ RoundToInt() [1/2]

static Vector3 Quantum.FPMathUtils.RoundToInt ( this Vector3  v)
inlinestatic

Rounds all components of the Unity vector to the nearest integer.

Parameters
vUnity vector3
Returns
The rounded vector

◆ RoundToInt() [2/2]

static Vector2 Quantum.FPMathUtils.RoundToInt ( this Vector2  v)
inlinestatic

Rounds all components of the Unity vector to the nearest integer.

Parameters
vUnity vector2
Returns
The rounded vector

◆ ToColor32()

static Color32 Quantum.FPMathUtils.ToColor32 ( this ColorRGBA  clr)
inlinestatic

Obsolete

◆ ToColor()

static Color Quantum.FPMathUtils.ToColor ( this ColorRGBA  clr)
inlinestatic

Obsolete