Struct Quaternion
Quaternion, used to describe a rotation.
Assembly: ABB.Robotics.Math.dll
Syntax
Constructors
View Source
Quaternion(Matrix4)
Creates a quaternion from the rotation part of a 4x4 matrix.
Declaration
public Quaternion(Matrix4 m)
Parameters
| Type |
Name |
Description |
| Matrix4 |
m |
Matrix (assumed to be pure rotation/translation)
|
View Source
Quaternion(Vector3)
Creates a quaternion from euler angles.
Declaration
public Quaternion(Vector3 eulerZYX)
Parameters
| Type |
Name |
Description |
| Vector3 |
eulerZYX |
Orientation in Euler angles (zyx order).
|
View Source
Quaternion(Vector3, double)
Creates a quaternion from rotation axis and angle.
Declaration
public Quaternion(Vector3 axis, double angle)
Parameters
| Type |
Name |
Description |
| Vector3 |
axis |
Normalized rotation axis
|
| double |
angle |
Rotation angle (radians)
|
Exceptions
View Source
Quaternion(double, Vector3)
Creates a quaternion from scalar and vector.
Declaration
public Quaternion(double w, Vector3 vec)
Parameters
| Type |
Name |
Description |
| double |
w |
Scalar part
|
| Vector3 |
vec |
Vector part
|
View Source
Quaternion(double, double, double)
Creates a quaternion from Euler angles (zyx order).
Declaration
public Quaternion(double xr, double yr, double zr)
Parameters
| Type |
Name |
Description |
| double |
xr |
Rotation around the x axis (radians)
|
| double |
yr |
Rotation around the y axis (radians)
|
| double |
zr |
Rotation around the z axis (radians)
|
View Source
Quaternion(double, double, double, double)
Creates a quaternion from four doubles.
Declaration
public Quaternion(double q1, double q2, double q3, double q4)
Parameters
View Source
Quaternion(double[])
Creates a quaternion from an array of doubles.
Declaration
public Quaternion(double[] vec)
Parameters
| Type |
Name |
Description |
| double[] |
vec |
|
Fields
View Source
Identity
Identity quaternion [1,0,0,0]
Declaration
public static readonly Quaternion Identity
Field Value
View Source
q1
Declaration
Field Value
View Source
q2
Declaration
Field Value
View Source
q3
Declaration
Field Value
View Source
q4
Declaration
Field Value
Properties
View Source
AxisAngle
Gets/sets the rotation as normalized rotation axis and angle
(represesented by a Vector4 [axis, angle]).
Declaration
public Vector4 AxisAngle { get; set; }
Property Value
Exceptions
View Source
EulerXYZ
Gets/sets the rotation as Euler angles (xyz order).
Equivalent to RPY (?).
Declaration
public Vector3 EulerXYZ { get; set; }
Property Value
View Source
EulerZYX
Gets/sets the rotation as Euler angles (zyx order).
Note: the vector contains the angles as [rx,ry,rz]
Declaration
public Vector3 EulerZYX { get; set; }
Property Value
View Source
this[int]
Declaration
public double this[int index] { get; set; }
Parameters
| Type |
Name |
Description |
| int |
index |
|
Property Value
View Source
Matrix
Gets/sets the rotation as a 3x3 matrix
Declaration
public Matrix3 Matrix { get; set; }
Property Value
View Source
Scalar
Gets/sets the scalar part.
Declaration
public double Scalar { get; set; }
Property Value
View Source
Vector
Gets/sets the vector part.
Declaration
public Vector3 Vector { get; set; }
Property Value
Methods
View Source
Add(Quaternion)
Element-wise addition method.
Declaration
public Quaternion Add(Quaternion rhs)
Parameters
Returns
View Source
AlmostEquals(Quaternion)
Comparison method for quaternions with tolerance (EPS)
Declaration
public bool AlmostEquals(Quaternion b)
Parameters
Returns
View Source
Conjugate()
Returns the conjugate [q1,-q2,-q3,-q4] of the quaternion.
Declaration
public Quaternion Conjugate()
Returns
View Source
Divide(double)
Quaternion-scalar division method.
Declaration
public Quaternion Divide(double rhs)
Parameters
| Type |
Name |
Description |
| double |
rhs |
|
Returns
View Source
Dot(Quaternion)
Declaration
public double Dot(Quaternion rhs)
Parameters
Returns
View Source
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type |
Name |
Description |
| object |
obj |
|
Returns
Overrides
View Source
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Overrides
View Source
Interpolate(Quaternion, double)
Spherical linear interpolation.
Declaration
public Quaternion Interpolate(Quaternion quat, double slerp)
Parameters
| Type |
Name |
Description |
| Quaternion |
quat |
Second quaternion
|
| double |
slerp |
Interpolation parameter
|
Returns
| Type |
Description |
| Quaternion |
Interpolated quaternion
|
View Source
Inverse()
Returns the inverse (conjugate*1/norm) of the quaternion.
Declaration
public Quaternion Inverse()
Returns
View Source
Invert()
Declaration
View Source
Magnitude()
Returns the magnitude of the quaternion.
Declaration
public double Magnitude()
Returns
View Source
Multiply(Quaternion)
Quaternion-Quaternion multiplication method.
Declaration
public Quaternion Multiply(Quaternion rhs)
Parameters
Returns
View Source
Multiply(double)
Quaternion-scalar multiplication method.
Declaration
public Quaternion Multiply(double rhs)
Parameters
| Type |
Name |
Description |
| double |
rhs |
|
Returns
View Source
Norm()
Returns the norm of the quaternion.
Declaration
Returns
View Source
Normalize()
Normalizes the quaternion.
Declaration
View Source
Subtract(Quaternion)
Element-wise subtraction method.
Declaration
public Quaternion Subtract(Quaternion rhs)
Parameters
Returns
View Source
ToString()
Returns a string in the format
[q1 q2 q3 q4]
Declaration
public override string ToString()
Returns
Overrides
View Source
Returns a string in the format
[q1 q2 q3 q4]
Declaration
public string ToString(IFormatProvider formatProvider)
Parameters
Returns
View Source
ToString(int, string)
Returns a string in the format q1 q2 q3 q4 with a specified number of decimals
and separator between the elements.
Declaration
public string ToString(int numDecimals, string separator)
Parameters
| Type |
Name |
Description |
| int |
numDecimals |
|
| string |
separator |
|
Returns
View Source
Returns a string in the format q1 q2 q3 q4 with a specified number of decimals
and separator between the elements.
Declaration
public string ToString(int numDecimals, string separator, IFormatProvider formatProvider)
Parameters
Returns
View Source
Converts the string representation of the format [q1,q2,q3,q4] to its Quaternion equivalent.
Declaration
public static bool TryParse(string value, IFormatProvider formatProvider, out Quaternion result)
Parameters
Returns
Operators
View Source
operator +(Quaternion, Quaternion)
Element-wise addition operator.
Declaration
public static Quaternion operator +(Quaternion lhs, Quaternion rhs)
Parameters
Returns
View Source
operator /(Quaternion, double)
Quaternion-scalar division operator.
Declaration
public static Quaternion operator /(Quaternion lhs, double rhs)
Parameters
Returns
View Source
operator ==(Quaternion, Quaternion)
Declaration
public static bool operator ==(Quaternion lhs, Quaternion rhs)
Parameters
Returns
View Source
operator !=(Quaternion, Quaternion)
Declaration
public static bool operator !=(Quaternion lhs, Quaternion rhs)
Parameters
Returns
View Source
operator *(Quaternion, Quaternion)
Quaternion-Quaternion multiplication operator.
Declaration
public static Quaternion operator *(Quaternion lhs, Quaternion rhs)
Parameters
Returns
View Source
operator *(Quaternion, double)
Quaternion-scalar multiplication operator.
Declaration
public static Quaternion operator *(Quaternion lhs, double rhs)
Parameters
Returns
View Source
operator *(double, Quaternion)
Scalar-Quaternion multiplication operator.
Declaration
public static Quaternion operator *(double lhs, Quaternion rhs)
Parameters
Returns
View Source
operator -(Quaternion, Quaternion)
Element-wise subtraction operator.
Declaration
public static Quaternion operator -(Quaternion lhs, Quaternion rhs)
Parameters
Returns
View Source
operator -(Quaternion)
Declaration
public static Quaternion operator -(Quaternion rhs)
Parameters
Returns