  Home  |  About Us  |  Link To Us  |  FAQ  |  Contact  # Calculation of distances from a given set of points to a set of segments 1.0

Date Added: April 10, 2013  |  Visits: 522 Report Broken Link Printer Friendly Version Product Homepage Download (33 downloads)

CSMV calculates distances from a given set of points to a set of linear segments SYNOPSIS: [squared_distances_to_segments I]=csmv(P,R,Q,to_plot) [squared_distances_to_segments I]=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 than or equal to 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.EXAMPLES (1-D, 2-D and 3-D cases with graphical outputs) 1) segments and points on the line PR_segments = [10,-10; -1,0; 2.3,1; 5,9; 10,10.2]; % note that PR do not have to be defined as directed segments! E.g. the third segment [2.3,1] in PR_segments is defined as an undirected segment. P = PR_segments(:,1); R = PR_segments(:,2); [squared_distances_to_segments I]=csmv(P,R,Q)OR [squared_distances_to_segments I]=csmv(P,R,Q,1); 2) plane P =[1 3; 4 6; 8 -1; 3 7] R = [0 -1; 2 2; 3 1; 0.1 2] Q =[4 1; 5 5; -1 3.5; -10 2; 10 -2] to_plot=1; [squared_distances_to_segments I]=csmv(P,R,Q,to_plot) 3) 3-D space P =[ 1 3 5; 4 6 9; 8 -1 -9; 3 7 0] R = [ 0 -1.0000 -1; 2.0000 2.0000 2; 3.0000 1.0000 4; 0.1000 2.0000 7] Q =[ 4.0000 1.0000 0; 5.0000 5.0000 8; -1.0000 3.5000 3; -10.0000 2.0000 -1; 10.0000 -2.0000 -1][squared_distances_to_segments I] = csmv(P,R,Q,1);

 Requirements: No special requirements Platforms: Matlab Keyword: And 3d,  Are The,  Array,  Arrays,  As An,  Be An,  Be No,  Calculated,  Calculates Distances,  Default,  Defined,  Greater,  Mbyp,  Nbym,  Nbyp,  Nonzero,  Points,  Undirected Users rating: 0/10        