本文介绍了如何确定点到曲线的最短距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++ MFC或C#中.
首先,我画一条线,它由连续的直线和曲线组成.给出了直线和曲线方程.
然后,上面的线附近有一些点,
我的问题是如何确定C ++或C#中的点与线之间的短路距离.
我知道这在AutoCAD中非常简单,但是我无法在C ++或C#中弄清楚.
非常感谢,伙计们,我需要您的帮助


也许我没有表达清楚.
我在一个火车建设项目中遇到了一个问题.设计的火车线由连续的直线和曲线组成.通常使用圆形曲线和缓和曲线.每条曲线均以解析方程式给出.
(缓动曲线:一条曲线,例如在高速公路上,其曲率变化以在切线和简单曲线之间或在所连接的两个简单曲线之间提供逐渐的过渡.也称为过渡曲线).
然后,我沿着火车线测量了一些点,我需要知道所测量的点与设计线之间的距离.
通过AutoCAD,我可以画出设计的线,也可以画出我的点.找到最短的距离非常简单.
但是我不能用C ++或C#解决它.有什么方法可以捕捉我在屏幕上绘制的每个点或线吗?

PS,火车线,如果经常是水平或垂直,

In C++ MFC or C#.
first, I draw a line, which consists of continuous straight lines and curves. the equations of straight lines and curves are given.
then , there are some points near the line above,
my question is how to deterimine the shortes distance between the points and the line in C++ or C#.
I know it''s very simple in AutoCAD, but I cannot figure it out in C++ or C#.
Thanks very much, guys, I need your help


Maybe I didnot express clearly.
I met a problem in a train construction project. The train line designed consists of continuous straight lines and curves. Circular curve and easement curve are often used. Every curve is given in ‎analytical equations.
(easement curve: A curve, as on a highway, whose degree of curvature is varied to provide a gradual transition between a tangent and a simple curve, or between two simple curves which it connects. Also known as transition curve).
Then I measured some points along the train line, I need to know the distance between the points i measured and the designed line.
By AutoCAD, i can draw the designed line, and also my points. It''s very simple to find the shortest distance.
But I cannot solve it in C++ or C#. Is there any way to catch every point or line i drawed on the screen?

PS, the train line if often horizontal or vertical,

推荐答案


然后,在每个曲线段的边界多边形上找到最接近的点(由四个控制点定义).如果点在线段的边界多边形内,则将该线段的距离值设置为0.

如果最小值是针对线段的,则采用最接近的方法.如果是曲线段,请使用适合您问题的步长沿曲线查找最小值.如果共享最小值,则可能需要走多个曲线段.但是您无需走遍整个道路.

在某些病理情况下,该点可能在一个或多个曲线边界框内,但最接近直线.因此,一旦找到距离值小于最小直线的每个曲线段的真正最接近方法,就可以通过走动该线段,来检查实际距离是否仍小于最小直线.

另外,该点可以靠近曲线的边界框,但不能靠近曲线本身.因此,您还应该在曲线的边界框中存储到点的最大距离,并在所有曲线的最小值小于(i)直线的最小距离的情况下走动所有曲线(ii)曲线的最大距离,且最小值最小.在路径为100%曲线的极端情况下,所有曲线都具有较大的边界框并且彼此靠近,这可能意味着您仍将必须走整条路径.


Then, find the closest point on the bounding polygon of each of the curve segments (defined by the four control points). If the point is within the bounding polygon of a segment, give that segment a distance value of 0.

If the smallest value is for a line segment, you have the closest approach. If it is for a curve segment, walk along the curve to find the minimum, using a step size appropriate for your problem. If the smallest value is shared, you may need to walk more than one curve segment. But you won''t need to walk the whole path.

In certain pathological cases, the point may be inside one or more curve bounding boxes, but closest to a line. So once you have found the real closest approach for each curve segment that has a lower distance value than the smallest line, by walking the segment, you need to check if the real distances are still lower than the smallest line.

In addition, the point can be close to the bounding box of a curve, but not to the curve itself. You should therefore also store the maximum distance to a point in the curve''s bounding box, and walk all curves with a minimum value less than (i) the smallest distance-to-line for a line segment and (ii) the maximum distance for the curve(s) with the smallest minimum value. In the extreme case of a path which is 100% curves, all of which have large bounding boxes and are near to each other, this may mean you will still have to walk the entire path.




这篇关于如何确定点到曲线的最短距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:05
查看更多