Struct Quaternions
A unit quaternions that defines rotation in 3D
public struct Quaternions : IEquatable<Quaternions>
- Implements
- Inherited Members
Constructors
Quaternions(double, double, double, double)
Create a quaternion with the specific values
public Quaternions(double w, double x, double y, double z)
Parameters
w
doubleThe W component of the quaternion: the value for cos(rotation angle / 2)
x
doubleThe X component of the vector: rotation axis * sin(rotation angle / 2)
y
doubleThe Y component of the vector: rotation axis * sin(rotation angle / 2)
z
doubleThe Z component of the vector: rotation axis * sin(rotation angle / 2)
Fields
Empty
Get the quaternions that represent a rotation of 0 degrees.
public static readonly Quaternions Empty
Field Value
Properties
AxisAngle
Get or set the equivalent axis angle representation. (x,y,z) is the rotation axis and |(x,y,z)| is the rotation angle in radians
public MCvPoint3D64f AxisAngle { get; set; }
Property Value
RotationAngle
Get the rotation angle in radian
public double RotationAngle { get; }
Property Value
RotationAxis
Get the rotation axis of the quaternion
public MCvPoint3D64f RotationAxis { get; }
Property Value
W
The W component of the quaternion: the value for cos(rotation angle / 2)
public double W { get; set; }
Property Value
X
The X component of the vector: rotation axis * sin(rotation angle / 2)
public double X { get; set; }
Property Value
Y
The Y component of the vector: rotation axis * sin(rotation angle / 2)
public double Y { get; set; }
Property Value
Z
The Z component of the vector: rotation axis * sin(rotation angle / 2)
public double Z { get; set; }
Property Value
Methods
Conjugate()
Compute the conjugate of the quaternions
public void Conjugate()
Equals(Quaternions)
Check if this quaternions equals to other
public bool Equals(Quaternions other)
Parameters
other
QuaternionsThe quaternions to be compared
Returns
- bool
True if two quaternions equals, false otherwise
GetEuler(ref double, ref double, ref double)
Get the equivalent euler angle
public void GetEuler(ref double x, ref double y, ref double z)
Parameters
x
doubleRotation around x-axis (roll) in radian
y
doubleRotation around y-axis (pitch) in radian
z
doublerotation around z-axis (yaw) in radian
GetRotationMatrix(Matrix<double>)
Fill the (3x3) rotation matrix with the value such that it represent the quaternions
public void GetRotationMatrix(Matrix<double> rotation)
Parameters
rotation
Matrix<double>The (3x3) rotation matrix which values will be set to represent this quaternions
Multiply(Quaternions)
Multiply the current Quaternions with quaternionsOther
public Quaternions Multiply(Quaternions quaternionsOther)
Parameters
quaternionsOther
QuaternionsThe other rotation
Returns
- Quaternions
A composition of the two rotations
RotatePoint(MCvPoint3D64f)
Rotate the specific point and return the result
public MCvPoint3D64f RotatePoint(MCvPoint3D64f point)
Parameters
point
MCvPoint3D64fThe point to be rotated
Returns
- MCvPoint3D64f
The rotated point
RotatePoints(Matrix<double>, Matrix<double>)
Rotate the points in pointsSrc
and save the result in pointsDst
. In-place operation is supported (pointsSrc
== pointsDst
).
public void RotatePoints(Matrix<double> pointsSrc, Matrix<double> pointsDst)
Parameters
pointsSrc
Matrix<double>The points to be rotated
pointsDst
Matrix<double>The result of the rotation, should be the same size as
pointsSrc
, can bepointsSrc
as well for inplace rotation
SetEuler(double, double, double)
Set the value of the quaternions using euler angle
public void SetEuler(double x, double y, double z)
Parameters
x
doubleRotation around x-axis (roll) in radian
y
doubleRotation around y-axis (pitch) in radian
z
doublerotation around z-axis (yaw) in radian
Slerp(Quaternions, double)
Perform quaternions linear interpolation
public Quaternions Slerp(Quaternions quaternionsOther, double weightForOther)
Parameters
quaternionsOther
QuaternionsThe other quaternions to interpolate with
weightForOther
doubleIf 0.0, the result is the same as this quaternions. If 1.0 the result is the same as
quaternionsOther
Returns
- Quaternions
The linear interpolated quaternions
ToString()
Get the string representation of the Quaternions
public override string ToString()
Returns
- string
The string representation
Operators
operator *(Quaternions, Quaternions)
Computes the multiplication of two quaternions
public static Quaternions operator *(Quaternions q1, Quaternions q2)
Parameters
q1
QuaternionsThe quaternions to be multiplied
q2
QuaternionsThe quaternions to be multiplied
Returns
- Quaternions
The multiplication of two quaternions