26 #if defined (HAVE_CONFIG_H)
38 inline double max (
double a,
double b,
double c)
41 return (b < c ? c : b);
43 return (a < c ? c : a);
46 inline double min (
double a,
double b,
double c)
49 return (b > c ? c : b);
51 return (a > c ? c : a);
54 #define REF(x,k,i) x(static_cast<octave_idx_type> (elem((k), (i))) - 1)
64 DEFUN (tsearch, args, ,
75 if (args.length () != 5)
78 const double eps = 1.0e-12;
103 double x0, y0, a11, a12, a21, a22, det;
105 a11 = a12 = a21 = a22 = 0.0;
111 const double xt =
xi(kp);
112 const double yt = yi(kp);
117 const double dx1 = xt - x0;
118 const double dx2 = yt - y0;
119 const double c1 = (a22 * dx1 - a21 * dx2) / det;
120 const double c2 = (-a12 * dx1 + a11 * dx2) / det;
121 if (c1 >= -
eps && c2 >= -
eps && (c1 + c2) <= (1 +
eps))
123 values(kp) = double(k+1);
129 for (k = 0; k < nelem; k++)
133 if (xt >= minx(k) && xt <= maxx(k) && yt >= miny(k) && yt <= maxy(k))
138 a11 =
REF (
x, k, 1) - x0;
139 a12 =
REF (y, k, 1) - y0;
140 a21 =
REF (
x, k, 2) - x0;
141 a22 =
REF (y, k, 2) - y0;
142 det = a11 * a22 - a21 * a12;
145 const double dx1 = xt - x0;
146 const double dx2 = yt - y0;
147 const double c1 = (a22 * dx1 - a21 * dx2) / det;
148 const double c2 = (-a12 * dx1 + a11 * dx2) / det;
149 if ((c1 >= -
eps) && (c2 >= -
eps) && ((c1 + c2) <= (1 +
eps)))
151 values(kp) = double(k+1);
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
double lo_ieee_nan_value(void)
F77_RET_T const F77_DBLE * x
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
static const double xi[33]
double min(double a, double b, double c)
double max(double a, double b, double c)