Mercurial > octave-nkf
comparison scripts/geometry/inpolygon.m @ 10549:95c3e38098bf
Untabify .m scripts
author | Rik <code@nomad.inbox5.com> |
---|---|
date | Fri, 23 Apr 2010 11:28:50 -0700 |
parents | 1bf0ce0930be |
children | c776f063fefe |
comparison
equal
deleted
inserted
replaced
10548:479536c5bb10 | 10549:95c3e38098bf |
---|---|
42 if (nargin != 4) | 42 if (nargin != 4) |
43 print_usage (); | 43 print_usage (); |
44 endif | 44 endif |
45 | 45 |
46 if (! (isreal (X) && isreal (Y) && ismatrix (Y) && ismatrix (Y) | 46 if (! (isreal (X) && isreal (Y) && ismatrix (Y) && ismatrix (Y) |
47 && size_equal (X, Y))) | 47 && size_equal (X, Y))) |
48 error ("inpolygon: first two arguments must be real matrices of same size"); | 48 error ("inpolygon: first two arguments must be real matrices of same size"); |
49 elseif (! (isreal (xv) && isreal (yv) && isvector (xv) && isvector (yv) | 49 elseif (! (isreal (xv) && isreal (yv) && isvector (xv) && isvector (yv) |
50 && size_equal (xv, yv))) | 50 && size_equal (xv, yv))) |
51 error ("inpolygon: last two arguments must be real vectors of same size"); | 51 error ("inpolygon: last two arguments must be real vectors of same size"); |
52 endif | 52 endif |
53 | 53 |
54 npol = length (xv); | 54 npol = length (xv); |
55 do_boundary = (nargout >= 2); | 55 do_boundary = (nargout >= 2); |
67 distance = delta_xv .* (Y - yv(i)) - (X - xv(i)) .* delta_yv; | 67 distance = delta_xv .* (Y - yv(i)) - (X - xv(i)) .* delta_yv; |
68 ## | 68 ## |
69 ## is Y between the y-values of edge i,j | 69 ## is Y between the y-values of edge i,j |
70 ## AND (X,Y) on the left of the edge ? | 70 ## AND (X,Y) on the left of the edge ? |
71 idx1 = (((yv(i) <= Y & Y < yv(j)) | (yv(j) <= Y & Y < yv(i))) | 71 idx1 = (((yv(i) <= Y & Y < yv(j)) | (yv(j) <= Y & Y < yv(i))) |
72 & 0 < distance.*delta_yv); | 72 & 0 < distance.*delta_yv); |
73 IN (idx1) = !IN (idx1); | 73 IN (idx1) = !IN (idx1); |
74 | 74 |
75 ## Check if (X,Y) are actually ON the boundary of the polygon. | 75 ## Check if (X,Y) are actually ON the boundary of the polygon. |
76 if (do_boundary) | 76 if (do_boundary) |
77 idx2 = (((yv(i) <= Y & Y <= yv(j)) | (yv(j) <= Y & Y <= yv(i))) | 77 idx2 = (((yv(i) <= Y & Y <= yv(j)) | (yv(j) <= Y & Y <= yv(i))) |
78 & ((xv(i) <= X & X <= xv(j)) | (xv(j) <= X & X <= xv(i))) | 78 & ((xv(i) <= X & X <= xv(j)) | (xv(j) <= X & X <= xv(i))) |
79 & (0 == distance | !delta_xv)); | 79 & (0 == distance | !delta_xv)); |
80 ON (idx2) = true; | 80 ON (idx2) = true; |
81 endif | 81 endif |
82 j = i; | 82 j = i; |
83 endfor | 83 endfor |
84 | 84 |