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. TODO : add processing of points not projected on the curve. -> use the closest end See also polylines2d, cart2geod, curveLength --------- author : David Legland INRA - TPV URPOI - BIA IMASTE created the 08/04/2004.
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 % TODO : add processing of points not projected on the curve. 0015 % -> use the closest end 0016 % 0017 % See also 0018 % polylines2d, cart2geod, curveLength 0019 % 0020 % --------- 0021 % author : David Legland 0022 % INRA - TPV URPOI - BIA IMASTE 0023 % created the 08/04/2004. 0024 % 0025 0026 t = parametrize(curve); 0027 N = size(src, 1); 0028 ind = zeros(N, 1); 0029 for i=1:N 0030 indices = find(t>=src(i,1)); 0031 ind(i) = indices(1); 0032 end 0033 0034 theta = lineAngle([zeros(N,1) zeros(N,1) normal(ind,:)]); 0035 d = src(:,2); 0036 point = [curve(ind,1)+d.*cos(theta), curve(ind,2)+d.*sin(theta)];