【问题标题】:Inverse quaternion [duplicate]反四元数[重复]
【发布时间】:2023-03-31 15:22:01
【问题描述】:

谁能告诉我如何得到四元数的倒数。

q-1=q'/(q*q')

q' = 四元数共轭

(q*q') = 四元数的范数 * 四元数的范数

我有我的四元数:(C 语言)

quat.x = 0.0;
quat.y = 1.0;
quat.z = 0.0;
quat.w = 45.0;

第一个共轭:

quat.conjx =  0.0;
quat.conjy = -1.0;
quat.conjz =  0.0;
quat.conjw = 45.0;

下一步:规范

quat.norm = sqrt(quat.x*quat.x + quat.y*quat.y + quat.z*quat.z + quat.w*quat.w);

好的,但是...如何使用 C 语法计算逆?是这样吗?:

quat.invx = quat.conjx / (quat.norm*quat.norm);
quat.invy = quat.conjy / (quat.norm*quat.norm);
quat.invz = quat.conjz / (quat.norm*quat.norm);
quat.invw = quat.conjw / (quat.norm*quat.norm);

非常感谢您的帮助

【问题讨论】:

  • 在这篇文章中使用 C 语法?
  • 这不是重复的。另一个问题在 Haskell 中回答。
  • 逆公式如下:inverse = conjugate(q) / norm(q)I wrote a C-library that does this.我会创建一个新答案,但这是一个封闭的问题。

标签: c quaternions


【解决方案1】:

四元数x + i y + j z + k w的共轭定义为x - i y - j z - k w。没有三个单独的共轭。另外,不要尝试将norminvxinvyinvzconjx 等放入四元数结构中。随便写:

typedef struct {
    double x;
    double y;
    double z;
    double w;
} quaternion;

然后编写将四元数作为参数并返回它们的函数。例如,写:

// Construct and return the conjugate of q.
quaternion q_conjugate(const quaternion q) { ...}
// Divide quaternion q by scalar d
quaternion q_divide(const quaternion q, const double divisor) {...}
// Compute the squared norm of q
double q_squared_norm(const quaternion q) {...}
// Compute the inverse of q
quaternion q_inverse(const quaternion q);

【讨论】:

  • 啊,那么我的四元数的共轭是 0-1-0-45 = -46.0 ?
  • 不,它是 0.0 - 1.0 i - 0.0 j - 45.0 k。正如复数 x + i y 可以被认为是平面中的向量,四元数可以被认为是 R^4 中的向量。它的共轭是 R^4 中的另一个向量。添加组件是没有意义的。
  • 好吧,但是,你能告诉我如何使用 C 语法计算 q_inverse。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-15
  • 1970-01-01
  • 2019-11-24
  • 1970-01-01
  • 2015-02-28
相关资源
最近更新 更多