使用变量 Xrotation、Yrotation 和 Zrotation 以高效方式创建四维脚本

Four dimensional script in a efficient manner using variables Xrotation, Yrotation, and Zrotation

是否有使用变量 Xrotation Z 旋转和 Yrotation 作为输入在三维 space 中映射四维点的有效公式?

我特别需要 scratch 语言,但任何其他语言都适用。

您可能正在谈论的四维旋转称为关于这些转换的 quaternion. When talking about rotating around each axis in a 3D space, we call Euler angles. Wikipedia has page,其中包括此 python 来源:

class Quaternion_toEulerianAngle():
    def __init__(self, x, y, z, w):
        self.x = x
        self.y = y
        self.z = z
        self.w = w

    def X(self):
        ysqr = self.y*self.y

        t0 = +2.0 * (self.w * self.x + self.y*self.z)
        t1 = +1.0 - 2.0 * (self.x*self.x + ysqr)
        X = math.degrees(math.atan2(t0, t1))

        return X

    def Y(self):
        ysqr = self.y*self.y

        t2 = +2.0 * (self.w*self.y - self.z*self.x)
        t2 =  1 if t2 > 1 else t2
        t2 = -1 if t2 < -1 else t2
        Y = math.degrees(math.asin(t2))

        return Y

    def Z(self):
        ysqr = self.y*self.y

        t3 = +2.0 * (self.w * self.z + self.x*self.y)
        t4 = +1.0 - 2.0 * (ysqr + self.z*self.z)
        Z = math.degrees(math.atan2(t3, t4))

        return Z