Click or drag to resize

Quaternion Structure

Represents the four coefficient values in a quaternion.

The first value a is the real part, while the rest multiplies i, j and k, that are imaginary.

quaternion = a + bi + cj + dk

Namespace:  Rhino.Geometry
Assembly:  RhinoCommon (in RhinoCommon.dll)
Syntax
[SerializableAttribute]
public struct Quaternion : IEquatable<Quaternion>, 
	IEpsilonComparable<Quaternion>

The Quaternion type exposes the following members.

Constructors
  NameDescription
Public methodQuaternion
Initializes a new quaternion with the provided coefficients.
Top
Properties
  NameDescription
Public propertyA
Gets or sets the real part of the quaternion.
Public propertyB
Gets or sets the first imaginary coefficient of the quaternion.
Public propertyC
Gets or sets the second imaginary coefficient of the quaternion.
Public propertyConjugate
Gets a new quaternion that is the conjugate of this quaternion.

This is (a,-b,-c,-d)

Public propertyD
Gets or sets the third imaginary coefficient of the quaternion.
Public propertyStatic memberI
Returns the (0,1,0,0) quaternion.
Public propertyStatic memberIdentity
Returns the (1,0,0,0) quaternion.
Public propertyInverse
Computes a new inverted quaternion,

(a/L2, -b/L2, -c/L2, -d/L2),

where L2 = length squared = (a*a + b*b + c*c + d*d).

This is the multiplicative inverse, i.e., (a,b,c,d)*(a/L2, -b/L2, -c/L2, -d/L2) = (1,0,0,0). If this is the zero quaternion, then the zero quaternion is returned.
Public propertyIsScalar
true if b, c, and d are all zero.
Public propertyIsValid
Determines if the four coefficients are valid numbers within RhinoCommon.

See IsValidDouble(Double).

Public propertyIsVector
true if a = 0 and at least one of b, c, or d is not zero.
Public propertyIsZero
true if a, b, c, and d are all zero.
Public propertyStatic memberJ
Returns the (0,0,1,0) quaternion.
Public propertyStatic memberK
Returns the (0,0,0,1) quaternion.
Public propertyLength
Returns the length or norm of the quaternion.
Public propertyLengthSquared
Gets the result of (a^2 + b^2 + c^2 + d^2).
Public propertyScalar
The real (scalar) part of the quaternion

This is A.

Public propertyVector
The imaginary part of the quaternion

(B,C,D)

Public propertyStatic memberZero
Returns the default quaternion, where all coefficients are 0.
Top
Methods
  NameDescription
Public methodStatic memberCreateFromRotationZYX
Constructs a quaternion defined by Tait-Byran angles, also loosely known as Euler angles.
Public methodStatic memberCreateFromRotationZYZ
Constructs a quaternion defined by Euler angles.
Public methodStatic memberCrossProduct
Computes the vector cross product of p and q = (0,x,y,z),

where (x,y,z) = CrossProduct(p.Vector,q.Vector).

This is not the same as the quaternion product p*q.

Public methodStatic memberDistance
Returns the distance or norm of the difference between two quaternions.
Public methodDistanceTo
Computes the distance or norm of the difference between this and another quaternion.
Public methodEpsilonEquals
Check that all values in other are within epsilon of the values in this
Public methodEquals(Object)
Determines whether an object is a quaternion and has the same value of this quaternion.
(Overrides ValueTypeEquals(Object).)
Public methodEquals(Quaternion)
Determines whether this quaternion has the same value of another quaternion.
Public methodGetEulerZYZ
Find the Euler angles for a rotation transformation.
Public methodGetHashCode
Gets a non-unique but repeatable hashing code for this quaternion.
(Overrides ValueTypeGetHashCode.)
Public methodGetRotation(Plane)
Returns the frame created by applying the quaternion's rotation to the canonical world frame (1,0,0),(0,1,0),(0,0,1).
Public methodGetRotation(Transform)
Returns a transformation matrix that performs the rotation defined by the quaternion. The transformation returned by this method has the property that xform * V = q.Rotate(V). If the quaternion is not unitized, the rotation of its unitized form is returned.
Public methodGetRotation(Double, Vector3d)
Returns the rotation defined by the quaternion.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetYawPitchRoll
Find sthe Tait-Byran angles, also loosely called Euler angles, for this quaternion.
Public methodInvert
Modifies this quaternion to become

