从向上向量倾斜角度并观察向量?

发布于 2024-09-05 12:26:53 字数 215 浏览 2 评论 0原文

我无法找出从向上和观察向量计算倾斜(滚动)角度的公式,尽管我觉得这个角度必须在垂直于观察向量的平面上测量。任何提示表示赞赏。仅供参考,我使用 WPF。

我在这里发布了另一个问题,这是同样的问题,但仅表达使用数学。

I can't figure out the formula to compute the bank (roll) angle from the up and lookat vectors, though I feel this angle must be measured in tha plan normal to the lookat vector. Any hint appreciated. FYI I use WPF.

I have posted another question here, which is the same problem, but expressed only using math.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难理解 2024-09-12 12:26:53

这是确定银行的最终代码。请注意,我需要确定角度的符号:

// project Y on plan perpendicular to look
Vector3D Yproj = new Vector3D(
    -(lookDirection.Y * lookDirection.X),
    1 - (lookDirection.Y * lookDirection.Y),
    -(lookDirection.Y * lookDirection.Z));
Yproj.Normalize();

// get absolute angle between Y projected and Up
double absAngle = Vector3D.AngleBetween(upDirection, Yproj);

// magic formula
Vector3D cross = Vector3D.CrossProduct(upDirection, Yproj);
double dot = Vector3D.DotProduct(lookDirection, cross);

// set actual signed angle
BDeg = (dot >= 0) ?  absAngle : -absAngle;

This is the final code to determine Bank. Note that I needed to determine the sign of the angle:

// project Y on plan perpendicular to look
Vector3D Yproj = new Vector3D(
    -(lookDirection.Y * lookDirection.X),
    1 - (lookDirection.Y * lookDirection.Y),
    -(lookDirection.Y * lookDirection.Z));
Yproj.Normalize();

// get absolute angle between Y projected and Up
double absAngle = Vector3D.AngleBetween(upDirection, Yproj);

// magic formula
Vector3D cross = Vector3D.CrossProduct(upDirection, Yproj);
double dot = Vector3D.DotProduct(lookDirection, cross);

// set actual signed angle
BDeg = (dot >= 0) ?  absAngle : -absAngle;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文