当前位置:网站首页>Detailed quaternion
Detailed quaternion
2022-06-23 23:10:00 【Hellfire Citadel 】
Quaternion Visualization
Understand the complex number dimension by dimension
One dimensional villains understand the plural
Little people can only understand operations in the range of real numbers , Just to i Take the square of itself as -1 Special symbols of .
Geometrically , Multiplication in the plural range , Consider the former complex number as a function acting on the second complex number

Fixed origin , take (1,0) This point is pulled to z Point location , After transformation w The point is the product result , There is only one transformation in two-dimensional space that can get this result
This process involves stretching and rotation , Stretching is very easy to understand , Because the one-dimensional number axis can also be . What about rotation ? Isn't this the concept of a two-dimensional plane ? All rotations correspond to a unique degree of rotation , We can project it onto a one-dimensional number axis
Imagine a point moving on a unit circle , This point is similar to (-1,0) The connecting line of and the complex axis intersect , One dimensional villain observes the complex axis


This point will first reach the infinite distance above , In the infinite distance from below
The two-dimensional man understands the three-dimensional rotation
Introduce a new unit j, A unit of distance from a complex plane , When we do not regard it as Z Axis , Instead, real numbers are treated as Z The axes allow us to better understand quaternions .
It is worth mentioning that , There is no good multiplication rule for such a definition , for example i*j and j*i Result
alike , We define a point on the unit sphere , And it and (-1,0) The intersection point of the line of on the plane

We rotate the unit ball , At the same time, how does the projection on the plane change 

Understand quaternions
Quaternions contain three imaginary dimensions , They are all perpendicular to the real number axis , And they are perpendicular to each other

The corresponding mathematical property is

alike , Quaternion multiplication corresponds to the corresponding transformation


This sphere represents that all real parts are 0 Unit quaternion of
The yellow and red lines represent two concentric lines with the same radius 、 Circles that are perpendicular to each other and do not intersect ( In four dimensions , It's very common )
The formula in the lower left corner is derived from the right-hand rotation theorem

multiply i Projection transformation of


More common cases , Multiply the left by a quaternion -0.5+0.5i+0.5j+0.5k
Rotate the first circle ( yellow ), Give Way 1 Came to q The location of
Then rotate the vertical circle by the same angle according to the right-hand rule ( white )

Three dimensional rotation
The easiest way to think of is that an object defines circles in three directions to control the direction , But then there will be “ Omnidirectional lock ” The problem of , That is to lose a degree of freedom

Two dimensional rotation :
Let's first consider how to rotate in the two-dimensional plane , Let's say we're going to (4,1) This point rotates counterclockwise 30°, How to express by vector operation ?

We extend to three-dimensional rotation , We define a unit vector in the direction of the axis of rotation
Multiply the sine of the same rotation angle by the imaginary part , But this imaginary part has three parts —— Used to determine the rotation unit vector

This is rotation in a given direction 40°,** But in fact we use half angle !!! ** Why? ?
We want to know the position of a point after this transformation , What we need to do is not to multiply these two quaternions directly , Instead, a special “ Sandwich ” form

A quaternion multiplication visual website , It's also 3Blue1Brown The teacher made it himself (eater.net)—— Need to climb over the wall
There is a super cool function in it , That is, you can directly operate the visual case in his demonstration video. Through this, you can better understand why you need to right multiply an inverse matrix
Why right multiply
First, perform the normal rotation operation , Along i Direction of rotation


Then we do not right multiply an inverse matrix

You can see clearly , The four-dimensional hypersphere has an obvious displacement on the axis of rotation ——j(i) spot , This yellow green line is its projection in three-dimensional space
Want to eliminate this **“ side effect ”** You have to right multiply the inverse matrix
Why half angle
We can see clearly from the video website , Left multiplication not only rotates the 3D points , Migration and deformation are also carried out

i ∗ j = − ( j ∗ i ) i * j = - ( j * i) i∗j=−(j∗i)
Left and right multiplication rotate in opposite directions , There is a minus sign for reverse
i ∗ j = j ∗ ( − i ) i * j = j * (-i) i∗j=j∗(−i)
That is, left multiply i And multiply right i The inverse matrix of is the same , The two directions of rotation are consistent ; But offset and deformation are the opposite , So only half angle

Unity The use of
Unity 3D in Rotation
stay Unity in , Rotation can usually be a three-dimensional vector (x,y,z) Express . Actually this is Euler's angle . The three components are respectively around x Axis 、y Axis and z The rotation Angle of the axis .
To one GameObject Rotate , You can use the following code directly :
transform.Rotate(xAngle, yAngle, zAngle);
Editor in Transform The rotation axis of the component is the model space coordinate axis of the parent node , If there is no parent node , Then the rotation axis is the world coordinate axis .
stay Script Use in Rotate function , stay Space.Self Middle rotation
public void Rotate(Vector3 eulerAngles, Space relativeTo = Space.Self);
public void Rotate(float xAngle, float yAngle, float zAngle, Space relativeTo = Space.Self);
public void Rotate(Vector3 axis, float angle, Space relativeTo = Space.Self);
stay Space.Self Rotate in , The rotation axis is the coordinate axis of the local coordinate system .
stay Space.World Rotate in , The axis of rotation is the axis of the world coordinate system .
Different rotation order will lead to different results , As you can see from the documentation , Its transform.Rotate() It uses Z-X-Y Compliance
gimbal lock
The real problem with the universal joint lock is the interpolation animation , The object will rotate along an arc , This is because the lack of a degree of freedom must be adjusted in this way
transform.eulerAngles = Vector3.Lerp(transform.eulerAngles, new Vector3(150, 90, 90), 0.5f);
Rotate with quaternions
Unity Quaternions in support of and Vector3 Multiply , If you take this Vector3 Think of it as a vector , that Multiply the left by a quaternion , It's equivalent to rotating this vector .
transform.rotation = Quaternion.FromToRotation(transform.up, toDirection) * transform.rotation;
The first parameter is what to rotate , The second parameter is the direction to be rotated. The three-dimensional coordinates here all represent a vector
The above code , Change it to quaternion
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(new Vector3(150,90,90)), dTime);
边栏推荐
- Bilibili×蓝桥云课|线上编程实战赛全新上新!
- How to build a website after registering a domain name
- MySQL highly available version 1c1g exclusive cloud database value-added special offers!
- Go language core 36 lectures (go language practice and application 25) -- learning notes
- 百万消息量IM系统技术要点分享
- 混沌工程,了解一下
- How PostgreSQL creates partition tables
- How to use FTP to upload websites to the web
- Section 30 high availability (HA) configuration case of Tianrongxin topgate firewall
- 【观察】戴尔科技+英特尔傲腾技术:以“纳秒之速”领跑存储创新
猜你喜欢

