From: <jpi...@us...> - 2012-04-16 11:24:35
|
Revision: 10246 http://octave.svn.sourceforge.net/octave/?rev=10246&view=rev Author: jpicarbajal Date: 2012-04-16 11:24:26 +0000 (Mon, 16 Apr 2012) Log Message: ----------- geometry: fixing details Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/geom2d/distancePointEdge.m trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m Modified: trunk/octave-forge/main/geometry/inst/geom2d/distancePointEdge.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/distancePointEdge.m 2012-04-16 10:39:05 UTC (rev 10245) +++ trunk/octave-forge/main/geometry/inst/geom2d/distancePointEdge.m 2012-04-16 11:24:26 UTC (rev 10246) @@ -76,9 +76,11 @@ % (Size of tp is the max number of edges or points) delta = dx .* dx + dy .* dy; + mask = delta < eps; + delta(mask) = 1; warning ('off', 'Octave:broadcast'); tp = ((point(:, 1) - edge(1, :)) .* dx + (point(:, 2) - edge(2, :)) .* dy) ./ delta; - tp(:,delta < eps) = 0; + tp(:,mask) = 0; % change position to ensure projected point is located on the edge tp(tp < 0) = 0; Modified: trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2012-04-16 10:39:05 UTC (rev 10245) +++ trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2012-04-16 11:24:26 UTC (rev 10246) @@ -54,7 +54,7 @@ %! 58.870 -38.083 -89.358 232.362]}; %! %! % Estimate a good tolerance -%! n = cell2mat(cellfun(@(x)curveval(x,[0 1]), shape, 'uniformoutput',false)); +%! n = cell2mat(cellfun(@(x)curveval(x,rand(1,10)), shape, 'uniformoutput',false)); %! dr = (max(n(:,1))-min(n(:,1)))*(max(n(:,2))-min(n(:,2)))*40; %! p = shape2polygon (shape,'tol',dr); %! Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-04-16 10:39:05 UTC (rev 10245) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-04-16 11:24:26 UTC (rev 10246) @@ -66,9 +66,8 @@ %! 0 0]}; %! CoM = shapecentroid (boomerang) %! Gcentroid = centroid(shape2polygon(boomerang)) -%! %! figure(1); clf; -%! shapeplot(boomerang,10,'-o'); +%! shapeplot(boomerang,'-o'); %! hold on %! drawPoint(CoM,'xk;shape centroid;'); %! drawPoint(Gcentroid,'xr;point centroid;'); @@ -85,7 +84,7 @@ %! CoM = shapecentroid (Lshape) %! Gcentroid = centroid (shape2polygon (Lshape)) %! -%! shapeplot(Lshape,10,'-o'); +%! shapeplot(Lshape,'-o'); %! hold on %! drawPoint(CoM,'xk;shape centroid;'); %! drawPoint(Gcentroid,'xr;point centroid;'); Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m 2012-04-16 10:39:05 UTC (rev 10245) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m 2012-04-16 11:24:26 UTC (rev 10246) @@ -29,8 +29,8 @@ function h = shapeplot(shape, varargin) - n = cell2mat(cellfun(@(x)curveval(x,[0 1]), shape, 'uniformoutput',false)); - dr = (max(n(:,1))-min(n(:,1)))*(max(n(:,2))-min(n(:,2)))/10; + n = cell2mat(cellfun(@(x)curveval(x,rand(1,5)), shape, 'uniformoutput',false)); + dr = (max(n(:,1))-min(n(:,1)))*(max(n(:,2))-min(n(:,2)))/100; p = shape2polygon(shape,'tol', dr); h = drawPolygon(p,varargin{:}); Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2012-04-16 10:39:05 UTC (rev 10245) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2012-04-16 11:24:26 UTC (rev 10246) @@ -98,14 +98,12 @@ %! shape = shapetransform (shape,-T + [2; 0]); %! %! close -%! shapeplot (shape,10,'-r','linewidth',2) +%! shapeplot (shape,'-r','linewidth',2) %! hold on %! for i = 1:9 %! T = createRotation (i*pi/5)(1:2,1:2)/exp(0.3*i); -%! shapeplot (shapetransform(shape, T), 10, 'color',rand(1,3),'linewidth',2); +%! shapeplot (shapetransform(shape, T), 'color',rand(1,3),'linewidth',2); %! end %! hold off %! axis tight %! axis square - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |