如何使用 4d 转子

Azo*_*ogh 3 math angle rotation 4d

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

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

我怎样才能实现这个类的功能?特别是旋转矢量和其他转子的功能,并得到逆?

我将不胜感激一些伪代码示例。非常感谢任何麻烦回答的人。

Hug*_*eld 5

在计算机中表示几何代数多向量(包括转子)的最常见方法是通过一系列系数,一个用于每个规范形式代数基元素(规范基叶片),即。对于 4D 基础空间,您将拥有 2^4 维代数和 2^4 维系数数组。另一种但可能更快的表示它们的方法是使用动态调整大小的列表,其中每个元素都包含一个刀片的索引和相关刀片的系数。在这种情况下,两个多向量的乘法将仅使用非零基刀片,因此在算法上应该更便宜且内存使用量更轻。

在实际使用方面,我发现开始玩几何代数的最简单的地方可能是在 python 中使用https://github.com/pygae/clifford。完全免责声明我每天都使用这个库,并为它做出了广泛的贡献。该库使用系数方法的平面阵列。使用这个 python 库,您可以通过三明治产品应用 4D 转子,并通过波浪号运算符进行反转(转子的反转):

# Create a 4D geometric algebra with euclidean metric
from clifford.g4 import *

# Create a rotor
R = layout.randomRotor()

# Create a vector to rotate
V = layout.randomV()

# Apply the rotor to the vector
V2 = R*V*~R
Run Code Online (Sandbox Code Playgroud)

来自 N 维几何代数的多向量的几何积和逆的具体定义可以在 Chris Doran 和 Anthony Lasenby 的 Geometric algebra for Physicists 的第 4 章中找到。

使用元素列表方法的 N 维 GA 的良好 C++ GA 参考实现可以在 Leo Dorst 的《Geometric Algebra for Physicists》一书中找到,也可以在他的网站上找到:http : //www.geometricalgebra.net/code.html。一般来说,这是 GA 的重要资源,尤其是保形模型和数值实现和关注点。


Azo*_*ogh 3

在学习了有关该主题的更多信息后,我能够使用 Rotors,这要归功于有关几何代数的 YouTube 系列:https://www.youtube.com/watch ?v=PNlgMPzj-7Q&list=PLpzmRsG7u_gqaTo_vEseQ7U8KFvtiJY4K

它解释得非常好,我推荐给任何想要使用几何代数的人。

如果您已经了解四元数乘法,那么转子乘法不会有任何不同,并且四元数的 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/clifford/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 )
// 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 )
Run Code Online (Sandbox Code Playgroud)

所以在代码中,你会做类似的事情:

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
Run Code Online (Sandbox Code Playgroud)

现在只需对那些大型 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,
Run Code Online (Sandbox Code Playgroud)