银行角向上矢量,看看向量?

时间:2010-06-14 07:28:15

标签: wpf vector bank

我无法弄清楚从up和lookat向量计算bank(roll)角度的公式,尽管我觉得这个角度必须在与lookat向量垂直的平面图中测量。任何暗示赞赏。仅供参考我使用WPF。

我发布了another question here,这是同样的问题,但仅使用数学表达。

1 个答案:

答案 0 :(得分:0)

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

// 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;