Home > matGeom > polygons2d > cart2geod.m

cart2geod

PURPOSE ^

CART2GEOD Convert cartesian coordinates to geodesic coord.

SYNOPSIS ^

function point = cart2geod(src, curve)

DESCRIPTION ^

CART2GEOD Convert cartesian coordinates to geodesic coord.

   PT2 = cart2geod(PT1, CURVE)
   PT1 is the point to transform, in Cartesian coordinates (same system
   used for the curve).
   CURVE is a N-by-2 array which represents coordinates of curve vertices.

   The function first compute the projection of PT1 on the curve. Then,
   the first geodesic coordinate is the length of the curve to the
   projected point, and the second geodesic coordinate is the 
   distance between PT1 and it projection.


   TODO : add processing of points not projected on the curve.
   -> use the closest end 

   See also
   polylines2d, geod2cart, curveLength

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function point = cart2geod(src, curve)
0002 %CART2GEOD Convert cartesian coordinates to geodesic coord.
0003 %
0004 %   PT2 = cart2geod(PT1, CURVE)
0005 %   PT1 is the point to transform, in Cartesian coordinates (same system
0006 %   used for the curve).
0007 %   CURVE is a N-by-2 array which represents coordinates of curve vertices.
0008 %
0009 %   The function first compute the projection of PT1 on the curve. Then,
0010 %   the first geodesic coordinate is the length of the curve to the
0011 %   projected point, and the second geodesic coordinate is the
0012 %   distance between PT1 and it projection.
0013 %
0014 %
0015 %   TODO : add processing of points not projected on the curve.
0016 %   -> use the closest end
0017 %
0018 %   See also
0019 %   polylines2d, geod2cart, curveLength
0020 %
0021 
0022 % ---------
0023 % Author: David Legland
0024 % e-mail: david.legland@grignon.inra.fr
0025 % created the 08/04/2004.
0026 % Copyright 2010 INRA - Cepia Software Platform.
0027 
0028 %   HISTORY
0029 %   15/02/2007 replace minDistance by minDistancePoints
0030 
0031 
0032 % parametrization approximation
0033 t = parametrize(curve);
0034 
0035 % compute distance between each src point and the curve
0036 [dist, ind] = minDistancePoints(src, curve);
0037 
0038 % convert to 'geodesic' coordinate
0039 point = [t(ind) dist];
0040 
0041 % Old version:
0042 % for i=1:size(pt1, 1)
0043 %     [dist, ind] = minDistance(src(i,:), curve);
0044 %     point(i,:) = [t(ind) dist];
0045 % end

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019