struct Rotation

in global

Represents a Quaternion rotation. Can be interpreted as a direction unit vector (x,y,z) + rotation around the direction vector (w) which represents the up direction. Unlike , this cannot store multiple revolutions around an axis.


public float x { get; set; }

The X component of this rotation.

public float y { get; set; }

The Y component of this rotation.

public float z { get; set; }

The Z component of this rotation.

public float w { get; set; }

The W component of this rotation (rotation around the normal defined by X,Y,Z components).

public Rotation( float x, float y, float z, float w )

Initializes the rotation from given components.

  • x The X component.
  • y The Y component.
  • z The Z component.
  • w The W component.

public Rotation( Vector3 v, float w )

Initializes the rotation from a normal vector + rotation around it.

  • v The normal vector.
  • w The W component, aka rotation around the normal vector.

public Vector3 Forward { get; }

The forwards direction of this rotation.

public Vector3 Backward { get; }

The backwards direction of this rotation.

public Vector3 Right { get; }

The right hand direction of this rotation.

public Vector3 Left { get; }

The left hand direction of this rotation.

public Vector3 Up { get; }

The upwards direction of this rotation.

public Vector3 Down { get; }

The downwards direction of this rotation.

public Rotation Inverse { get; }

Returns the inverse of this rotation.

public Rotation Normal { get; }

Divides each component of the rotation by its length, normalizing the rotation.

public Rotation Conjugate { get; }

Returns conjugate of this rotation, meaning the X Y and Z components are negated.

public static Rotation Random { get; }

Returns a uniformly random rotation.

public static Rotation FromAxis( Vector3 axis, float degrees )

Create from angle and an axis

Remarks: vector must be normalized before calling this method or the resulting will be incorrect.

public static Rotation From( Angles angles )

Create a Rotation (quaternion) from Angles

public static Rotation From( float pitch, float yaw, float roll )

Create a Rotation (quaternion) from pitch yaw roll (degrees)

public static Rotation FromPitch( float pitch )

Create a Rotation (quaternion) from pitch (degrees)

public static Rotation FromYaw( float yaw )

Create a Rotation (quaternion) from yaw (degrees)

public static Rotation FromRoll( float roll )

Create a Rotation (quaternion) from roll (degrees)

public static Rotation LookAt( Vector3 forward, Vector3 up )

Create a Rotation (quaternion) from a forward and up vector

public static Rotation LookAt( Vector3 forward )

Create a Rotation (quaternion) from a forward vector, using as an up vector. This won't give nice results if is very close to straight up or down, if that can happen you should use .

public static Rotation Identity

A rotation that represents no rotation.

public static Rotation Difference( Rotation from, Rotation to )

Returns the difference between two rotations, as a rotation

public float Distance( Rotation to )

The degree angular distance between this rotation and the target

public static Rotation Lerp( Rotation a, Rotation b, float frac, bool clamp = True )

Perform a linear interpolation from a to b by given amount.

public static Rotation Slerp( Rotation a, Rotation b, float amount, bool clamp = True )

Perform a spherical interpolation from a to b by given amount.

public Rotation LerpTo( Rotation target, float frac, bool clamp = True )

Perform a linear interpolation from this rotation to a target rotation by given amount.

public Rotation SlerpTo( Rotation target, float frac, bool clamp = True )

Perform a spherical interpolation from this rotation to a target rotation by given amount.

public Rotation Clamp( Rotation to, float degrees )

Clamp to within degrees of passed rotation

public Rotation Clamp( Rotation to, float degrees, ref float change )

Clamp to within degrees of passed rotation. Also pases out the change in degrees, if any.

public Rotation RotateAroundAxis( Vector3 axis, float degrees )

A convenience function that rotates this rotation around a given axis given amount of degrees

Remarks: vector must be normalized before calling this method or the resulting will be incorrect.

public static Rotation SmoothDamp( Rotation current, ref Rotation target, ref Vector3 velocity, float smoothTime, float deltaTime )

Smoothly move towards the target rotation

public Vector3 ClosestAxis( Vector3 normal )

Will give you the axis most aligned with the given normal

public static Rotation FromToRotation( ref Vector3 fromDirection, ref Vector3 toDirection )

Returns a Rotation that rotates from one direction to another.

public static Rotation Parse( string str )

Given a string, try to convert this into a quaternion rotation. The format is "x,y,z,w"

public static Rotation Parse( string str, IFormatProvider provider )

🤡 Doc inheritance is not yet supported.

No summary.

public static bool TryParse( string str, ref Rotation result )

🤡 Doc inheritance is not yet supported.

No summary.

public static bool TryParse( string str, IFormatProvider provider, ref Rotation result )

🤡 Doc inheritance is not yet supported.

No summary.

public bool AlmostEqual( ref Rotation r, float delta = 0.0001 )

Returns true if we're nearly equal to the passed rotation.

  • r The value to compare with
  • delta The max difference between component values
  • Returns True if nearly equal

public Rotation( )

😔 No documentation found.

public static Rotation op_Subtraction( Rotation a, Rotation b )

😔 No documentation found.

public int GetHashCode( )

😔 No documentation found.

public bool Equals( Rotation o )

😔 No documentation found.

public bool Equals( object obj )

😔 No documentation found.

public static bool op_Inequality( Rotation left, Rotation right )

😔 No documentation found.

public static bool op_Equality( Rotation left, Rotation right )

😔 No documentation found.

public Type GetType( )

😔 No documentation found.

public static Rotation op_Addition( Rotation a, Rotation b )

😔 No documentation found.

public static Rotation op_Implicit( ref Quaternion value )

😔 No documentation found.

public static Rotation op_Multiply( Rotation a, float f )

😔 No documentation found.

public static Rotation op_Multiply( Rotation a, Rotation b )

😔 No documentation found.

public static Vector3 op_Multiply( ref Rotation f, ref Vector3 c1 )

😔 No documentation found.

public static Quaternion op_Implicit( ref Rotation value )

😔 No documentation found.

public static Angles op_Implicit( ref Rotation value )

😔 No documentation found.

public static Rotation op_Implicit( ref Angles value )

😔 No documentation found.

public float Angle( )

😔 No documentation found.

public string ToString( )

😔 No documentation found.

public float Roll( )

😔 No documentation found.

public float Yaw( )

😔 No documentation found.

public float Pitch( )

😔 No documentation found.

public static Rotation op_Division( Rotation a, float f )

😔 No documentation found.

public Angles Angles( )

😔 No documentation found.