Mercurial > hg > octave-terminal
changeset 9496:079c06f37f17
optimize griddata
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 06 Aug 2009 07:56:18 +0200 |
parents | 0a427d3244bf |
children | 54ae52abd4c9 |
files | scripts/ChangeLog scripts/geometry/griddata.m |
diffstat | 2 files changed, 19 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2009-08-06 Jaroslav Hajek <highegg@gmail.com> + + * geometry/griddata.m: Optimize. + 2009-08-06 Olaf Till <olaf.till@uni-jena.de> * geometry/griddata.m: Linearize arrays.
--- a/scripts/geometry/griddata.m +++ b/scripts/geometry/griddata.m @@ -83,27 +83,29 @@ tri_list = tsearch (x, y, tri, xi(:), yi(:)); ## Only keep the points within triangles. - valid = !isnan (reshape (tri_list, size (xi))); - tri_list = tri_list(!isnan (tri_list)); + valid = !isnan (tri_list); + tri_list = tri_list(valid); nr_t = rows (tri_list); + tri = tri(tri_list,:); + ## Assign x,y,z for each point of triangle. - x1 = x(tri(tri_list,1)); - x2 = x(tri(tri_list,2)); - x3 = x(tri(tri_list,3)); + x1 = x(tri(:,1)); + x2 = x(tri(:,2)); + x3 = x(tri(:,3)); - y1 = y(tri(tri_list,1)); - y2 = y(tri(tri_list,2)); - y3 = y(tri(tri_list,3)); + y1 = y(tri(:,1)); + y2 = y(tri(:,2)); + y3 = y(tri(:,3)); - z1 = z(tri(tri_list,1)); - z2 = z(tri(tri_list,2)); - z3 = z(tri(tri_list,3)); + z1 = z(tri(:,1)); + z2 = z(tri(:,2)); + z3 = z(tri(:,3)); ## Calculate norm vector. N = cross ([x2-x1, y2-y1, z2-z1], [x3-x1, y3-y1, z3-z1]); - N_norm = sqrt (sumsq (N, 2)); - N = N ./ N_norm(:,[1,1,1]); + ## Normalize. + N = diag (norm (N, "rows")) \ N; ## Calculate D of plane equation ## Ax+By+Cz+D = 0;