# Quaternion struct

Namespace: [Rhino.Geometry](https://developer.rhino3d.com/api/rhinocommon/namespace/rhino.geometry.md) · Assembly: [RhinoCommon](https://developer.rhino3d.com/api/rhinocommon/assembly/rhinocommon.md)

```cs
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 32)]
[Serializable]
public struct Quaternion : IEquatable<Quaternion>, IEpsilonComparable<Quaternion>
```

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

## Constructors

- [Quaternion](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/ctor.md): Initializes a new quaternion with the provided coefficients.

## Properties

- [A](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/a.md): Gets or sets the real part of the quaternion.
- [B](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/b.md): Gets or sets the first imaginary coefficient of the quaternion.
- [C](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/c.md): Gets or sets the second imaginary coefficient of the quaternion.
- [Conjugate](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/conjugate.md): Gets a new quaternion that is the conjugate of this quaternion. This is (a,-b,-c,-d)
- [D](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/d.md): Gets or sets the third imaginary coefficient of the quaternion.
- [I](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/i.md): (static) Returns the (0,1,0,0) quaternion.
- [Identity](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/identity.md): (static) Returns the (1,0,0,0) quaternion.
- [Inverse](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/inverse.md): 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.
- [IsScalar](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/isscalar.md): true if b, c, and d are all zero.
- [IsValid](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/isvalid.md): Determines if the four coefficients are valid numbers within RhinoCommon. See [RhinoMath.IsValidDouble(double)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.rhinomath/isvaliddouble.md).
- [IsVector](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/isvector.md): true if a = 0 and at least one of b, c, or d is not zero.
- [IsZero](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/iszero.md): true if a, b, c, and d are all zero.
- [J](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/j.md): (static) Returns the (0,0,1,0) quaternion.
- [K](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/k.md): (static) Returns the (0,0,0,1) quaternion.
- [Length](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/length.md): Returns the length or norm of the quaternion.
- [LengthSquared](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/lengthsquared.md): Gets the result of (a^2 + b^2 + c^2 + d^2).
- [Scalar](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/scalar.md): The real (scalar) part of the quaternion This is [Quaternion.A](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/a.md).
- [Vector](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/vector.md): The imaginary part of the quaternion (B,C,D)
- [Zero](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/zero.md): (static) Returns the default quaternion, where all coefficients are 0.

## Methods

- [CreateFromRotationZYX](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/createfromrotationzyx.md): (static) Constructs a quaternion defined by Tait-Byran angles, also loosely known as Euler angles.
- [CreateFromRotationZYZ](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/createfromrotationzyz.md): (static) Constructs a quaternion defined by Euler angles.
- [CrossProduct](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/crossproduct.md): (static) Computes the vector cross product of p and q = (0,x,y,z), where (x,y,z) = [CrossProduct](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.vector3d/crossproduct.md)(p.[Vector](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/vector.md),q.[Vector](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/vector.md)). This is not the same as the quaternion product p*q.
- [Distance](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/distance.md): (static) Returns the distance or norm of the difference between two quaternions.
- [DistanceTo](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/distanceto.md): Computes the distance or norm of the difference between this and another quaternion.
- [EpsilonEquals](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/epsilonequals.md): Check that all values in other are within epsilon of the values in this
- [Equals](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/equals.md): (2 overloads) Determines whether an object is a quaternion and has the same value of this quaternion.
- [GetEulerZYZ](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/geteulerzyz.md): Find the Euler angles for a rotation transformation.
- [GetHashCode](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/gethashcode.md): Gets a non-unique but repeatable hashing code for this quaternion.
- [GetRotation](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/getrotation.md): (3 overloads) Returns the rotation defined by the quaternion.
- [GetYawPitchRoll](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/getyawpitchroll.md): Find sthe Tait-Byran angles, also loosely called Euler angles, for this quaternion.
- [Invert](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/invert.md): 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).
- [Lerp](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/lerp.md): (static) Interpolates between two quaternions, using linear interpolation.
- [MatrixForm](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/matrixform.md): 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.
- [Product](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/product.md): (static) The quaternion product of p and q. This is the same value as p*q.
- [Rotate](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/rotate.md): 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.
- [RotateTowards](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/rotatetowards.md): (static) Returns the quaternion obtained by rotating a towards b, limiting the rotation by MaxRadians.
- [Rotation](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/rotation.md): (2 overloads, static) 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.
- [Set](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/set.md): Sets all coefficients of the quaternion.
- [SetRotation](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/setrotation.md): (2 overloads) 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.
- [Slerp](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/slerp.md): (static) Interpolates between two quaternions, using spherical linear interpolation.
- [ToString](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/tostring.md): Returns a string representation of this Quaternion.
- [Unitize](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/unitize.md): Scales the quaternion's coordinates so that a*a + b*b + c*c + d*d = 1.

## Operators

- [operator +](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/op-addition.md): (static) Adds two quaternions. This sums each quaternion coefficient with its correspondent and returns a new result quaternion.
- [operator /](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/op-division.md): (static) Divides all quaternion coefficients by a factor and returns a new quaternion with the result.
- [operator ==](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/op-equality.md): (static) Determines whether two quaternions have the same value.
- [operator !=](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/op-inequality.md): (static) Determines whether two quaternions have different values.
- [operator *](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/op-multiply.md): (4 overloads, static) Multiplies a quaternion with another one. Quaternion multiplication (Hamilton product) is not commutative.
- [operator -](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.quaternion/op-subtraction.md): (static) Subtracts a quaternion from another one. This computes the difference of each quaternion coefficient with its correspondent and returns a new result quaternion.
