CREATELINEREFLECTION Create the the 3x3 matrix of a line reflection. TRANS = createLineReflection(LINE); where line is given as [x0 y0 dx dy], return the affine tansform corresponding to the desired line reflection See also: lines2d, transforms2d, transformPoint, createTranslation, createHomothecy, createScaling --------- author : David Legland INRA - TPV URPOI - BIA IMASTE created the 19/01/2005.
0001 function trans = createLineReflection(line) 0002 %CREATELINEREFLECTION Create the the 3x3 matrix of a line reflection. 0003 % 0004 % TRANS = createLineReflection(LINE); 0005 % where line is given as [x0 y0 dx dy], return the affine tansform 0006 % corresponding to the desired line reflection 0007 % 0008 % 0009 % See also: 0010 % lines2d, transforms2d, transformPoint, 0011 % createTranslation, createHomothecy, createScaling 0012 % 0013 % --------- 0014 % author : David Legland 0015 % INRA - TPV URPOI - BIA IMASTE 0016 % created the 19/01/2005. 0017 % 0018 0019 % HISTORY 0020 % 22/04/2009: rename as createLineReflection 0021 0022 % extract line parameters 0023 x0 = line(:,1); 0024 y0 = line(:,2); 0025 dx = line(:,3); 0026 dy = line(:,4); 0027 0028 % normalisation coefficient of line direction vector 0029 delta = dx*dx + dy*dy; 0030 0031 % compute coefficients of transform 0032 m00 = (dx*dx - dy*dy)/delta; 0033 m01 = 2*dx*dy/delta; 0034 m02 = 2*dy*(dy*x0 - dx*y0)/delta; 0035 m10 = 2*dx*dy/delta; 0036 m11 = (dy*dy - dx*dx)/delta; 0037 m12 = 2*dx*(dx*y0 - dy*x0)/delta; 0038 0039 % create transformation 0040 trans = [m00 m01 m02; m10 m11 m12; 0 0 1];