开发者

How do you calculate the line of shortest distance between two sets of line segments that passes through a known point?

Given two sets of line segments (xa1..N,ya1..N) and (xb1..N,yb开发者_如何转开发1..N) that represent the upper and lower surfaces of a geology unit, and a known point (xc1,yc1) within the geology unit, how do I find the line of shortest distance between (xa,ya) and (xb,yb) that passes through (xc1,yc1).


If I understand well, you are looking for an intermediate polyline between two given polylines, through a given point.

If your two source polylines have the same point count, you can consider linear interpolation between corresponding segments, using a parameter t in range [0 1]. Every new vertex is given by

Xti = (1 - t) Xai + t Xbi
Yti = (1 - t) Yai + t Ybi

When t=0, this gives the upper surface, t=1 the lower surface and other t intermediate surfaces.

Now remains to find the t value that makes the line pass through (xc, yc). Every segment can be represented by its parametric equation, between point i and i+1 (let j), using some parameter p. This leads to the following equations:

Xc= (1 - p) Xti + p Xtj
Yc= (1 - p) Yti + p Ytj

Now, for every i-j segment, you have a system of two equations in two unknowns (t and p). You will keep the i-j solution such that p falls in range [0 1]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