CENTEREDEDGETOEDGE Convert a centered edge to a two-points edge. EDGE = centeredEdgeToEdge(CEDGE) Converts an edge represented using center, length and orientation to an edge represented using coordinates of end points. Example % example of conversion on a 'pythagorean' edge cedge = [30 40 50 atand(3/4)]; centeredEdgeToEdge(cedge) ans = 10 25 50 55 See also edges2d, drawCenteredEdge, drawOrientedBox ------ Author: David Legland e-mail: david.legland@grignon.inra.fr Created: 2012-07-31, using Matlab 7.9.0.529 (R2009b) Copyright 2012 INRA - Cepia Software Platform.
0001 function edge = centeredEdgeToEdge(cedge) 0002 %CENTEREDEDGETOEDGE Convert a centered edge to a two-points edge. 0003 % 0004 % EDGE = centeredEdgeToEdge(CEDGE) 0005 % Converts an edge represented using center, length and orientation to an 0006 % edge represented using coordinates of end points. 0007 % 0008 % Example 0009 % % example of conversion on a 'pythagorean' edge 0010 % cedge = [30 40 50 atand(3/4)]; 0011 % centeredEdgeToEdge(cedge) 0012 % ans = 0013 % 10 25 50 55 0014 % 0015 % 0016 % See also 0017 % edges2d, drawCenteredEdge, drawOrientedBox 0018 % 0019 % ------ 0020 % Author: David Legland 0021 % e-mail: david.legland@grignon.inra.fr 0022 % Created: 2012-07-31, using Matlab 7.9.0.529 (R2009b) 0023 % Copyright 2012 INRA - Cepia Software Platform. 0024 0025 % length and orientation 0026 len = cedge(:,3); 0027 ori = cedge(:,4); 0028 0029 % x and y shifts around center 0030 dx = len * cosd(ori) / 2; 0031 dy = len * sind(ori) / 2; 0032 0033 % coordinates of extremities 0034 edge = [cedge(:,1:2)-[dx dy] cedge(:,1:2)+[dx dy]];