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
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 % E-mail: david.legland@inrae.fr 0016 % Created: 2005-01-19 0017 % Copyright 2005-2024 INRA - TPV URPOI - BIA IMASTE 0018 0019 % extract line parameters 0020 x0 = line(:,1); 0021 y0 = line(:,2); 0022 dx = line(:,3); 0023 dy = line(:,4); 0024 0025 % normalisation coefficient of line direction vector 0026 delta = dx*dx + dy*dy; 0027 0028 % compute coefficients of transform 0029 m00 = (dx*dx - dy*dy)/delta; 0030 m01 = 2*dx*dy/delta; 0031 m02 = 2*dy*(dy*x0 - dx*y0)/delta; 0032 m10 = 2*dx*dy/delta; 0033 m11 = (dy*dy - dx*dx)/delta; 0034 m12 = 2*dx*(dx*y0 - dy*x0)/delta; 0035 0036 % create transformation 0037 trans = [m00 m01 m02; m10 m11 m12; 0 0 1];