changeset 10060:5d6178e77d0c octave-forge

geometry: fixing details
author jpicarbajal
date Mon, 16 Apr 2012 11:24:26 +0000
parents c9c23706fe3d
children e6f222a04277
files main/geometry/inst/geom2d/distancePointEdge.m main/geometry/inst/shape2d/shape2polygon.m main/geometry/inst/shape2d/shapecentroid.m main/geometry/inst/shape2d/shapeplot.m main/geometry/inst/shape2d/shapetransform.m
diffstat 5 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/main/geometry/inst/geom2d/distancePointEdge.m	Mon Apr 16 10:39:05 2012 +0000
+++ b/main/geometry/inst/geom2d/distancePointEdge.m	Mon Apr 16 11:24:26 2012 +0000
@@ -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;
--- a/main/geometry/inst/shape2d/shape2polygon.m	Mon Apr 16 10:39:05 2012 +0000
+++ b/main/geometry/inst/shape2d/shape2polygon.m	Mon Apr 16 11:24:26 2012 +0000
@@ -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);
 %!
--- a/main/geometry/inst/shape2d/shapecentroid.m	Mon Apr 16 10:39:05 2012 +0000
+++ b/main/geometry/inst/shape2d/shapecentroid.m	Mon Apr 16 11:24:26 2012 +0000
@@ -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;');
--- a/main/geometry/inst/shape2d/shapeplot.m	Mon Apr 16 10:39:05 2012 +0000
+++ b/main/geometry/inst/shape2d/shapeplot.m	Mon Apr 16 11:24:26 2012 +0000
@@ -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{:});
 
--- a/main/geometry/inst/shape2d/shapetransform.m	Mon Apr 16 10:39:05 2012 +0000
+++ b/main/geometry/inst/shape2d/shapetransform.m	Mon Apr 16 11:24:26 2012 +0000
@@ -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
-
-