简体   繁体   English

如何从与另一个给定线段相交的一组点中找到最短的线(2个端点就可以了)

[英]how can I find a shortest line (2 end points will be fine) from a group of points which is intersect with another given line segment

图片

Say I got a bunch of points(red points) and a blue line segment , i want to find a line(2 points) which is intersect with the blue line segment and the sum of two end points' perpendicular distance to the blue line segment is the shortest distance.假设我有一堆点(红点)和一条蓝线段,我想找到一条与蓝线段相交的线(2 点)以及两个端点与蓝线段垂直距离之和是最短距离。

P in this picture above is CD and the blue line segment intersect point.上图中的 P 是 CD 和蓝色线段的交点。

I only know that they should be on the blue line's different side (left/right or above/below).我只知道它们应该在蓝线的另一侧(左/右或上/下)。

But there are still serveral variants can make this go south.Like AB and CE in this picture.但是仍然有几个变体可以使这个 go 南下。像这张照片中的 AB 和 CE。

Edit: At first i thought i only need to make sure both of two end points' projection point lies on the blue line segment .But if I do so,there might be not so many good points for this case.I might just throw the only solution away.编辑:起初我以为我只需要确保两个端点的投影点都位于蓝线段上。但如果我这样做,这种情况下可能没有那么多优点。我可能只是抛出唯一的解决办法。

Sketch of algorithm:算法示意图:

  1. Calculate all perp.计算所有 perp。 distances including orientation (left or right of dividing line L).距离,包括方向(分界线 L 的左侧或右侧)。
  2. Devide points in two lists (left or right).在两个列表(左或右)中划分点。
  3. Sort both lists by perp.按 perp 对两个列表进行排序。 distance.距离。
  4. Now build pairs from both lists, sorted by minimal sum of perp.现在从两个列表构建对,按 perp 的最小总和排序。 distance.距离。
  5. Choose the first (smallest sum) pair with a connecting line that intersects L as result.选择具有与 L 相交的连接线的第一个(最小和)对作为结果。

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

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