如何使用 4d 转子 [英] How to use 4d rotors

查看:40
本文介绍了如何使用 4d 转子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个 4D 环境,类似于 Miegakure 的环境.

我无法理解如何表示旋转.Miegakure 的创建者写了这篇小文章,解释了他为 4d 转子制作的课程.http://marctenbosch.com/news/2011/05/4d-rotations-and-the-4d-equivalent-of-quaternions/

如何实现这个类的功能?特别是旋转矢量和其他转子的函数,并得到逆?

我会很感激一些伪代码示例.非常感谢任何麻烦回答的人.

解决方案

多亏了这个关于几何代数的 YouTube 系列:https://www.youtube.com/watch?v=PNlgMPzj-7Q&list=PLpzmRsG7vEsG7U8KFvtiJY4K>

它的解释非常好,我向想要使用几何代数的人推荐它.

如果你已经知道四元数乘法,那么转子乘法也不会有什么不同,四元数的 i、j、k 单位类似于几何代数的基双向量:e12、e13、e23(或 e01、e02, e12)

因此 4D 中的转子将是 (A + B*e12 + C*e13 + D*e14 + E*e23 + F*e24 + G*e34 + H*e1234).

可以在此页面上找到显示如何乘以这些单位的表格:http://www.euclideanspace.com/maths/algebra/克里福德/d4/arithmetic/index.htm

要了解其要点,请考虑 2D 转子.

它们的形式为:R = A + B*e12

现在,如果我们计算 2 个任意转子 R_1 和 R_2 之间的乘积,我们得到:

R_1*R_2 = (R_1.a * R_2.a+ R_1.a * R_2.b*e12+ R_1.b*e12 * R_2.a+ R_1.b*e12 * R_2.b*e12 )//但是:e12*e12 = e1e2e1e2 = -e1e2e2e1= -e1e1 = -1//这由我上面链接的计算规则证实=((R_1.a * R_1.a - R_2.b * R_2.b)+ (R_1.a * R_2.b + R_1.b * R_2.a) * e12 )

所以在代码中,你会做这样的事情:

R_3.a = R_1.a * R_2.a - R_1.b * R_2.bR_3.b = R_1.a * R_2.b + R_1.b * R_2.a

现在只需对那些大型 4D 转子执行相同操作,应用上文链接的第 4 维乘法规则即可.

这是结果代码(使用 e0、e1、e2、e3 作为基向量):

e: self.e*other.e - self.e01*other.e01 - self.e02*other.e02 - self.e03*other.e03 - self.e12*other.e12 - self.e13*other.e13 - self.e23*other.e23 + self.e0123*other.e0123,e01:self.e*other.e01 + self.e01*other.e - self.e02*other.e12 - self.e03*other.e13 + self.e12*other.e02 + self.e13*other.e03 -self.e23*other.e0123 - self.e0123*other.e23,e02: self.e*other.e02 + self.e01*other.e12 + self.e02*other.e - self.e03*other.e23 - self.e12*other.e01 + self.e13*other.e0123 +self.e23*other.e03 + self.e0123*other.e13,e03:self.e*other.e03 + self.e01*other.e13 + self.e02*other.e23 + self.e03*other.e - self.e12*other.e0123 - self.e13*other.e01 -self.e23*other.e02 - self.e0123*other.e12,e12:self.e*other.e12 - self.e01*other.e02 + self.e02*other.e01 - self.e03*other.e0123 + self.e12*other.e - self.e13*other.e23 +self.e23*other.e13 - self.e0123*other.e03,e13:self.e*other.e13 - self.e01*other.e03 + self.e02*other.e0123 + self.e03*other.e01 + self.e12*other.e23 + self.e13*other.e -self.e23*other.e12 + self.e0123*other.e02,e23:self.e*other.e23 - self.e01*other.e0123 - self.e02*other.e03 + self.e03*other.e02 - self.e12*other.e13 + self.e13*other.e12 +self.e23*other.e - self.e0123*other.e01,e0123:self.e*other.e0123 + self.e01*other.e23 - self.e02*other.e13 + self.e03*other.e12 + self.e12*other.e03 - self.e13*other.e02 +self.e23*other.e01 + self.e0123*other.e,

