Distance from points to polyline or polygon
版本 2.0.0.1 (7.5 KB) 作者:
Michael Yoshpe
Find minimum distances from points to a polyline or to a closed polygon
编者注: This file was selected as MATLAB Central Pick of the Week
The following files are included:
p_poly_dist.m - Compute the distances from each one of a set of np points p(1), p(2),... p(np) on a 2D plane to a polyline or a closed polygon. Polyline is defined as a set of nv-1 segments connecting nv ordered vertices v(1), v(2), ..., v(nv). The polyline can optionally be treated as a closed polygon.
Distance from point j to a segment k is defined as a distance from this point to a straight line passing through vertices v(k) and v(k+1), when the projection of point j on this line falls INSIDE of segment k; and to the closest of v(k) or v(k+1) vertices, when the projection falls OUTSIDE of segment k. Distance from point j to a polyline is defined as a minimum of this point's distances to all segments.
In a case when the projected point fall OUTSIDE of ALL polyline segments, the distance to a closest vertex of the polyline is returned
test_p_poly_dist.m - a simple unit test for p_poly_dist. Plots the results of a call to p_poly_dist function (see help for usage example)
p_poly_dist1.m – previous version (ver. 1.0) of p_poly_dist.m
Notes on version 2.0:
Oct 2, 2015 - version 2.0 (Michael Yoshpe). The original ver. 1.0 function was completely redesigned. The main changes introduced in Ver. 2.0 are:
1. Distances to polyline (instead of a closed polygon in Ver. 1.0) are returned. The polyline can optionally be treated as a closed polygon.
2. Distances from multiple points to the same polyline can be found.
3. The algorithm for finding the closest points is now based on coordinate system transformation. The new algorithm avoids numerical problems that Ver. 1.0 algorithm could experience in "ill-conditioned" cases.
4. Many optional output variables were added. In particular, the closest points on polyline can be returned.
5. Added input validity checks
引用格式
Michael Yoshpe (2024). Distance from points to polyline or polygon (https://www.mathworks.com/matlabcentral/fileexchange/12744-distance-from-points-to-polyline-or-polygon), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
创建方式
R2014b
兼容任何版本
平台兼容性
Windows macOS Linux类别
在 Help Center 和 MATLAB Answers 中查找有关 Elementary Polygons 的更多信息
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
2.0.0.1 | 1) Small changes to p_poly_dist function to allow translation with Matlab Coder
|
||
2.0.0.0 | Fixed a bug that cause idx_c output argument to be off by 1
|
||
1.0.0.0 |