计算 3d 中线段之间的垂直距离和角距离
我正在致力于用 C++ 实现聚类算法。具体来说,这个算法: http://www.cs.uiuc.edu/~ hanj/pdf/sigmod07_jglee.pdf
在算法中的某一点(第 3.2 p4-5 节),我要计算两条线段之间的垂直距离和角度距离(d┴ 和 dθ):p1 到 p2,p1 到p3。
我已经有一段时间没有上数学课了,我对这些实际上的概念以及如何计算它们有点动摇。有人可以帮忙吗?
I am working on implementing a clustering algorithm in C++. Specifically, this algorithm: http://www.cs.uiuc.edu/~hanj/pdf/sigmod07_jglee.pdf
At one point in the algorithm (sec 3.2 p4-5), I am to calculate perpendicular and angular distance (d┴ and dθ) between two line segments: p1 to p2, p1 to p3.
It has been a while since I had a math class, I am kinda shaky on what these actually are conceptually and how to calculate them. Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要获取点
Q
到由两点P_1
和P_2
定义的直线的垂直距离,请计算:其中
DOT 是点积,
CROSS
是向量叉积,MAG
是幅度 (sqrt(X*X+Y*Y+..)< /code>)
使用图 5。您计算
d_1
从sj
到直线 (si->ei
) 的距离以及d_2
从ej
到同一直线的距离。我将基于三个点建立一个坐标系,其中两个(
P_1
、P_2
)表示一条线,第三个Q
表示起点或终点其他线段的末端。坐标系的三个轴可以这样定义:其中
UNIT()
是返回单位向量(幅度=1)的函数。然后,您可以使用简单的点积确定所有投影长度。因此,考虑图 5 中的线
si-ei
和点sj
,长度为:并且在第二段
ej
的末尾,需要计算新的坐标轴(e
,k
,n
)最终角度距离为
PS。您可能想将其发布在 Math.SO 上,在那里您可以获得更好的答案。
To get the perpendicular distance of a point
Q
to a line defined by two pointsP_1
andP_2
calculate this:where
DOT
is the dot product,CROSS
is the vector cross product, andMAG
is the magnitude (sqrt(X*X+Y*Y+..)
)Using Fig 5. You calculate
d_1
the distance fromsj
to line (si->ei
) andd_2
the distance fromej
to the same line.I would establish a coordinate system based on three points, two (
P_1
,P_2
) for a line and the thirdQ
for either the start or the end of the other line segment. The three axis of the coordinate system can be defined as such:where
UNIT()
is function to return a unit vector (with magnitude=1).Then you can establish all your projected lengths with simple dot products. So considering the line
si-ei
and the pointsj
in Fig 5, the lengths are:And with the end of the second segment
ej
, new coordinate axes (e
,k
,n
) need to be computedEventually the angle distance is
PS. You might want to post this at Math.SO where you can get better answers.
看第 3 页的图 5。它画出了 d┴ 和 dθ 是什么。
编辑:“莱默平均值”是使用 Lp-space 约定定义的。因此,在 3 维中,您将使用 p = 3。假设两个起点之间的(欧几里德)距离为 d1,两端之间的距离为 d2。然后
d┴(L1, L2) = (d1^3 + d2^3) / (d1^2 + d2^2)
。要查找两个向量之间的角度,您可以使用它们的点积。范数(表示为
||x||
)的计算 像这样。Look at figure 5 on page 3. It draws out what d┴ and dθ are.
EDIT: The "Lehmer mean" is defined using Lp-space conventions. So in 3 dimensions, you would use p = 3. Let's say that the (Euclidean) distance between the two start points is d1, and between the ends is d2. Then
d┴(L1, L2) = (d1^3 + d2^3) / (d1^2 + d2^2)
.To find the angle between two vectors, you can use their dot product. The norm (denoted
||x||
) is computed like this.