Quaternion Quaternion Quaternion Quaternion Struct

定義

以三維表示旋轉的結構。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
繼承
QuaternionQuaternionQuaternionQuaternion
屬性
實作

範例

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

備註

四元數可讓您在套用至物件的旋轉轉換之間插補, 以便更輕鬆地計算旋轉的平滑動畫。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.

在 XAML 中, 的值Quaternion之間的分隔符號可以是逗號或空格。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 處理在大部分的 XAML 處理器執行中預設為 en-us, 而且預期句點必須是小數分隔符號。XAML processing for invariant culture defaults to en-US in most XAML processor implementations, and expects the period to be the decimal delimiter. 如果Quaternion在 XAML 中指定, 您應該避免使用逗號字元做為小數分隔符號, 因為這會與Quaternion屬性值在其元件中的字串類型轉換衝突。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 UsageXAML Attribute Usage

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

XAML 值XAML Values

xx
這個 X 結構的 Quaternion 元件。The X component of this Quaternion structure.

yy
這個 Y 結構的 Quaternion 元件。The Y component of this Quaternion structure.

zz
這個 Z 結構的 Quaternion 元件。The Z component of this Quaternion structure.

ww
這個 W 結構的 Quaternion 元件。The W component of this Quaternion structure.

建構函式

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

初始化 Quaternion 結構的新執行個體。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)

初始化 Quaternion 結構的新執行個體。Initializes a new instance of the Quaternion structure.

屬性

Angle Angle Angle Angle

取得四元數的角度,以度數為單位。Gets the quaternion's angle, in degrees.

Axis Axis Axis Axis

取得四元數的軸。Gets the quaternion's axis.

Identity Identity Identity Identity

取得 Identity 四元數。Gets the Identity quaternion

IsIdentity IsIdentity IsIdentity IsIdentity

取得值,這個值表示指定的四元數是否為 Identity 四元數。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

取得四元數的 W 元件。Gets the W component of the quaternion.

X X X X

取得四元數的 X 元件。Gets the X component of the quaternion.

Y Y Y Y

取得四元數的 Y 元件。Gets the Y component of the quaternion.

Z Z Z Z

取得四元數的 Z 元件。Gets the Z component of the quaternion.

方法

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)

比較兩個 Quaternion 執行個體是否相等。Compares two Quaternion instances for equality.

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

比較兩個 Quaternion 執行個體是否相等。Compares two Quaternion instances for equality.

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

比較兩個 Quaternion 執行個體是否相等。Compares two Quaternion instances for equality.

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

傳回 Quaternion 的雜湊程式碼。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)

乘以指定的 Quaternion 值。Multiplies the specified Quaternion values.

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

傳回標準化的四元數。Returns a normalized quaternion.

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

Quaternion 的字串表示轉換成對等的 Quaternion 結構。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)

使用球面線性插補,在表示為 Quaternion 的方向間進行插補。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.

運算子

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

加入指定的 Quaternion 值。Adds the specified Quaternion values.

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

比較兩個 Quaternion 執行個體是否完全相等。Compares two Quaternion instances for exact equality.

Inequality(Quaternion, Quaternion) Inequality(Quaternion, Quaternion) Inequality(Quaternion, Quaternion) Inequality(Quaternion, 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.

明確介面實作

IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider)

這個成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,但是您不可以從程式碼直接使用它。This member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明,請參閱 ToString(String, IFormatProvider)For a description of this member, see ToString(String, IFormatProvider).

適用於