Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Quaternion Structure


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Structure that represents a rotation in three dimensions.

Namespace:   System.Windows.Media.Media3D
Assembly:  PresentationCore (in PresentationCore.dll)

public struct Quaternion : IFormattable

System_CAPS_pubmethodQuaternion(Double, Double, Double, Double)

Initializes a new instance of the Quaternion structure.

System_CAPS_pubmethodQuaternion(Vector3D, Double)

Initializes a new instance of the Quaternion structure.


Gets the quaternion's angle, in degrees.


Gets the quaternion's axis.


Gets the Identity quaternion


Gets a value that indicates whether the specified quaternion is an Identity quaternion.


Gets a value that indicates whether the quaternion is normalized.


Gets the W component of the quaternion.


Gets the X component of the quaternion.


Gets the Y component of the quaternion.


Gets the Z component of the quaternion.

System_CAPS_pubmethodSystem_CAPS_staticAdd(Quaternion, Quaternion)

Adds the specified quaternions.


Replaces a quaternion with its conjugate.


Compares two Quaternion instances for equality. (Overrides ValueType.Equals(Object).)


Compares two Quaternion instances for equality.

System_CAPS_pubmethodSystem_CAPS_staticEquals(Quaternion, Quaternion)

Compares two Quaternion instances for equality.


Returns the hash code for the Quaternion. (Overrides ValueType.GetHashCode().)


Gets the Type of the current instance.(Inherited from Object.)


Replaces the specified quaternion with its inverse

System_CAPS_pubmethodSystem_CAPS_staticMultiply(Quaternion, Quaternion)

Multiplies the specified Quaternion values.


Returns a normalized quaternion.


Converts a string representation of a Quaternion into the equivalent Quaternion structure.

System_CAPS_pubmethodSystem_CAPS_staticSlerp(Quaternion, Quaternion, Double)

Interpolates between two orientations using spherical linear interpolation.

System_CAPS_pubmethodSystem_CAPS_staticSlerp(Quaternion, Quaternion, Double, Boolean)

Interpolates between orientations, represented as Quaternion structures, using spherical linear interpolation.

System_CAPS_pubmethodSystem_CAPS_staticSubtract(Quaternion, Quaternion)

Subtracts a Quaternion from another.


Creates a string representation of the object. (Overrides ValueType.ToString().)


Creates a string representation of the object.

System_CAPS_puboperatorSystem_CAPS_staticAddition(Quaternion, Quaternion)

Adds the specified Quaternion values.

System_CAPS_puboperatorSystem_CAPS_staticEquality(Quaternion, Quaternion)

Compares two Quaternion instances for exact equality.

System_CAPS_puboperatorSystem_CAPS_staticInequality(Quaternion, Quaternion)

Compares two Quaternion instances for exact inequality.

System_CAPS_puboperatorSystem_CAPS_staticMultiply(Quaternion, Quaternion)

Multiplies the specified quaternion by another.

System_CAPS_puboperatorSystem_CAPS_staticSubtraction(Quaternion, Quaternion)

Subtracts a specified quaternion from another.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIFormattable.ToString(String, IFormatProvider)

This member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see ToString.

Quaternions allow you to interpolate between rotation transformations applied to an object, thereby making it easier to compute smooth animations of rotations. A quaternion represents an axis of rotation and a rotation around that axis. It's possible to individually define the axis and angle of rotation of the starting and ending positions of a rotated object ,but the intermediate positions of that object during an animation are computationally uncertain. By determining a quaternion that represents the original orientation of a 3-D object and one that represents its destination orientation, you can smoothly interpolate between those orientations.

In XAML, the delimiter between the values of a Quaternion can be either a comma or a space.

Some cultures might use the comma character as the decimal delimiter instead of the period character. XAML processing for invariant culture defaults to en-US in most XAML processor implementations, and expects the period to be the decimal delimiter. You should avoid using the comma character as the decimal delimiter if specifying a Quaternion in XAML, because that will clash with the string type conversion of a Quaternion attribute value into its components.

<object property="x,y,z,w"/>
<object property="x y z w"/>


The X component of this Quaternion structure.


The Y component of this Quaternion structure.


The Z component of this Quaternion structure.


The W component of this Quaternion structure.

<!-- Trigger the rotation animation when the 3D object loads. -->
  <EventTrigger RoutedEvent="Viewport3D.Loaded">

        <!-- This animation animates the Rotation property of the RotateTransform3D
             causing the 3D shape to rotate. -->
         Storyboard.TargetProperty="Quaternion" From="0,0,1,0" To="0.3, 0.3, 1, 0" 
         Duration="0:0:2" />

//Read new settings
    Double WValue = System.Convert.ToDouble(QuaternionWText.Text);
    Double XValue = System.Convert.ToDouble(QuaternionXText.Text);
    Double YValue = System.Convert.ToDouble(QuaternionYText.Text);
    Double ZValue = System.Convert.ToDouble(QuaternionZText.Text);

    endQuaternion = new Quaternion(XValue, YValue, ZValue, WValue);
    MessageBox.Show("Set non-null values for the quaternion.");

myQuaternionRotation3D = new QuaternionRotation3D(endQuaternion);
myRotateTransform3D.Rotation = myQuaternionRotation3D;

//update matrix display
qrotationMatrix3D = myRotateTransform3D.Value;

.NET Framework
Available since 3.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2017 Microsoft