(a/L2, -b/L2, -c/L2, -d/L2),

where L2 = length squared = (a*a + b*b + c*c + d*d).

This is the multiplicative inverse, i.e., (a,b,c,d)*(a/L2, -b/L2, -c/L2, -d/L2) = (1,0,0,0).

Public methodStatic memberLerp
Interpolates between two quaternions, using linear interpolation.
Public methodMatrixForm
Returns 4x4 real valued matrix form of the quaternion a b c d -b a -d c -c d a -b -d -c b a which has the same arithmetic properties as the quaternion.
Public methodStatic memberProduct
The quaternion product of p and q. This is the same value as p*q.
Public methodRotate
Rotates a 3d vector. This operation is also called conjugation, because the result is the same as (q.Conjugate()*(0,x,y,x)*q/q.LengthSquared).Vector.
Public methodStatic memberRotateTowards
Returns the quaternion obtained by rotating a towards b, limiting the rotation by MaxRadians.
Public methodStatic memberRotation(Double, Vector3d)
Returns the unit quaternion cos(angle/2), sin(angle/2)*x, sin(angle/2)*y, sin(angle/2)*z where (x,y,z) is the unit vector parallel to axis. This is the unit quaternion that represents the rotation of angle about axis.
Public methodStatic memberRotation(Plane, Plane)
Returns the unit quaternion that represents the rotation that maps plane0.xaxis to plane1.xaxis, plane0.yaxis to plane1.yaxis, and plane0.zaxis to plane1.zaxis.
Public methodSet
Sets all coefficients of the quaternion.
Public methodSetRotation(Double, Vector3d)
Sets the quaternion to cos(angle/2), sin(angle/2)*x, sin(angle/2)*y, sin(angle/2)*z where (x,y,z) is the unit vector parallel to axis. This is the unit quaternion that represents the rotation of angle about axis.
Public methodSetRotation(Plane, Plane)
Sets the quaternion to the unit quaternion which rotates plane0.xaxis to plane1.xaxis, plane0.yaxis to plane1.yaxis, and plane0.zaxis to plane1.zaxis.
Public methodStatic memberSlerp
Interpolates between two quaternions, using spherical linear interpolation.
Public methodToString
Returns a string representation of this Quaternion.
(Overrides ValueTypeToString.)
Public methodUnitize
Scales the quaternion's coordinates so that a*a + b*b + c*c + d*d = 1.
Top
Operators
  NameDescription
Public operatorStatic memberAddition
Adds two quaternions.

This sums each quaternion coefficient with its correspondent and returns a new result quaternion.

Public operatorStatic memberDivision
Divides all quaternion coefficients by a factor and returns a new quaternion with the result.
Public operatorStatic memberEquality
Determines whether two quaternions have the same value.
Public operatorStatic memberInequality
Determines whether two quaternions have different values.
Public operatorStatic memberMultiply(Quaternion, Quaternion)
Multiplies a quaternion with another one.

Quaternion multiplication (Hamilton product) is not commutative.

Public operatorStatic memberMultiply(Quaternion, Double)
Multiplies (scales) all quaternion coefficients by a factor and returns a new quaternion with the result.
Public operatorStatic memberMultiply(Quaternion, Int32)
Multiplies (scales) all quaternion coefficients by a factor and returns a new quaternion with the result.
Public operatorStatic memberMultiply(Quaternion, Single)
Multiplies (scales) all quaternion coefficients by a factor and returns a new quaternion with the result.
Public operatorStatic memberSubtraction
Subtracts a quaternion from another one.

This computes the difference of each quaternion coefficient with its correspondent and returns a new result quaternion.

Top
See Also