Home > matGeom > polygons2d > geod2cart.m

geod2cart

PURPOSE ^

GEOD2CART Convert geodesic coordinates to cartesian coord.

SYNOPSIS ^

function point = geod2cart(src, curve, normal)

DESCRIPTION ^

GEOD2CART Convert geodesic coordinates to cartesian coord.

   PT2 = geod2cart(PT1, CURVE, NORMAL)
   CURVE and NORMAL are both [N*2] array with the same length, and
   represent positions of the curve, and normal to each point.
   PT1 is the point to transform, in geodesic  coordinate (first coord is
   distance from the curve start, and second coord is distance between
   point and curve).

   The function return the coordinate of PT1 in the same coordinate system
   than for the curve.

   See also
   polylines2d, cart2geod, curveLength

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function point = geod2cart(src, curve, normal)
0002 %GEOD2CART Convert geodesic coordinates to cartesian coord.
0003 %
0004 %   PT2 = geod2cart(PT1, CURVE, NORMAL)
0005 %   CURVE and NORMAL are both [N*2] array with the same length, and
0006 %   represent positions of the curve, and normal to each point.
0007 %   PT1 is the point to transform, in geodesic  coordinate (first coord is
0008 %   distance from the curve start, and second coord is distance between
0009 %   point and curve).
0010 %
0011 %   The function return the coordinate of PT1 in the same coordinate system
0012 %   than for the curve.
0013 %
0014 %   See also
0015 %   polylines2d, cart2geod, curveLength
0016 
0017 % ------
0018 % Author: David Legland
0019 % E-mail: david.legland@inrae.fr
0020 % Created: 2004-04-08
0021 % Copyright 2004-2024 INRA - TPV URPOI - BIA IMASTE
0022 
0023 t = parametrize(curve);
0024 N = size(src, 1);
0025 ind = zeros(N, 1);
0026 for i = 1:N
0027     indices = find(t >= src(i,1));
0028     if ~isempty(indices)
0029         ind(i) = indices(1);
0030     else
0031         ind(i) = 1;
0032     end
0033 end
0034 
0035 theta = lineAngle([zeros(N,2) normal(ind,:)]);
0036 d = src(:,2);
0037 point = [curve(ind,1)+d.*cos(theta), curve(ind,2)+d.*sin(theta)];

Generated on Thu 21-Nov-2024 11:30:22 by m2html © 2003-2022