从向上矢量倾斜角度并查看矢量? [英] Bank angle from up vector and look at vector?

查看:30
本文介绍了从向上矢量倾斜角度并查看矢量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法计算从向上和注视向量计算倾斜(滚动)角度的公式,尽管我觉得这个角度必须在与注视向量垂直的平面中测量.任何提示表示赞赏.仅供参考,我使用 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.

推荐答案

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

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;

这篇关于从向上矢量倾斜角度并查看矢量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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