简体   繁体   English

坐标簇与沿单位矢量i的点之间的最小距离

[英]Minimum distance between coordinate cluster and a point along unit vector i

I have a set of 3D coordinates Q clustered into a crude sphere about an origin O, a unit vector i, and length d. 我有一组3D坐标Q,这些坐标Q围绕原点O,单位矢量i和长度d聚集到一个粗球形中。 Let p = c * i where c is a positive real number. 令p = c * i,其中c是一个正实数。 Let M denote the set of distances between p and every q in Q. I need a robust way to compute the minimum value of c subject to the constraint that the minimum valve of M be bigger than d. 令M表示p与Q中每个q之间的距离的集合。在M的最小阀大于d的约束下,我需要一种可靠的方法来计算c的最小值。 Is there an elegant way to do this in python with scipy/numpy? 有没有一种优雅的方法可以在python中使用scipy / numpy做到这一点? I suspect that scipy.spatial.KDTree will be useful but it is unclear how I would efficiently find my constrained minimum. 我怀疑scipy.spatial.KDTree会很有用,但目前尚不清楚如何有效地找到我的约束最小值。

You can solve the problem like this: 您可以解决以下问题:

For a point q in Q, define: 对于Q中的一个点q,定义:

C(q) = set of values of c >= 0 s.t. |q - c*i| >= d

and then define 然后定义

C = intersection { q in Q } C(q)

and then the desired value c is: 然后期望值c为:

c = inf C = minimum element of C

The sets C(q) are just the solution to a quadratic inequality and so will have one of the forms: 集C(q)只是二次不等式的解决方案,因此将具有以下形式之一:

1) C(q) = [0, +infinity)
2) C(q) = [0, b] union [ e, +infinity )  (for some e > b)
3) C(q) = [e, +infinity )

You can safely discard sets of the first form. 您可以安全地丢弃第一种形式的集合。

If all of the remaining C(q) sets have form #2, then c = 0. 如果所有其余的C(q)集都具有形式#2,则c = 0。

If instead they all have form #3, c is: 相反,如果它们都具有#3形式,则c为:

c = maximum { q in Q } e(q)

Otherwise things get more complicated. 否则情况会变得更加复杂。

For a given q, to compute C(q) note that: 对于给定的q,要计算C(q),请注意:

|q - c*i| >= d
  <=> (q - c*i)^2 >= d*d
  <=> (q - c*i).(q - c*i) >= d*d
  <=> q.q + c*c - 2*c*(q.i) >= d*d
  <=> c*c - c*2*(q.i) + q.q - d*d >= 0

If the discriminant of this quadratic equation is < 0, then C(q) = [0, +infinity). 如果此二次方程的判别式<0,则C(q)= [0,+无限大]。

Otherwise let b and e be the roots, b <= e, and check these cases: 否则,让b和e为根,b <= e,并检查以下情况:

e < 0    -->  C(q) = [0, +infinity)
b < 0    -->  C(q) = [e, +infinity)
b >= 0   -->  C(q) = [0, b]  union [e, +infinity)

An example in 2-d which demonstrates the more complicated case: 2-d中的示例演示了更复杂的情况:

Q = { q1, q2, q3, q4 }
  = { (1,0), (0,1), (4,4), (0,10) }
i = (1/sqrt 5, 2/sqrt 5)
d = 2

C(q1) = [ 2.236, +infinity )
C(q2) = [ 2.843, +infinity )
C(q3) = [ 0, 4.472 ] union [ 6.261, +infinity )
C(q4) = [ 0, +infinity )

The smallest element of the intersection of C(q1), C(q2) and C(q3) is 2.843. C(q1),C(q2)和C(q3)的交点的最小元素为2.843。

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

相关问题 如何计算一个python函数,该函数计算/绘制点与曲线之间的最小距离? - How do I compute a python function which calculates/plot minimum distance between a point and a curve? 如何使用 Python 获得点和抛物线之间的最小距离? - How do I get the minimum distance between a point and a parabola using Python? 如何计算kmeans聚类中心之间的距离并在python中选择最小值? - How to calculate distance between cluster centres of kmeans and choose the minimum in python? 优化器在某些点上失败的点和曲线之间的最小距离 - Minimum distance between a point and a curve with optimiser failing for some points 原子之间的最小距离 - Minimum distance between atoms 计算给定点、方位和距离的 GPS 坐标 - calculating a gps coordinate given a point, bearing and distance 确保选择之间的最小距离 - Ensuring minimum distance between choices 查找两个数组PLOT1和PLOT2之间的最小距离,并在该点所在的位置存储索引 - To find minimum distance between two array PLOT1 and PLOT2 and also store the index where that point is "找到点到复杂曲线的最小距离" - Find minimum distance from point to complicated curve 计算坐标对之间的最小距离 - Computing the least distance between coordinate pairs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM