Home > matGeom > geom2d > createHomothecy.m

createHomothecy

PURPOSE ^

CREATEHOMOTHECY Create the the 3x3 matrix of an homothetic transform.

SYNOPSIS ^

function T = createHomothecy(point, ratio)

DESCRIPTION ^

CREATEHOMOTHECY Create the the 3x3 matrix of an homothetic transform.

   TRANS = createHomothecy(POINT, K);
   POINT is the center of the homothecy, K is its factor.
   TRANS is a 3-by-3 matrix representing the homothetic transform in
   homogeneous coordinates.

   Example:

      p  = [0 0; 1 0; 0 1];
      s  = [-0.5 0.4];
      T  = createHomothecy (s, 1.5);
      pT = transformPoint (p, T);
      drawPolygon (p,'-b')
      hold on;
      drawPolygon (pT, '-r');
      
      drawEdge (p(:,1), p(:,2), pT(:,1), pT(:,2), ...
                'color', 'k','linestyle','--')
      hold off
      axis tight equal

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function T = createHomothecy(point, ratio)
0002 %CREATEHOMOTHECY Create the the 3x3 matrix of an homothetic transform.
0003 %
0004 %   TRANS = createHomothecy(POINT, K);
0005 %   POINT is the center of the homothecy, K is its factor.
0006 %   TRANS is a 3-by-3 matrix representing the homothetic transform in
0007 %   homogeneous coordinates.
0008 %
0009 %   Example:
0010 %
0011 %      p  = [0 0; 1 0; 0 1];
0012 %      s  = [-0.5 0.4];
0013 %      T  = createHomothecy (s, 1.5);
0014 %      pT = transformPoint (p, T);
0015 %      drawPolygon (p,'-b')
0016 %      hold on;
0017 %      drawPolygon (pT, '-r');
0018 %
0019 %      drawEdge (p(:,1), p(:,2), pT(:,1), pT(:,2), ...
0020 %                'color', 'k','linestyle','--')
0021 %      hold off
0022 %      axis tight equal
0023 %
0024 
0025 % ---------
0026 % Author: David Legland
0027 % e-mail: david.legland@inra.fr
0028 % INRA - TPV URPOI - BIA IMASTE
0029 % created the 20/01/2005.
0030 
0031 
0032 %   HISTORY
0033 %   22/04/2009: rename as createHomothecy
0034 %   05/04/2017: improved code by JuanPi Carbajal <ajuanpi+dev@gmail.com>
0035 
0036 point = point(:);
0037 if length (point) > 2
0038     error('Only one point accepted.');
0039 end
0040 if length (ratio) > 1
0041     error('Only one ratio accepted.');
0042 end
0043 
0044 T        = diag ([ratio ratio 1]);
0045 T(1:2,3) = point .* (1 - ratio);

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019