Calculation of distances from a given set of points to a set of segments

버전 1.4.0.0 (3.07 KB) 작성자: Andrei Bejan
A fully vectorised calculation of distances from a given set of points to a set of segments.
다운로드 수: 1.2K
업데이트 날짜: 2011/12/13

라이선스 보기

CSMV calculates distances from a given set of points to a set of linear segments

SYNOPSIS: [squared_distances_to_segments I t]=csmv(P,R,Q,to_plot)
[squared_distances_to_segments I t]=csmv(P,R,Q,...)

INPUT P,R : arrays of coordinates of 2n segment endpoints
(i.e., if there are n segments considered in p-dimensional
Euclidean space, than P and R are n-by-p matrices); the sizes of P
and R should coincide; p should be greater or equal than unity.
Q : an array of coordinates corresponding to the set of m points
from which distances to the segments PR are calculated
(Q should therefore be an m-by-p matrix).
to_plot : (optional) graphical output.
Any non-zero value would cause the graphical output. There will be
no graphical output by default (if this parameter is not passed).

OUTPUT squared_distances_to_segments : an n-by-m matrix whose j-th column
contains n squared distance from the j-th point of Q to the segments PR.
I : a vector of m elements representing indices of the segments PR
which are the closest to points from Q.
t : an n-by-m matrix whose ij-th element is a real number between 0
and 1 equal to |P(i,:)Qi*(j,:)|/|P(i,:)R(i,:)|, where Qi*(j,:) is the
point on the segment P(i,:)R(i,:) closest to Q(j,:). Thus, for example, if
P(i,:) is closest to Q(j,:), then t(i,j)=0; if R(i,:) is closest to
Q(j,:), then t(i,j)=1.

NOTE: (i) the dimensions of P and R should coincide!
(ii) you may encounter an error if some points P and R coincide;
this can be easily avoided by suitably changing the code - feel
free to do so.

인용 양식

Andrei Bejan (2024). Calculation of distances from a given set of points to a set of segments (https://www.mathworks.com/matlabcentral/fileexchange/28268-calculation-of-distances-from-a-given-set-of-points-to-a-set-of-segments), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2009a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Image Segmentation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.4.0.0

A third output argument is added. This explicitly indicates whether the closest points on the segments are inner points or the end points.

1.3.0.0

one-dimensional case is added (p=1)

1.2.0.0

minor corrections in the description of the function csmv

1.1.0.0

Small changes in the description of this function have been made.

1.0.0.0