如何从两个矢量3获得俯仰角 [英] How do I get the pitch angle from two vector3

查看:75
本文介绍了如何从两个矢量3获得俯仰角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好专家!



我有4个vector3:

Hello experts!

I have 4 vector3:

Vector3 posFront = PositionBlocks.front.GetPosition();
Vector3 posRear = PositionBlocks.rear.GetPosition();
Vector3 posLeft = PositionBlocks.left.GetPosition();
Vector3 posRight = PositionBlocks.right.GetPosition();





posFront是鼻子。

posRear是尾巴。

posLeft是左翼尖。

posRight是右翼尖。



这些vector3是全球坐标。



目前我只是尝试获得俯仰角(上/下)。

我有这个代码:



posFront is the nose.
posRear is the tail.
posLeft is the left wing tip.
posRight is the right wing tip.

These vector3 are global coordinates.

At the moment I just try to get the pitch angle (up/down).
I have this code:

const int X = 0;
const int Y = 1;
const int Z = 2;

Vector3 dir = Vector3.Subtract(posFront, posRear);
double x = dir.GetDim(X);
double y = dir.GetDim(Y);
double z = dir.GetDim(Z);
double angle = Math.Atan2(z, Math.Sqrt(y * y + x * x)) * 180.0 / Math.PI;

Logger.log(angle.ToString());





但这给了我一系列:

0到90,回到0,然后到-90再回到0



我需要的是-180到-180的范围180.





我希望有人可以帮助我

谢谢



But this gives me a range of:
0 to 90, back to 0, then to -90 and back to 0

What I need is a range from -180 to 180.


I hope someone can help me
Thanks

推荐答案

俯仰角是航空术语,如果没有为两个向量定义的话。您可以只计算它们之间的角度。矢量代数在很多地方都有解释,看看它们中的任何一个。例如 http://www.ltcconline.net/greenl/courses/107/vectors/dotcros。 htm [ ^ ]。



无论如何,这些问题不是通过提问而是通过教育解决的。在这种情况下,教育在这个相对简单的数学领域,线性代数

http://en.wikipedia.org/wiki/Linear_algebra [ ^ ],

http://en.wikipedia.org/wiki/Vector_algebra [ ^ ]。



请熟悉这个领域。



-SA
"Pitch angle" is the aviation term, if is not defined for just two vectors. You can calculate just the angle between them. The vector algebra is explained in so many places, look at any of them. Such as http://www.ltcconline.net/greenl/courses/107/vectors/dotcros.htm[^].

Anyway, such problems are solved not by asking questions, but by education. In this case, education in this relatively simple field of mathematics, linear algebra:
http://en.wikipedia.org/wiki/Linear_algebra[^],
http://en.wikipedia.org/wiki/Vector_algebra[^].

Please make yourself familiar with this field.

—SA


这篇关于如何从两个矢量3获得俯仰角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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