comparison scripts/geometry/delaunayn.m @ 7795:df9519e9990c

Handle single precision eps values
author David Bateman <dbateman@free.fr>
date Mon, 12 May 2008 22:57:11 +0200
parents a730e47fda4d
children eb63fbe60fab
comparison
equal deleted inserted replaced
7794:2b458dfe31ae 7795:df9519e9990c
52 print_usage (); 52 print_usage ();
53 endif 53 endif
54 54
55 t = __delaunayn__ (x, varargin{:}); 55 t = __delaunayn__ (x, varargin{:});
56 56
57 if (isa (x, "single"))
58 myeps = eps ("single");
59 else
60 myeps = eps;
61 endif
62
57 ## Try to remove the zero volume simplices. The volume of the i-th simplex is 63 ## Try to remove the zero volume simplices. The volume of the i-th simplex is
58 ## given by abs(det(x(t(i,1:end-1),:)-x(t(i,2:end),:)))/prod(1:n) 64 ## given by abs(det(x(t(i,1:end-1),:)-x(t(i,2:end),:)))/prod(1:n)
59 ## (reference http://en.wikipedia.org/wiki/Simplex). Any simplex with a 65 ## (reference http://en.wikipedia.org/wiki/Simplex). Any simplex with a
60 ## relative volume less than some arbitrary criteria is rejected. The 66 ## relative volume less than some arbitrary criteria is rejected. The
61 ## criteria we use is the volume of the simplex corresponding to an 67 ## criteria we use is the volume of the simplex corresponding to an
65 ## prod(1:n) is dropped. 71 ## prod(1:n) is dropped.
66 idx = []; 72 idx = [];
67 [nt, n] = size (t); 73 [nt, n] = size (t);
68 for i = 1:nt 74 for i = 1:nt
69 X = x(t(i,1:end-1),:) - x(t(i,2:end),:); 75 X = x(t(i,1:end-1),:) - x(t(i,2:end),:);
70 if (abs (det (X)) / sqrt (sum (X .^ 2, 2)) < 1e3 * eps) 76 if (abs (det (X)) / sqrt (sum (X .^ 2, 2)) < 1e3 * myeps)
71 idx = [idx, i]; 77 idx = [idx, i];
72 endif 78 endif
73 endfor 79 endfor
74 t(idx,:) = []; 80 t(idx,:) = [];
75 endfunction 81 endfunction