巨头下场“摆摊”,大排档陷入“苦战”

What is an immunohistochemical experiment? Immunohistochemical experiment

Face and lining of fresh food pre storage

蚂蚁集团自研TEE技术通过国家级金融科技产品认证

Data interpretation! Ideal L9 sprints to "sell more than 10000 yuan a month" to grab share from BBA

Summary of some indicators for evaluating and selecting the best learning model

国家邮政局等三部门:加强涉邮政快递个人信息安全治理,推行隐私面单、虚拟号码等个人信息去标识化技术
How PostgreSQL creates partition tables

专业“搬砖”老司机总结的 12 条 SQL 优化方案,非常实用!

Giants end up "setting up stalls" and big stalls fall into "bitter battle"
随机推荐
How to set the border of layers in website construction? What is the role of border design
C#/VB. Net word to text
Map集合的四种遍历
Heat transfer oil electric heater
API gateway monitoring function the importance of API gateway
FANUC机器人SRVO-050碰撞检测报警原因分析及处理对策(亲测可用)
Detailed explanation of MySQL database configuration information viewing and modification methods
[JS reverse hundred examples] the first question of the anti crawling practice platform for netizens: JS confusion encryption and anti hook operation
The latest February activity # 1 core 2G first year: 38 yuan / year! 2-core 4G light weight RMB 74 / year! Mysql database 19.9 yuan / year!!
Industry 4.0 era: the rise of low code may bring about changes in the pattern of manufacturing industry
Problem solving: inittramfs unpacking failed:decoding failed
SQL Server Common SQL
新股民怎样炒股票开户?在线开户安全么?
Website construction column setting form which website construction company is better
反序列化——php反序列化
Troubleshooting of undefined problems in the channel list of easynvr channel management
TDD开发模式流程推荐
How to set the website construction title bar drop-down
巨头下场“摆摊”,大排档陷入“苦战”
Understand the data consistency between MySQL and redis