No BSD License  

Highlights from
Project a planar polyline on another polyline

2.0

2.0 | 2 ratings Rate this file 1 Download (last 30 days) File Size: 12.5 KB File ID: #24090

Project a planar polyline on another polyline

by Michael Yoshpe

 

12 May 2009 (Updated 13 May 2009)

Find a projection of a cartesian polyline on another polyline.

| Watch this File

File Information
Description

%poly_poly_proj Project a planar polyline on another polyline.
%*******************************************************************************
% function: poly_poly_proj
% Description: Compute the distances (cross-ranges) from a set of points
% P <p(1), p(2), ..., p(m)> on a plane to the planar polyline
% V <v(1), v(2), ..., v(n)>, and the distances (ranges) from the
% projections of P on V to the first point of a segment containing
% the projected point. Planar polyline V is defined as a set of n-1
% segments connecting n ordered vertices v(1), v(2), ..., v(n) on a
% plane.
% In case when the shortest distance is to the vertex of the
% polyline (see p(2) in the picture below), the cross range
% cr(2) will be the distance to the vertex and the range will be
% the length of this segment (segment # 3)
%
% p(1)
% o p(m)
% | o
% cr(1)-> | p(k) /
% | o / <- cr(m)
% v(1) v(2) | cr(k)-> | /
% x---x | | v(n)/
% \ | x-->|--------x <- r(m) = 0
% \ | v(3) / r(k)
% v(3) x->|--------x r(2)
% |->| \ <-cr(2)
% r(1) \
% o p(2)
% Input:
% xp - x coordinates of the first polyline (vector of length m)
% yp - y coordinates of the first polyline (vector of length m)
% xv - x coordinates of the second polyline (vector of length n)
% yv - y coordinates of the second polyline (vector of length n)
% Output:
% rpv - vector (of length m) of distances (ranges) from the projections on
% the second polyline to the beginnings of the segments containing
% these projections
% crpv - vector (of length m) of distances (cross-ranges) from points of the
% first polyline (P) to a second polyline (V), defined as a minimal
% distance from each point of the first polyline to any segment of a
% second polyline. Note that cr is a signed value! The sign of
% cross range is determined using a local coordinate system, where
% X axis is along the rib k, from point v(k) to v(k+1), Z axis is
% out of plane, and Y axis completes the right-hand system. The
% sign of projected point's p(j) y coordinate will determine the
% cross-range sign for this point.
% y
% ^
% | o p(j)
% | /|
% | / | <- cr > 0
% |/ |
% x---|-------x--------------> x
% v(k) v(k+1)
% spv - total projected path length. Can be negative, if P and V are in the
% opposite directions
% xppv - vector of x coordinates of the first polyline projections on the
% second polyline
% yppv - vector of y coordinates of the first polyline projections on the
% second polyline
% jppv - indices of the first points in segments containing the projections
% (vector of length m). In the abovementioned example, this vector
% should be jpv = [2, 4, 5, 6]. Note that the shortest distances
% of points p(1), p(2) and p(4) are not to the second polyline's
% ribs, but to the verices.
% Routines:
% Revision history:
% 12/05/2009 - added dimension parameter to cross function-Michael Yoshpe
% 26/11/2008 - created by Michael Yoshpe
% Remarks:
% Based on routine p_poly_dist that computed the distance from point to
% polygon
%*******************************************************************************

MATLAB release MATLAB 6.5.1 (R13SP1)
Tags for This File  
Everyone's Tags
cross range, geometric transformation, image registration, polyline, projection, range
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
29 Sep 2009 Chamane

interesting function

13 May 2009 Darren Rowland

This function is as bloated and confusing as the above description. There is just too much going on. An example of use would really help, perhaps included in a published HTML page. I really doubt that anyone can use the file as it is.

Updates
13 May 2009

Added usage example at the end of the header

Contact us