This documentation is archived and is not being maintained.

Quaternion Structure

Structure that represents a rotation in three dimensions.

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

public struct Quaternion : IFormattable
/** @attribute SerializableAttribute() */ 
/** @attribute TypeConverterAttribute(System.Windows.Media.Media3D.QuaternionConverter) */ 
public final class Quaternion extends ValueType implements IFormattable
<Quaternion .../>
<object property="x,y,z,w"/>
 x   System.Double  The X component of this Quaternion structure.  y   System.Double  The Y component of this Quaternion structure.  z   System.Double  The Z component of this Quaternion structure.  w   System.Double  The W component of this Quaternion structure. 

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.

<!-- 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;

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0