当前位置:网站首页>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);
边栏推荐
- FANUC机器人SRVO-050碰撞检测报警原因分析及处理对策(亲测可用)
- Tencent lightweight + pagoda building document online preview project kkfileview
- 专业“搬砖”老司机总结的 12 条 SQL 优化方案,非常实用!
- Get and post are nothing more than TCP links in nature?
- Application of clock synchronization system in banking system
- Notes to nodejs (II)
- Ambire 指南:Arbitrum 奥德赛活动开始!第一周——跨链桥
- 【观察】戴尔科技+英特尔傲腾技术:以“纳秒之速”领跑存储创新
- How to create a virtual server through a fortress machine? What are the functions of the fortress machine?
- Installation and use of qingscan scanner
猜你喜欢

CS5213 HDMI转VGA带音频信号输出方案

数据解读!理想L9冲刺「月销过万」,从BBA手中抢份额

Desai wisdom number - histogram (basic histogram): the way to celebrate father's day in 2022
Trigger definition and syntax introduction in MySQL

The 12 SQL optimization schemes summarized by professional "brick moving" old drivers are very practical!

蚂蚁获FinQA竞赛冠军,在长文本数值推理AI技术上取得突破

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

【观察】戴尔科技+英特尔傲腾技术:以“纳秒之速”领跑存储创新

解密抖音春节红包背后的技术设计与实践
云原生流水线工具汇总
随机推荐
Installation and use of qingscan scanner
Production of labels for table products
How to batch generate flattermark barcode
Is the website under construction because there is no FTP upload? Can I upload without FTP
Section 30 high availability (HA) configuration case of Tianrongxin topgate firewall
Start learning simple JS
Detailed usage of exists in SQL statements
Notes to nodejs (II)
How to set up links for website construction how to build a website
Three ways to enable IPv6 on Tencent cloud
How to use data warehouse to create time series
December 14, 2021: rebuild the queue according to height. Suppose there's a bunch of people out of order
AAAI 2022 | Tencent Youtu 14 papers were selected, including image coloring, face security, scene text recognition and other frontier fields
蚂蚁获FinQA竞赛冠军,在长文本数值推理AI技术上取得突破
How to connect the fortress machine to the new server? What can I do if there is a problem with the fortress machine?
Go deep: the evolution of garbage collection
Unknown character set index for field ‘255‘ received from server.
AIX系统月维护查什么(二)
MySQL highly available version 1c1g exclusive cloud database value-added special offers!
SQL Server Common SQL