[英]Find direction of given x,y,z cordinates
i'm new to opencv & it's developing. 我是opencv的新手,而且正在不断发展。 I have x,y,z coordinates ( 0.00949334694383068, -0.3999829847985352, 0.8449078780010854) by using the given coordinates how could i find the direction.
我有x,y,z坐标(0.00949334694383068,-0.3999829847985352,0.8449078780010854)通过使用给定的坐标我怎么能找到方向。
for an example
input one : x,y,z = 0.00949334694383068, -0.3999829847985352, 0.8449078780010854
input two : x,y,z = 0.01603883281370779, 0.6066595296580494, 0.5342810849038371
At the finally i want to compare input_one direction and input_two direction. 最后,我想比较input_one方向和input_two方向。 Any help is appreciated
任何帮助表示赞赏
What you're trying to do is called calculating the azimuth. 您要尝试做的就是计算方位角。 If you're interested in doing this for navigational or geographic purposes and need a thorough understanding of this, you can start here:
如果您有兴趣出于导航或地理目的而执行此操作,并且需要对此有透彻的了解,则可以从此处开始:
http://mobile.codeguru.com/cpp/cpp/algorithms/article.php/c5115/Geographic-Distance-and-Azimuth-Calculations.htm http://mobile.codeguru.com/cpp/cpp/algorithms/article.php/c5115/Geographic-Distance-and-Azimuth-Calculations.htm
Otherwise you could look for a library for calculating the azimuth bases on 3d co-ordinates 否则,您可能会寻找一个库来计算基于3d坐标的方位角
This is called vector math. 这称为向量数学。
"Coordinates" are a special kind of vector, relative to some origin (in your case x=0,y=0,z=0
). 相对于某些原点(在您的情况下
x=0,y=0,z=0
) x=0,y=0,z=0
“坐标”是一种特殊的向量。 For that reason, the difference x1-x2, y1-y2, z1-z2
is a vector from point 2 to point 1. The inverse x2-x1, y2-y1, z2-z1
is a vector from point 1 to point 2. 出于这个原因,所不同的
x1-x2, y1-y2, z1-z2
是从点2 到点 1.逆矢量x2-x1, y2-y1, z2-z1
是从点1 至点2的载体。
The direction of a vector is usually defined by ignoring its length, or alternatively by setting its length to one. 向量的方向通常是通过忽略其长度或将其长度设置为1来定义的。 So we need to first define the length, which is
L = √(x*x + y*y + z*z)
. 因此,我们需要首先定义长度,即
L = √(x*x + y*y + z*z)
。 We can define the vector x/L, y/L, z/L
which points in the same direction as x,y,z
but with length one. 我们可以定义向量
x/L, y/L, z/L
,其指向与x,y,z
相同的方向x,y,z
但长度为1。
Finally, to compare two directions we can calculate the inner product of those two directions: x1/L1 * x2/L2 + y1/L1 * y2/L2 + z1/L1 * z2/L2
. 最后,为了比较两个方向,我们可以计算这两个方向的内积 :
x1/L1 * x2/L2 + y1/L1 * y2/L2 + z1/L1 * z2/L2
。 If that's one, they point in the same direction. 如果那是一个,则它们指向相同的方向。 If it's 0, they're orthogonal.
如果为0,则它们是正交的。 If it's -1, they point in opposite directions.
如果为-1,则它们指向相反的方向。
As you can see, the vector 0,0,0 has length 0 and no direction. 如您所见,向量0,0,0的长度为0,没有方向。 That can complicate things a bit.
这会使事情复杂化。
In OpenCV: class Vec . 在OpenCV中: Vec类 。 The length function is called
norm(v)
and the inner product is called v1.mul(v2)
长度函数称为
norm(v)
,内部乘积称为v1.mul(v2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.