# Quaternion 结构

## 定义

``public value class Quaternion : IEquatable<System::Numerics::Quaternion>``
``public struct Quaternion : IEquatable<System.Numerics.Quaternion>``
``type Quaternion = struct``
``````Public Structure Quaternion
Implements IEquatable(Of Quaternion)``````

Quaternion

## 注解

Quaternion 结构用于有效地使用 angle （x，y，z）向量旋转对象，其中：The Quaternion structure is used to efficiently rotate an object about the (x,y,z) vector by the angle theta, where:

``````w = cos(theta/2)
``````

## 构造函数

 从指定分量构造四元数。Constructs a quaternion from the specified components. 从指定向量和旋转部分创建四元数。Creates a quaternion from the specified vector and rotation parts.

## 字段

 四元数的旋转分量。The rotation component of the quaternion. 四元数向量分量的 X 值。The X value of the vector component of the quaternion. 四元数向量分量的 Y 值。The Y value of the vector component of the quaternion. 四元数向量分量的 Z 值。The Z value of the vector component of the quaternion.

## 属性

 获取一个表示无旋转的四元数。Gets a quaternion that represents no rotation. 获取一个指示当前实例是否为 Identity 四元数的值。Gets a value that indicates whether the current instance is the identity quaternion.

## 方法

 将一个四元数中的每个元素与第二个四元数中的对应元素相加。Adds each element in one quaternion with its corresponding element in a second quaternion. 连接两个四元数。Concatenates two quaternions. 返回指定四元数的共轭。Returns the conjugate of a specified quaternion. 从一个单位向量以及围绕该向量旋转的角度创建四元数。Creates a quaternion from a unit vector and an angle to rotate around the vector. 从指定旋转矩阵创建四元数。Creates a quaternion from the specified rotation matrix. 从给定的绕 Y 轴旋转、绕 X 轴旋转和绕 Z 轴旋转创建新四元数。Creates a new quaternion from the given yaw, pitch, and roll. 将一个四元数除以第二个四元数。Divides one quaternion by a second quaternion. 计算两个四元数的点积。Calculates the dot product of two quaternions. 返回一个值，该值指示此实例是否与指定对象相等。Returns a value that indicates whether this instance and a specified object are equal. 返回一个值，该值指示此实例是否与另一个四元数相等。Returns a value that indicates whether this instance and another quaternion are equal. 返回此实例的哈希代码。Returns the hash code for this instance. 返回四元数的逆。Returns the inverse of a quaternion. 计算四元数的长度。Calculates the length of the quaternion. 计算四元数的长度平方值。Calculates the squared length of the quaternion. 基于指定第二个四元数的权重的值在两个四元数之间执行线性内插。Performs a linear interpolation between two quaternions based on a value that specifies the weighting of the second quaternion. 返回将两个四元数相乘得到的四元数。Returns the quaternion that results from multiplying two quaternions together. 返回按标量系数缩放指定四元数的所有分量后得到的四元数。Returns the quaternion that results from scaling all the components of a specified quaternion by a scalar factor. 反转四元数的每个分量的符号。Reverses the sign of each component of the quaternion. 将指定 Quaternion 的每个分量除以其长度。Divides each component of a specified Quaternion by its length. 使用球状线性内插，在两个四元数之间进行内插。Interpolates between two quaternions, using spherical linear interpolation. 从第一个四元数中的每个元素中减去第二个四元数中的对应元素。Subtracts each element in a second quaternion from its corresponding element in a first quaternion. 返回表示此四元数的字符串。Returns a string that represents this quaternion.

## 运算符

 将一个四元数中的每个元素与第二个四元数中的对应元素相加。Adds each element in one quaternion with its corresponding element in a second quaternion. 将一个四元数除以第二个四元数。Divides one quaternion by a second quaternion. 返回一个值，该值指示两个四元数是否相等。Returns a value that indicates whether two quaternions are equal. 返回一个值，该值指示两个四元数是否不相等。Returns a value that indicates whether two quaternions are not equal. 返回将两个四元数相乘得到的四元数。Returns the quaternion that results from multiplying two quaternions together. 返回按标量系数缩放指定四元数的所有分量后得到的四元数。Returns the quaternion that results from scaling all the components of a specified quaternion by a scalar factor. 从第一个四元数中的每个元素中减去第二个四元数中的对应元素。Subtracts each element in a second quaternion from its corresponding element in a first quaternion. 反转四元数的每个分量的符号。Reverses the sign of each component of the quaternion.