I'm trying to create a 4D environment, similar to Miegakure's.

I'm having trouble understanding how to represent rotations. The creator of Miegakure wrote this small article explaining he made a class for 4d rotors. http://marctenbosch.com/news/2011/05/4d-rotations-and-the-4d-equivalent-of-quaternions/

How can I implement the functions of this class ? In particular the functions to rotate vectors and other rotors, and getting the inverse ?

I would appreciate some pseudocode examples. Thanks a lot to anyone who bothers answering.

解决方案

I was able to use Rotors after learning more on the subject thanks to this youtube series about Geometric Algebra : https://www.youtube.com/watch?v=PNlgMPzj-7Q&list=PLpzmRsG7u_gqaTo_vEseQ7U8KFvtiJY4K

It's really well explained and I recommend it to whoever wants use geometric algebra.

If you already know about Quaternions multiplication, Rotor multiplication won't be any different, and the i, j, k units of quaternions are analog to the basis bivectors of Geometric Algebra : e12, e13, e23 (or e01, e02, e12)

So a Rotor in 4D will be (A + B*e12 + C*e13 + D*e14 + E*e23 + F*e24 + G*e34 + H*e1234).

A table showing how to multiply those units can be found on this page : http://www.euclideanspace.com/maths/algebra/clifford/d4/arithmetic/index.htm

To get the gist of it, consider the 2D Rotors.

They're of the form: R = A + B*e12

Now, if we compute product between 2 arbitrary rotors R_1 and R_2, we get:

R_1*R_2 = (
  R_1.a     * R_2.a
+ R_1.a     * R_2.b*e12
+ R_1.b*e12 * R_2.a
+ R_1.b*e12 * R_2.b*e12 )
// but: e12*e12 = e1e2e1e2 = -e1e2e2e1= -e1e1 = -1
// this is confirmed by the computation rules I linked above
=
( (R_1.a * R_1.a - R_2.b * R_2.b)
+ (R_1.a * R_2.b + R_1.b * R_2.a) * e12 )

So in code, you would do something like :

R_3.a = R_1.a * R_2.a - R_1.b * R_2.b
R_3.b = R_1.a * R_2.b + R_1.b * R_2.a

Now it's only a matter of doing the same with those big 4D rotors, applying the multiplication rules for dimension 4 as linked above.

Here is the resulting code (using e0, e1, e2, e3 as basis vectors):

e: self.e*other.e - self.e01*other.e01 - self.e02*other.e02 - self.e03*other.e03 - self.e12*other.e12 - self.e13*other.e13 - self.e23*other.e23 + self.e0123*other.e0123,
e01: self.e*other.e01 + self.e01*other.e - self.e02*other.e12 - self.e03*other.e13 + self.e12*other.e02 + self.e13*other.e03 - self.e23*other.e0123 - self.e0123*other.e23,
e02: self.e*other.e02 + self.e01*other.e12 + self.e02*other.e - self.e03*other.e23 - self.e12*other.e01 + self.e13*other.e0123 + self.e23*other.e03 + self.e0123*other.e13,
e03: self.e*other.e03 + self.e01*other.e13 + self.e02*other.e23 + self.e03*other.e - self.e12*other.e0123 - self.e13*other.e01 - self.e23*other.e02 - self.e0123*other.e12,
e12: self.e*other.e12 - self.e01*other.e02 + self.e02*other.e01 - self.e03*other.e0123 + self.e12*other.e - self.e13*other.e23 + self.e23*other.e13 - self.e0123*other.e03,
e13: self.e*other.e13 - self.e01*other.e03 + self.e02*other.e0123 + self.e03*other.e01 + self.e12*other.e23 + self.e13*other.e - self.e23*other.e12 + self.e0123*other.e02,
e23: self.e*other.e23 - self.e01*other.e0123 - self.e02*other.e03 + self.e03*other.e02 - self.e12*other.e13 + self.e13*other.e12 + self.e23*other.e - self.e0123*other.e01,
e0123: self.e*other.e0123 + self.e01*other.e23 - self.e02*other.e13 + self.e03*other.e12 + self.e12*other.e03 - self.e13*other.e02 + self.e23*other.e01 + self.e0123*other.e,

这篇关于如何使用 4d 转子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