QUATERNION VÀ PHÉP QUAY KHÔNG GIAN, TẠI SAO QUATERNION ĐƯỢC SỬ DỤNG CHO CÁC PHÉP QUAY

Namespace: System.Numerics Assemblies:System.Numerics.dll, System.Numerics.Vectors.dll
Assembly:System.Numerics.Vectors.dll
Assembly:System.Numerics.dll
Assembly:netstandard.dll

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to lớn the information provided here.

Bạn đang xem: Quaternion và phép quay không gian


public value class Quaternion : IEquatablepublic struct Quaternion : IEquatabletype Quaternion = struct
Public Structure Quaternion
Implements IEquatable(Of Quaternion)Inheritance

Remarks

The Quaternion structure is used lớn efficiently rotate an object about the (x,y,z) vector by the angle theta, where:

w = cos(theta/2)

Constructors

Quaternion(Single, Single, Single, Single) Constructs a quaternion from the specified components.

Quaternion(Vector3, Single)

Creates a quaternion from the specified vector & rotation parts.

Fields

W

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.

Properties

Identity

Gets a quaternion that represents no rotation.

Is
Identity

Gets a value that indicates whether the current instance is the identity quaternion.

Item

Gets or sets the element at the specified index.

Zero

Gets a quaternion that represents a zero.

Methods

Add(Quaternion, Quaternion)

Adds each element in one quaternion with its corresponding element in a second quaternion.

Concatenate(Quaternion, Quaternion)

Concatenates two quaternions.

Conjugate(Quaternion)

Returns the conjugate of a specified quaternion.

Create
From
Axis
Angle(Vector3, Single)

Creates a quaternion from a unit vector và an angle khổng lồ rotate around the vector.

Create
From
Rotation
Matrix(Matrix4x4)

Creates a quaternion from the specified rotation matrix.

Create
From
Yaw
Pitch
Roll(Single, Single, Single)

Creates a new quaternion from the given yaw, pitch, & roll.

Divide(Quaternion, Quaternion)

Divides one quaternion by a second quaternion.

Dot(Quaternion, Quaternion)

Calculates the dot hàng hóa of two quaternions.

Equals(Object)

Returns a value that indicates whether this instance và a specified object are equal.

Equals(Quaternion)

Returns a value that indicates whether this instance và another quaternion are equal.

Get
Hash
Code()

Returns the hash code for this instance.

Inverse(Quaternion)

Returns the inverse of a quaternion.

Xem thêm: Hiđro Hoá Hoàn Toàn Hỗn Hợp M Gồm Hai Anđehit X Và Y No, Đơn Chức

Length()

Calculates the length of the quaternion.

Length
Squared()

Calculates the squared length of the quaternion.

Lerp(Quaternion, Quaternion, Single)

Performs a linear interpolation between two quaternions based on a value that specifies the weighting of the second quaternion.

Multiply(Quaternion, Quaternion)

Returns the quaternion that results from multiplying two quaternions together.

Multiply(Quaternion, Single)

Returns the quaternion that results from scaling all the components of a specified quaternion by a scalar factor.

Negate(Quaternion)

Reverses the sign of each component of the quaternion.

Normalize(Quaternion)

Divides each component of a specified Quaternion by its length.

Slerp(Quaternion, Quaternion, Single)

Interpolates between two quaternions, using spherical linear interpolation.

Subtract(Quaternion, Quaternion)

Subtracts each element in a second quaternion from its corresponding element in a first quaternion.

To
String()

Returns a string that represents this quaternion.

Operators

Addition(Quaternion, Quaternion)

Adds each element in one quaternion with its corresponding element in a second quaternion.

Division(Quaternion, Quaternion)

Divides one quaternion by a second quaternion.

Equality(Quaternion, Quaternion)

Returns a value that indicates whether two quaternions are equal.

Inequality(Quaternion, Quaternion)

Returns a value that indicates whether two quaternions are not equal.

Multiply(Quaternion, Quaternion)

Returns the quaternion that results from multiplying two quaternions together.

