简体   繁体   English

在两个轴上计算方向的更有效方法?

[英]More efficient way to calculate direction on both axis?

I have a Vector3 defined like so {x,y,z};我有一个像这样定义的 Vector3 {x,y,z};

I want to get the angles of the point relative to the y axis and the origin.我想获得点相对于 y 轴和原点的角度。

I do:我愿意:

  float tilt = atan2( point.z(), point.y() );
  float pan = atan2( point.x(), point.y() ); 

Now, I need the directions so the dot product is not interesting.现在,我需要说明,这样点积就没意思了。

Is there a better way to get those values in one go?有没有更好的方法在一个 go 中获取这些值?

Thanks谢谢

Expression表达

angle = acos(x / length(x,y,z))

gives angle between vector and OX axis.给出向量和 OX 轴之间的角度。 Range is 0..Pi .范围是0..Pi

Perhaps you want -Pi/2..Pi/2 range between OYZ plane and vector - in this case use Pi/2-angle也许你想要 OYZ 平面和矢量之间的-Pi/2..Pi/2范围 - 在这种情况下使用Pi/2-angle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM