SUPPORTFUNCTION Compute support function of a polygon. H = supportFunction(POLYGON, N) uses N points for suport function approximation H = supportFunction(POLYGON) assume 24 points for approximation H = supportFunction(POLYGON, V) where V is a vector, uses vector V of angles to compute support function. See also: polygons2d, convexification --------- author : David Legland INRA - TPV URPOI - BIA IMASTE created the 20/12/2004.
0001 function h = supportFunction(polygon, varargin) 0002 %SUPPORTFUNCTION Compute support function of a polygon. 0003 % 0004 % H = supportFunction(POLYGON, N) 0005 % uses N points for suport function approximation 0006 % 0007 % H = supportFunction(POLYGON) 0008 % assume 24 points for approximation 0009 % 0010 % H = supportFunction(POLYGON, V) 0011 % where V is a vector, uses vector V of angles to compute support 0012 % function. 0013 % 0014 % See also: 0015 % polygons2d, convexification 0016 % 0017 % --------- 0018 % author : David Legland 0019 % INRA - TPV URPOI - BIA IMASTE 0020 % created the 20/12/2004. 0021 % 0022 0023 N = 24; 0024 u = 0:2*pi/N:2*pi*(1-1/N); 0025 0026 if length(varargin)==1 0027 var = varargin{1}; 0028 if length(var)==1 0029 N = var; 0030 u = 0:2*pi/N:2*pi*(1-1/N); 0031 else 0032 u = var; 0033 end 0034 end 0035 0036 % ensure u vertical vector 0037 if size(u, 1)==1 0038 u=u'; 0039 end 0040 0041 0042 h = zeros(size(u)); 0043 0044 for i=1:length(u) 0045 0046 v = repmat([cos(u(i)) sin(u(i))], [size(polygon, 1), 1]); 0047 0048 h(i) = max(dot(polygon, v, 2)); 0049 end