Multiply(Quaternion, Single)

Returns the quaternion that results from scaling all the components of a specified quaternion by a scalar factor.

Subtraction(Quaternion, Quaternion)

Subtracts each element in a second quaternion from its corresponding element in a first quaternion.

Unary
Negation(Quaternion)

Reverses the sign of each component of the quaternion.

Quarternion được sử dụng trong phép quay không gian. Trong phần 1 này, tôi đã nói về phong thái sử dụng sơ lược của chính nó trong phép quay ko gian.

Các bài viết khác vào loạt bài xích về quaternion:

Quaternion được định nghĩa như là một vài phức có cha thành phần ảo:

*

Đừng nghĩ đến quaternion là 1 trong những cái nào đấy bốn chiều, đầu bạn sẽ nổ tung. Các thành phần ảo

*
rất có thể được coi như tía vector đơn vị chức năng của trục tọa độ x, y, z. Với một quaternion hoàn toàn có thể được viết lại như sau:

*

Với

*
là 1 trong vector trong không khí 3 chiều, và
*
là một trong đại lượng vô hướng chỉ độ lớn (nói chung là một trong những con số). Dễ tưởng tượng rộng rồi đúng không!

Áp dụng vào phép quay không khí của bọn chúng ta. Mang sử các bạn có một vector trục con quay

*
(vector 
*
cần là vector solo vị, tức
*
) và góc con quay
*
(dương lúc quay thuộc chiều với vector, theo hiệ tượng nắm tay phải) thì bọn họ sẽ tất cả một quaternion con quay như sau:

*

Ví dụ, bạn có nhu cầu tạo một phép tảo một góc 120 độ (tức 2/3 pi radian) xoay trục

*
. Đầu tiên họ sẽ chuẩn chỉnh hóa (normalize) vector
*
thành vector đơn vị chức năng
*
.

*

Và từ bỏ đó, chúng ta có quaternion có thể chấp nhận được quay là:

*

Để triển khai phép quay, bạn cần một cái nào đó để quay. Lấy một ví dụ tôi có một điểm

*
trong không khí có tọa độ
*
được xác minh trong không gian bởi vector
*
thì phép quay điểm
*
theo
*
được tư tưởng là:

*

Trong đó

*
là vector tọa độ của điểm
*
sau khoản thời gian xoay. Và
*
là nghịch hòn đảo của
*
. Ví dụ trong trường đúng theo này:

*

Trong trường đúng theo này, nghịch hòn đảo bằng lượng phối hợp do trị tuyệt vời nhất của quaternion vào phép quay bằng 1. Nếu như bạn thắc mắc vì sao có công thức chuyển đổi quarternion, xin coi phần sau.

Sau đó, bọn họ sẽ áp dụng phép nhân quartenion. Hãy ghi lưu giữ phép nhân quaternion không có tính giao hoán. Bạn có thể nghiên cứu giúp thêm về phép nhân quaternion trên đây. Trong blog này tôi chỉ nhắc tới hiệu quả của phép nhân. Cho 2 quaternion

*
với
*
thì tích
*
là:

*

Sử dụng cách làm trên để dán vào ví dụ của họ (biến đổi

*
theo
*
) và lấy lệ nhân rất điên loạn (tôi khuyên chúng ta nên dùng đồ vật vi tính), chúng ta sẽ ra được:

*


*

Hinh mặt mô tả phép quay lấy ví dụ như của chúng ta. Bạn cũng có thể thấy nếu bọn họ quay xung quanh trục

*
một góc 120 độ thì tọa độ
*
đang tráo lẫn nhau thành
*
. Phù hợp với công dụng của phép nhân sinh sống trên.

Vừa rồi tôi vừa mới ra mắt sơ lược về kiểu cách sử dụng quaternion trong phép quay. Vào phần sau, tôi sẽ nói đi sâu về phần toán, bài toán tối ưu hóa nó trong xây dựng và đối chiếu với những phép thay đổi khác.

Leave a Reply

Your email address will not be published. Required fields are marked *

x