36 inline double max (
double a,
double b,
double c)
39 return (b < c ? c : b);
41 return (a < c ? c : a);
44 inline double min (
double a,
double b,
double c)
47 return (b > c ? c : b);
49 return (a > c ? c : a);
52 #define REF(x,k,i) x(static_cast<octave_idx_type>(elem((k), (i))) - 1)
62 DEFUN (tsearch, args, ,
64 @deftypefn {Built-in Function} {@var{idx} =} tsearch (@var{x}, @var{y}, @var{t}, @var{xi}, @var{yi})\n\
65 Search for the enclosing Delaunay convex hull.\n\
67 For @code{@var{t} = delaunay (@var{x}, @var{y})}, finds the index in @var{t}\n\
68 containing the points @code{(@var{xi}, @var{yi})}. For points outside the\n\
69 convex hull, @var{idx} is NaN.\n\
70 @seealso{delaunay, delaunayn}\n\
73 const double eps=1.0e-12;
76 const int nargin = args.
length ();
109 double x0, y0, a11, a12, a21, a22, det;
111 a11 = a12 = a21 = a22 = 0.0;
117 const double xt =
xi(kp);
118 const double yt = yi(kp);
123 const double dx1 = xt - x0;
124 const double dx2 = yt - y0;
125 const double c1 = (a22 * dx1 - a21 * dx2) / det;
126 const double c2 = (-a12 * dx1 + a11 * dx2) / det;
127 if (c1 >= -eps && c2 >= -eps && (c1 + c2) <= (1 +
eps))
135 for (k = 0; k < nelem; k++)
138 if (xt >= minx(k) && xt <= maxx(k) && yt >= miny(k) && yt <= maxy(k))
143 a11 =
REF (x, k, 1) - x0;
144 a12 =
REF (y, k, 1) - y0;
145 a21 =
REF (x, k, 2) - x0;
146 a22 =
REF (y, k, 2) - y0;
147 det = a11 * a22 - a21 * a12;
150 const double dx1 = xt - x0;
151 const double dx2 = yt - y0;
152 const double c1 = (a22 * dx1 - a21 * dx2) / det;
153 const double c2 = (-a12 * dx1 + a11 * dx2) / det;
154 if ((c1 >= -eps) && (c2 >= -
eps) && ((c1 + c2) <= (1 +
eps)))
OCTINTERP_API void print_usage(void)
octave_idx_type length(void) const
#define DEFUN(name, args_name, nargout_name, doc)
double lo_ieee_nan_value(void)
double max(double a, double b, double c)
octave_idx_type rows(void) const
double min(double a, double b, double c)
octave_idx_type length(void) const
Number of elements in the array.
static MArray< double > const octave_idx_type const octave_idx_type octave_idx_type octave_idx_type octave_idx_type c1
static const double xi[33]
F77_RET_T const double * x