Export (0) Print
Expand All

Quaternion Structure

Structure that represents a rotation in three dimensions.

Namespace:  System.Windows.Media.Media3D
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

[SerializableAttribute]
[TypeConverterAttribute(typeof(QuaternionConverter))]
public struct Quaternion : IFormattable
<Quaternion .../>
<object property="x,y,z,w"/>
-or-
<object property="x y z w"/>

XAML Values

x

The X component of this Quaternion structure.

y

The Y component of this Quaternion structure.

z

The Z component of this Quaternion structure.

w

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.

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.

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

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

      </Storyboard>
    </BeginStoryboard>
  </EventTrigger>
</Viewport3D.Triggers>
//Read new settings 
try
{
    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);
}
catch
{
    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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

ADD
Show:
© 2014 Microsoft