Quaternion Quaternion Quaternion Quaternion Struct

Definition

Structure that represents a rotation in three dimensions.

public value class Quaternion : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.Media.Media3D.QuaternionConverter))]
[System.Serializable]
public struct Quaternion : IFormattable
type Quaternion = struct
    interface IFormattable
Public Structure Quaternion
Implements IFormattable
Inheritance
QuaternionQuaternionQuaternionQuaternion
Attributes
Implements

Examples

<!-- 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;
'Read new settings
Try
    Dim WValue As Double = Convert.ToDouble(QuaternionWText.Text)
    Dim XValue As Double = Convert.ToDouble(QuaternionXText.Text)
    Dim YValue As Double = Convert.ToDouble(QuaternionYText.Text)
    Dim ZValue As Double = Convert.ToDouble(QuaternionZText.Text)

    endQuaternion = New Quaternion(XValue, YValue, ZValue, WValue)
Catch
    MessageBox.Show("Set non-null values for the quaternion.")
End Try

myQuaternionRotation3D = New QuaternionRotation3D(endQuaternion)
myRotateTransform3D.Rotation = myQuaternionRotation3D

'update matrix display
qrotationMatrix3D = myRotateTransform3D.Value

Remarks

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.

XAML Attribute Usage

<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.

Constructors

Quaternion(Vector3D, Double) Quaternion(Vector3D, Double) Quaternion(Vector3D, Double) Quaternion(Vector3D, Double)

Initializes a new instance of the Quaternion structure.

Quaternion(Double, Double, Double, Double) Quaternion(Double, Double, Double, Double) Quaternion(Double, Double, Double, Double) Quaternion(Double, Double, Double, Double)

Initializes a new instance of the Quaternion structure.

Properties

Angle Angle Angle Angle

Gets the quaternion's angle, in degrees.

Axis Axis Axis Axis

Gets the quaternion's axis.

Identity Identity Identity Identity

Gets the Identity quaternion.

IsIdentity IsIdentity IsIdentity IsIdentity

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

IsNormalized IsNormalized IsNormalized IsNormalized

Gets a value that indicates whether the quaternion is normalized.

W W W W

Gets the W component of the quaternion.

X X X X

Gets the X component of the quaternion.

Y Y Y Y

Gets the Y component of the quaternion.

Z Z Z Z

Gets the Z component of the quaternion.

Methods

Add(Quaternion, Quaternion) Add(Quaternion, Quaternion) Add(Quaternion, Quaternion) Add(Quaternion, Quaternion)

Adds the specified quaternions.

Conjugate() Conjugate() Conjugate() Conjugate()

Replaces a quaternion with its conjugate.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Compares two Quaternion instances for equality.

Equals(Quaternion) Equals(Quaternion) Equals(Quaternion) Equals(Quaternion)

Compares two Quaternion instances for equality.

Equals(Quaternion, Quaternion) Equals(Quaternion, Quaternion) Equals(Quaternion, Quaternion) Equals(Quaternion, Quaternion)

Compares two Quaternion instances for equality.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Returns the hash code for the Quaternion.

Invert() Invert() Invert() Invert()

Replaces the specified quaternion with its inverse.

Multiply(Quaternion, Quaternion) Multiply(Quaternion, Quaternion) Multiply(Quaternion, Quaternion) Multiply(Quaternion, Quaternion)

Multiplies the specified Quaternion values.

Normalize() Normalize() Normalize() Normalize()

Returns a normalized quaternion.

Parse(String) Parse(String) Parse(String) Parse(String)

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

Slerp(Quaternion, Quaternion, Double) Slerp(Quaternion, Quaternion, Double) Slerp(Quaternion, Quaternion, Double) Slerp(Quaternion, Quaternion, Double)

Interpolates between two orientations using spherical linear interpolation.

Slerp(Quaternion, Quaternion, Double, Boolean) Slerp(Quaternion, Quaternion, Double, Boolean) Slerp(Quaternion, Quaternion, Double, Boolean) Slerp(Quaternion, Quaternion, Double, Boolean)

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

Subtract(Quaternion, Quaternion) Subtract(Quaternion, Quaternion) Subtract(Quaternion, Quaternion) Subtract(Quaternion, Quaternion)

Subtracts a Quaternion from another.

ToString() ToString() ToString() ToString()

Creates a string representation of the object.

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

Creates a string representation of the object.

Operators

Addition(Quaternion, Quaternion) Addition(Quaternion, Quaternion) Addition(Quaternion, Quaternion) Addition(Quaternion, Quaternion)

Adds the specified Quaternion values.

Equality(Quaternion, Quaternion) Equality(Quaternion, Quaternion) Equality(Quaternion, Quaternion) Equality(Quaternion, Quaternion)

Compares two Quaternion instances for exact equality.

Inequality(Quaternion, Quaternion) Inequality(Quaternion, Quaternion) Inequality(Quaternion, Quaternion) Inequality(Quaternion, Quaternion)

Compares two Quaternion instances for exact inequality.

Multiply(Quaternion, Quaternion) Multiply(Quaternion, Quaternion) Multiply(Quaternion, Quaternion) Multiply(Quaternion, Quaternion)

Multiplies the specified quaternion by another.

Subtraction(Quaternion, Quaternion) Subtraction(Quaternion, Quaternion) Subtraction(Quaternion, Quaternion) Subtraction(Quaternion, Quaternion)

Subtracts a specified quaternion from another.

Explicit Interface Implementations

IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.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(String, IFormatProvider).

Applies to