Struct Quaternion
Implements
Inherited Members
Namespace: GTA.Math
Assembly: ScriptHookVDotNet3.dll
Syntax
[Serializable]
public struct Quaternion : IEquatable<Quaternion>
Constructors
| Improve this Doc View SourceQuaternion(Vector3, Single)
Initializes a new instance of the Quaternion structure.
Declaration
public Quaternion(Vector3 axis, float angle)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | axis | The axis of rotation. |
Single | angle | The angle of rotation in radians. |
Quaternion(Single, Single, Single, Single)
Initializes a new instance of the Quaternion structure.
Declaration
public Quaternion(float x, float y, float z, float w)
Parameters
Type | Name | Description |
---|---|---|
Single | x | The X component of the quaternion. |
Single | y | The Y component of the quaternion. |
Single | z | The Z component of the quaternion. |
Single | w | The W component of the quaternion. |
Fields
| Improve this Doc View SourceW
Gets or sets the W component of the quaternion.
Declaration
public float W
Field Value
Type | Description |
---|---|
Single | The W component of the quaternion. |
X
Gets or sets the X component of the quaternion.
Declaration
public float X
Field Value
Type | Description |
---|---|
Single | The X component of the quaternion. |
Y
Gets or sets the Y component of the quaternion.
Declaration
public float Y
Field Value
Type | Description |
---|---|
Single | The Y component of the quaternion. |
Z
Gets or sets the Z component of the quaternion.
Declaration
public float Z
Field Value
Type | Description |
---|---|
Single | The Z component of the quaternion. |
Properties
| Improve this Doc View SourceAngle
Gets the angle of the quaternion.
Declaration
public readonly float Angle { get; }
Property Value
Type | Description |
---|---|
Single |
Axis
Gets the axis components of the quaternion.
Declaration
public readonly Vector3 Axis { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Identity
The identity Quaternion (0, 0, 0, 1).
Declaration
public static readonly Quaternion Identity { get; }
Property Value
Type | Description |
---|---|
Quaternion |
One
A Quaternion with all of its components set to one.
Declaration
public static readonly Quaternion One { get; }
Property Value
Type | Description |
---|---|
Quaternion |
Zero
A Quaternion with all of its components set to zero.
Declaration
public static readonly Quaternion Zero { get; }
Property Value
Type | Description |
---|---|
Quaternion |
Methods
| Improve this Doc View SourceAdd(Quaternion, Quaternion)
Adds two quaternions.
Declaration
public static Quaternion Add(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to add. |
Quaternion | right | The second quaternion to add. |
Returns
Type | Description |
---|---|
Quaternion | The sum of the two quaternions. |
AngleBetween(Quaternion, Quaternion)
Returns the angle in degrees between two rotations a and b.
Declaration
public static float AngleBetween(Quaternion a, Quaternion b)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | a | The first quaternion to calculate angle. |
Quaternion | b | The second quaternion to calculate angle. |
Returns
Type | Description |
---|---|
Single | The angle in degrees between two rotations a and b. |
Conjugate()
Conjugates the quaternion.
Declaration
public void Conjugate()
Conjugate(Quaternion)
Creates the conjugate of a specified Quaternion.
Declaration
public static Quaternion Conjugate(Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The Quaternion of which to return the conjugate. |
Returns
Type | Description |
---|---|
Quaternion | A new Quaternion that is the conjugate of the specified one. |
DirectionVectors(Vector3, Vector3, Vector3)
Creates a Quaternion from the given relative x, y, z axis
Declaration
public static Quaternion DirectionVectors(Vector3 rightVector, Vector3 forwardVector, Vector3 upVector)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | rightVector | Relative X axis |
Vector3 | forwardVector | Relative Y axis |
Vector3 | upVector | Relative Z axis |
Returns
Type | Description |
---|---|
Quaternion | The newly created quaternion. |
Divide(Quaternion, Quaternion)
Divides a quaternion by another.
Declaration
public static Quaternion Divide(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to divide. |
Quaternion | right | The second quaternion to divide. |
Returns
Type | Description |
---|---|
Quaternion | The divided quaternion. |
Dot(Quaternion, Quaternion)
Calculates the dot product of two quaternions.
Declaration
public static float Dot(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | First source quaternion. |
Quaternion | right | Second source quaternion. |
Returns
Type | Description |
---|---|
Single | The dot product of the two quaternions. |
Equals(Quaternion)
Returns a value that indicates whether the current instance is equal to the specified object.
Declaration
public bool Equals(Quaternion other)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | other | Object to make the comparison with. |
Returns
Type | Description |
---|---|
Boolean | true if the current instance is equal to the specified object; false otherwise. |
Equals(Object)
Returns a value that indicates whether the current instance is equal to a specified object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | Object to make the comparison with. |
Returns
Type | Description |
---|---|
Boolean | true if the current instance is equal to the specified object; false otherwise. |
Overrides
| Improve this Doc View SourceEuler(Vector3)
Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).
Declaration
public static Quaternion Euler(Vector3 euler)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | euler | Euler angles in degrees. euler.X = around X axis, euler.Y = around Y axis, euler.Z = around Z axis |
Returns
Type | Description |
---|---|
Quaternion |
Euler(Single, Single, Single)
Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).
Declaration
public static Quaternion Euler(float zaxis, float xaxis, float yaxis)
Parameters
Type | Name | Description |
---|---|---|
Single | zaxis | Z degrees. |
Single | xaxis | X degrees. |
Single | yaxis | Y degrees. |
Returns
Type | Description |
---|---|
Quaternion |
FromToRotation(Vector3, Vector3)
Creates a rotation which rotates from fromDirection to toDirection.
Declaration
public static Quaternion FromToRotation(Vector3 fromDirection, Vector3 toDirection)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | fromDirection | |
Vector3 | toDirection |
Returns
Type | Description |
---|---|
Quaternion |
GetDirectionVectors(Quaternion, out Vector3, out Vector3, out Vector3)
Get direction vectors from the given quaternion
Declaration
public static void GetDirectionVectors(Quaternion quaternion, out Vector3 rightVector, out Vector3 forwardVector, out Vector3 upVector)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion |
Vector3 | rightVector | RightVector = relative x axis |
Vector3 | forwardVector | ForwardVector = relative y axis |
Vector3 | upVector | UpVector = relative z axis |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer hash code. |
Overrides
| Improve this Doc View SourceInvert()
Conjugates and renormalizes the quaternion.
Declaration
public void Invert()
Invert(Quaternion)
Conjugates and renormalizes the quaternion.
Declaration
public static Quaternion Invert(Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion to conjugate and re-normalize. |
Returns
Type | Description |
---|---|
Quaternion | The conjugated and renormalized quaternion. |
Length()
Calculates the length of the quaternion.
Declaration
public float Length()
Returns
Type | Description |
---|---|
Single | The length of the quaternion. |
LengthSquared()
Calculates the squared length of the quaternion.
Declaration
public float LengthSquared()
Returns
Type | Description |
---|---|
Single | The squared length of the quaternion. |
Lerp(Quaternion, Quaternion, Single)
Performs a linear interpolation between two quaternion.
Declaration
public static Quaternion Lerp(Quaternion start, Quaternion end, float amount)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | start | Start quaternion. |
Quaternion | end | End quaternion. |
Single | amount | Value between 0 and 1 indicating the weight of |
Returns
Type | Description |
---|---|
Quaternion | The linear interpolation of the two quaternions. |
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount
a value of 0 will cause start
to be returned; a value of 1 will cause end
to be returned.
LookRotation(Vector3)
Creates a rotation with the specified forward
and WorldUp directions.
Declaration
public static Quaternion LookRotation(Vector3 forward)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | forward |
Returns
Type | Description |
---|---|
Quaternion |
LookRotation(Vector3, Vector3)
Creates a rotation with the specified forward
and up
directions.
Declaration
public static Quaternion LookRotation(Vector3 forward, Vector3 up)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | forward | |
Vector3 | up |
Returns
Type | Description |
---|---|
Quaternion |
Multiply(Quaternion, Quaternion)
Multiplies two Quaternions together.
Declaration
public static Quaternion Multiply(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The Quaternion on the left side of the multiplication. |
Quaternion | right | The Quaternion on the right side of the multiplication. |
Returns
Type | Description |
---|---|
Quaternion | The result of the multiplication. |
Multiply(Quaternion, Single)
Scales a quaternion by the given value.
Declaration
public static Quaternion Multiply(Quaternion quaternion, float scale)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion to scale. |
Single | scale | The amount by which to scale the quaternion. |
Returns
Type | Description |
---|---|
Quaternion | The scaled quaternion. |
Negate(Quaternion)
Reverses the direction of a given quaternion.
Declaration
public static Quaternion Negate(Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion to negate. |
Returns
Type | Description |
---|---|
Quaternion | A quaternion facing in the opposite direction. |
Normalize()
Converts the quaternion into a unit quaternion.
Declaration
public void Normalize()
Normalize(Quaternion)
Converts the quaternion into a unit quaternion.
Declaration
public static Quaternion Normalize(Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion to normalize. |
Returns
Type | Description |
---|---|
Quaternion | The normalized quaternion. |
RotateTowards(Quaternion, Quaternion, Single)
Rotates a rotation from towards to.
Declaration
public static Quaternion RotateTowards(Quaternion from, Quaternion to, float maxDegreesDelta)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | from | From Quaternion. |
Quaternion | to | To Quaternion. |
Single | maxDegreesDelta |
Returns
Type | Description |
---|---|
Quaternion |
RotateTransform(Quaternion, Vector3)
Rotates the point with rotation.
Declaration
public static Vector3 RotateTransform(Quaternion rotation, Vector3 point)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | rotation | The quaternion to rotate the vector. |
Vector3 | point | The vector to be rotated. |
Returns
Type | Description |
---|---|
Vector3 | The vector after rotation. |
RotateTransform(Quaternion, Vector3, Vector3)
Rotates the point with rotation.
Declaration
public static Vector3 RotateTransform(Quaternion rotation, Vector3 point, Vector3 center)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | rotation | The quaternion to rotate the vector. |
Vector3 | point | The vector to be rotated. |
Vector3 | center | The vector representing the origin of the new coordinate system. |
Returns
Type | Description |
---|---|
Vector3 | The vector after rotation in the original coordinate system. |
RotateTransform(Vector3)
Rotates the point with rotation.
Declaration
public Vector3 RotateTransform(Vector3 point)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | point | The vector to be rotated. |
Returns
Type | Description |
---|---|
Vector3 | The vector after rotation. |
RotateTransform(Vector3, Vector3)
Rotates the point with rotation.
Declaration
public Vector3 RotateTransform(Vector3 point, Vector3 center)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | point | The vector to be rotated. |
Vector3 | center | The vector representing the origin of the new coordinate system. |
Returns
Type | Description |
---|---|
Vector3 | The vector after rotation in the original coordinate system. |
RotationAxis(Vector3, Single)
Creates a quaternion given a rotation and an axis.
Declaration
public static Quaternion RotationAxis(Vector3 axis, float angle)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | axis | The axis of rotation. |
Single | angle | The angle of rotation in radians. |
Returns
Type | Description |
---|---|
Quaternion | The newly created quaternion. |
RotationMatrix(Matrix)
Creates a quaternion given a rotation matrix.
Declaration
public static Quaternion RotationMatrix(Matrix matrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix | matrix | The rotation matrix. |
Returns
Type | Description |
---|---|
Quaternion | The newly created quaternion. |
RotationYawPitchRoll(Single, Single, Single)
Creates a Quaternion from the given yaw, pitch, and roll, in radians.
Declaration
public static Quaternion RotationYawPitchRoll(float yaw, float pitch, float roll)
Parameters
Type | Name | Description |
---|---|---|
Single | yaw | The yaw angle, in radians, around the Z-axis. |
Single | pitch | The pitch angle, in radians, around the X-axis. |
Single | roll | The roll angle, in radians, around the Y-axis. |
Returns
Type | Description |
---|---|
Quaternion | The newly created quaternion. |
Slerp(Quaternion, Quaternion, Single)
Interpolates between two quaternions, using spherical linear interpolation..
Declaration
public static Quaternion Slerp(Quaternion start, Quaternion end, float amount)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | start | Start quaternion. |
Quaternion | end | End quaternion. |
Single | amount | Value between 0 and 1 indicating the weight of |
Returns
Type | Description |
---|---|
Quaternion | The spherical linear interpolation of the two quaternions. |
SlerpUnclamped(Quaternion, Quaternion, Single)
Interpolates between two quaternions, using spherical linear interpolation. The parameter /t/ is not clamped.
Declaration
public static Quaternion SlerpUnclamped(Quaternion a, Quaternion b, float t)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | a | |
Quaternion | b | |
Single | t |
Returns
Type | Description |
---|---|
Quaternion |
Subtract(Quaternion, Quaternion)
Subtracts two quaternions.
Declaration
public static Quaternion Subtract(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to subtract. |
Quaternion | right | The second quaternion to subtract. |
Returns
Type | Description |
---|---|
Quaternion | The difference of the two quaternions. |
ToString()
Converts the value of the object to its equivalent string representation.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The string representation of the value of this instance. |
Overrides
| Improve this Doc View SourceToString(String)
Converts the value of the object to its equivalent string representation.
Declaration
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
String | format | The format. |
Returns
Type | Description |
---|---|
String | The string representation of the value of this instance. |
Operators
| Improve this Doc View SourceAddition(Quaternion, Quaternion)
Adds two quaternions.
Declaration
public static Quaternion operator +(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to add. |
Quaternion | right | The second quaternion to add. |
Returns
Type | Description |
---|---|
Quaternion | The sum of the two quaternions. |
Division(Quaternion, Quaternion)
Divides a Quaternion by another Quaternion.
Declaration
public static Quaternion operator /(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The source Quaternion. |
Quaternion | right | The divisor. |
Returns
Type | Description |
---|---|
Quaternion | The result of the division. |
Equality(Quaternion, Quaternion)
Tests for equality between two objects.
Declaration
public static bool operator ==(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first value to compare. |
Quaternion | right | The second value to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
Inequality(Quaternion, Quaternion)
Tests for inequality between two objects.
Declaration
public static bool operator !=(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first value to compare. |
Quaternion | right | The second value to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
Multiply(Quaternion, Quaternion)
Multiplies a quaternion by another.
Declaration
public static Quaternion operator *(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to multiply. |
Quaternion | right | The second quaternion to multiply. |
Returns
Type | Description |
---|---|
Quaternion | The multiplied quaternion. |
Multiply(Quaternion, Vector3)
Rotates the point with rotation.
Declaration
public static Vector3 operator *(Quaternion rotation, Vector3 point)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | rotation | The quaternion to rotate the vector. |
Vector3 | point | The vector to be rotated. |
Returns
Type | Description |
---|---|
Vector3 | The vector after rotation. |
Multiply(Quaternion, Single)
Scales a quaternion by the given value.
Declaration
public static Quaternion operator *(Quaternion quaternion, float scale)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion to scale. |
Single | scale | The amount by which to scale the quaternion. |
Returns
Type | Description |
---|---|
Quaternion | The scaled quaternion. |
Multiply(Single, Quaternion)
Scales a quaternion by the given value.
Declaration
public static Quaternion operator *(float scale, Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Single | scale | The amount by which to scale the quaternion. |
Quaternion | quaternion | The quaternion to scale. |
Returns
Type | Description |
---|---|
Quaternion | The scaled quaternion. |
Subtraction(Quaternion, Quaternion)
Subtracts two quaternions.
Declaration
public static Quaternion operator -(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to subtract. |
Quaternion | right | The second quaternion to subtract. |
Returns
Type | Description |
---|---|
Quaternion | The difference of the two quaternions. |
UnaryNegation(Quaternion)
Reverses the direction of a given quaternion.
Declaration
public static Quaternion operator -(Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion to negate. |
Returns
Type | Description |
---|---|
Quaternion | A quaternion facing in the opposite direction. |