Struct Quaternion
Represents a Quaternion.
Implements
Inherited Members
Namespace: AGS.API
Assembly: AGS.API.dll
Syntax
public struct Quaternion : IEquatable<Quaternion>
Constructors
| Improve this Doc View SourceQuaternion(Vector3)
Construct a new Quaternion from given Euler angles
Declaration
public Quaternion(Vector3 eulerAngles)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | eulerAngles | The euler angles as a Vector3 |
Quaternion(Vector3, Single)
Construct a new Quaternion from vector and w components
Declaration
public Quaternion(Vector3 v, float w)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | v | The vector part |
System.Single | w | The w part |
Quaternion(Single, Single, Single)
Construct a new Quaternion from given Euler angles
Declaration
public Quaternion(float pitch, float yaw, float roll)
Parameters
Type | Name | Description |
---|---|---|
System.Single | pitch | The pitch (attitude), rotation around X axis |
System.Single | yaw | The yaw (heading), rotation around Y axis |
System.Single | roll | The roll (bank), rotation around Z axis |
Quaternion(Single, Single, Single, Single)
Construct a new Quaternion
Declaration
public Quaternion(float x, float y, float z, float w)
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | The x component |
System.Single | y | The y component |
System.Single | z | The z component |
System.Single | w | The w component |
Fields
| Improve this Doc View SourceIdentity
Defines the identity quaternion.
Declaration
public static readonly Quaternion Identity
Field Value
Type | Description |
---|---|
Quaternion |
Properties
| Improve this Doc View SourceLength
Gets the length (magnitude) of the quaternion.
Declaration
public float Length { get; }
Property Value
Type | Description |
---|---|
System.Single |
See Also
| Improve this Doc View SourceLengthSquared
Gets the square of the quaternion length (magnitude).
Declaration
public float LengthSquared { get; }
Property Value
Type | Description |
---|---|
System.Single |
W
Gets or sets the W component of this instance.
Declaration
public float W { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
X
Gets or sets the X component of this instance.
Declaration
public float X { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Xyz
Gets or sets an OpenTK.Vector3 with the X, Y and Z components of this instance.
Declaration
[CLSCompliant(false)]
public Vector3 Xyz { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
Y
Gets or sets the Y component of this instance.
Declaration
public float Y { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Z
Gets or sets the Z component of this instance.
Declaration
public float Z { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Methods
| Improve this Doc View SourceAdd(Quaternion, Quaternion)
Add two quaternions
Declaration
public static Quaternion Add(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first operand |
Quaternion | right | The second operand |
Returns
Type | Description |
---|---|
Quaternion | The result of the addition |
Add(ref Quaternion, ref Quaternion, out Quaternion)
Add two quaternions
Declaration
public static void Add(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first operand |
Quaternion | right | The second operand |
Quaternion | result | The result of the addition |
Conjugate()
Inverts the Vector3 component of this Quaternion.
Declaration
public void Conjugate()
Conjugate(Quaternion)
Get the conjugate of the given quaternion
Declaration
public static Quaternion Conjugate(Quaternion q)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | q | The quaternion |
Returns
Type | Description |
---|---|
Quaternion | The conjugate of the given quaternion |
Conjugate(ref Quaternion, out Quaternion)
Get the conjugate of the given quaternion
Declaration
public static void Conjugate(ref Quaternion q, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | q | The quaternion |
Quaternion | result | The conjugate of the given quaternion |
Equals(Quaternion)
Compares this Quaternion instance to another Quaternion for equality.
Declaration
public bool Equals(Quaternion other)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | other | The other Quaternion to be used in the comparison. |
Returns
Type | Description |
---|---|
System.Boolean | True if both instances are equal; false otherwise. |
Equals(Object)
Compares this object instance to another object for equality.
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
System.Object | other | The other object to be used in the comparison. |
Returns
Type | Description |
---|---|
System.Boolean | True if both objects are Quaternions of equal value. Otherwise it returns false. |
Overrides
FromAxisAngle(Vector3, Single)
Build a quaternion from the given axis and angle
Declaration
public static Quaternion FromAxisAngle(Vector3 axis, float angle)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | axis | The axis to rotate about |
System.Single | angle | The rotation angle in radians |
Returns
Type | Description |
---|---|
Quaternion | The equivalent quaternion |
FromEulerAngles(Vector3)
Builds a Quaternion from the given euler angles
Declaration
public static Quaternion FromEulerAngles(Vector3 eulerAngles)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | eulerAngles | The euler angles as a vector |
Returns
Type | Description |
---|---|
Quaternion | The equivalent Quaternion |
FromEulerAngles(ref Vector3, out Quaternion)
Builds a Quaternion from the given euler angles
Declaration
public static void FromEulerAngles(ref Vector3 eulerAngles, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | eulerAngles | The euler angles a vector |
Quaternion | result | The equivalent Quaternion |
FromEulerAngles(Single, Single, Single)
Builds a Quaternion from the given euler angles
Declaration
public static Quaternion FromEulerAngles(float pitch, float yaw, float roll)
Parameters
Type | Name | Description |
---|---|---|
System.Single | pitch | The pitch (attitude), rotation around X axis |
System.Single | yaw | The yaw (heading), rotation around Y axis |
System.Single | roll | The roll (bank), rotation around Z axis |
Returns
Type | Description |
---|---|
Quaternion |
FromMatrix(Matrix3)
Builds a quaternion from the given rotation matrix
Declaration
public static Quaternion FromMatrix(Matrix3 matrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix3 | matrix | A rotation matrix |
Returns
Type | Description |
---|---|
Quaternion | The equivalent quaternion |
FromMatrix(ref Matrix3, out Quaternion)
Builds a quaternion from the given rotation matrix
Declaration
public static void FromMatrix(ref Matrix3 matrix, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Matrix3 | matrix | A rotation matrix |
Quaternion | result | The equivalent quaternion |
GetHashCode()
Provides the hash code for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code formed from the bitwise XOR of this objects members. |
Overrides
Invert()
Reverses the rotation angle of this Quaterniond.
Declaration
public void Invert()
Invert(Quaternion)
Get the inverse of the given quaternion
Declaration
public static Quaternion Invert(Quaternion q)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | q | The quaternion to invert |
Returns
Type | Description |
---|---|
Quaternion | The inverse of the given quaternion |
Invert(ref Quaternion, out Quaternion)
Get the inverse of the given quaternion
Declaration
public static void Invert(ref Quaternion q, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | q | The quaternion to invert |
Quaternion | result | The inverse of the given quaternion |
Inverted()
Returns a copy of this Quaterniond with its rotation angle reversed.
Declaration
public Quaternion Inverted()
Returns
Type | Description |
---|---|
Quaternion |
Mult(Quaternion, Quaternion)
Multiplies two instances.
Declaration
[Obsolete("Use Multiply instead.")]
public static Quaternion Mult(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first instance. |
Quaternion | right | The second instance. |
Returns
Type | Description |
---|---|
Quaternion | A new instance containing the result of the calculation. |
Mult(ref Quaternion, ref Quaternion, out Quaternion)
Multiplies two instances.
Declaration
[Obsolete("Use Multiply instead.")]
public static void Mult(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first instance. |
Quaternion | right | The second instance. |
Quaternion | result | A new instance containing the result of the calculation. |
Multiply(Quaternion, Quaternion)
Multiplies two instances.
Declaration
public static Quaternion Multiply(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first instance. |
Quaternion | right | The second instance. |
Returns
Type | Description |
---|---|
Quaternion | A new instance containing the result of the calculation. |
Multiply(Quaternion, Single)
Multiplies an instance by a scalar.
Declaration
public static Quaternion Multiply(Quaternion quaternion, float scale)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The instance. |
System.Single | scale | The scalar. |
Returns
Type | Description |
---|---|
Quaternion | A new instance containing the result of the calculation. |
Multiply(ref Quaternion, ref Quaternion, out Quaternion)
Multiplies two instances.
Declaration
public static void Multiply(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first instance. |
Quaternion | right | The second instance. |
Quaternion | result | A new instance containing the result of the calculation. |
Multiply(ref Quaternion, Single, out Quaternion)
Multiplies an instance by a scalar.
Declaration
public static void Multiply(ref Quaternion quaternion, float scale, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The instance. |
System.Single | scale | The scalar. |
Quaternion | result | A new instance containing the result of the calculation. |
Normalize()
Scales the Quaternion to unit length.
Declaration
public void Normalize()
Normalize(Quaternion)
Scale the given quaternion to unit length
Declaration
public static Quaternion Normalize(Quaternion q)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | q | The quaternion to normalize |
Returns
Type | Description |
---|---|
Quaternion | The normalized quaternion |
Normalize(ref Quaternion, out Quaternion)
Scale the given quaternion to unit length
Declaration
public static void Normalize(ref Quaternion q, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | q | The quaternion to normalize |
Quaternion | result | The normalized quaternion |
Normalized()
Returns a copy of the Quaternion scaled to unit length.
Declaration
public Quaternion Normalized()
Returns
Type | Description |
---|---|
Quaternion |
Slerp(Quaternion, Quaternion, Single)
Do Spherical linear interpolation between two quaternions
Declaration
public static Quaternion Slerp(Quaternion q1, Quaternion q2, float blend)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | q1 | The first quaternion |
Quaternion | q2 | The second quaternion |
System.Single | blend | The blend factor |
Returns
Type | Description |
---|---|
Quaternion | A smooth blend between the given quaternions |
Sub(Quaternion, Quaternion)
Subtracts two instances.
Declaration
public static Quaternion Sub(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The left instance. |
Quaternion | right | The right instance. |
Returns
Type | Description |
---|---|
Quaternion | The result of the operation. |
Sub(ref Quaternion, ref Quaternion, out Quaternion)
Subtracts two instances.
Declaration
public static void Sub(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The left instance. |
Quaternion | right | The right instance. |
Quaternion | result | The result of the operation. |
ToAxisAngle()
Convert this instance to an axis-angle representation.
Declaration
public Vector4 ToAxisAngle()
Returns
Type | Description |
---|---|
Vector4 | A Vector4 that is the axis-angle representation of this quaternion. |
ToAxisAngle(out Vector3, out Single)
Convert the current quaternion to axis angle representation
Declaration
public void ToAxisAngle(out Vector3 axis, out float angle)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | axis | The resultant axis |
System.Single | angle | The resultant angle |
ToString()
Returns a System.String that represents the current Quaternion.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
Operators
| Improve this Doc View SourceAddition(Quaternion, Quaternion)
Adds two instances.
Declaration
public static Quaternion operator +(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first instance. |
Quaternion | right | The second instance. |
Returns
Type | Description |
---|---|
Quaternion | The result of the calculation. |
Equality(Quaternion, Quaternion)
Compares two instances for equality.
Declaration
public static bool operator ==(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first instance. |
Quaternion | right | The second instance. |
Returns
Type | Description |
---|---|
System.Boolean | True, if left equals right; false otherwise. |
Inequality(Quaternion, Quaternion)
Compares two instances for inequality.
Declaration
public static bool operator !=(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first instance. |
Quaternion | right | The second instance. |
Returns
Type | Description |
---|---|
System.Boolean | True, if left does not equal right; false otherwise. |
Multiply(Quaternion, Quaternion)
Multiplies two instances.
Declaration
public static Quaternion operator *(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first instance. |
Quaternion | right | The second instance. |
Returns
Type | Description |
---|---|
Quaternion | The result of the calculation. |
Multiply(Quaternion, Single)
Multiplies an instance by a scalar.
Declaration
public static Quaternion operator *(Quaternion quaternion, float scale)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The instance. |
System.Single | scale | The scalar. |
Returns
Type | Description |
---|---|
Quaternion | A new instance containing the result of the calculation. |
Multiply(Single, Quaternion)
Multiplies an instance by a scalar.
Declaration
public static Quaternion operator *(float scale, Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
System.Single | scale | The scalar. |
Quaternion | quaternion | The instance. |
Returns
Type | Description |
---|---|
Quaternion | A new instance containing the result of the calculation. |
Subtraction(Quaternion, Quaternion)
Subtracts two instances.
Declaration
public static Quaternion operator -(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first instance. |
Quaternion | right | The second instance. |
Returns
Type | Description |
---|---|
Quaternion | The result of the calculation. |