26 #if defined (HAVE_CONFIG_H)
41 max (
double a,
double b,
double c)
43 return (a > b) ? (a > c ? a : c) : (b > c ? b : c);
47 min (
double a,
double b,
double c)
49 return (a < b) ? (a < c ? a : c) : (b < c ? b : c);
52 #define REF(x,k,i) x(static_cast<octave_idx_type> (elem((k), (i))) - 1)
62 DEFUN (tsearch, args, ,
73 if (args.length () != 5)
76 const double eps = 1.0e-12;
80 const Matrix elem (args(2).matrix_value ());
101 double x0 = 0.0, y0 = 0.0;
102 double a11 = 0.0, a12 = 0.0, a21 = 0.0, a22 = 0.0, det = 0.0;
103 double xt = 0.0, yt = 0.0;
104 double dx1 = 0.0, dx2 = 0.0, c1 = 0.0, c2 = 0.0;
121 c1 = (a22 * dx1 - a21 * dx2) / det;
122 c2 = (-a12 * dx1 + a11 * dx2) / det;
123 if (c1 >= -
eps && c2 >= -
eps && (c1 + c2) <= 1 +
eps)
131 for (k = 0; k < nelem; k++)
133 if (xt >= minx(k) && xt <= maxx(k) && yt >= miny(k) && yt <= maxy(k))
139 a11 =
REF (
x, k, 1) - x0;
140 a12 =
REF (y, k, 1) - y0;
141 a21 =
REF (
x, k, 2) - x0;
142 a22 =
REF (y, k, 2) - y0;
143 det = a11 * a22 - a21 * a12;
148 c1 = (a22 * dx1 - a21 * dx2) / det;
149 c2 = (-a12 * dx1 + a11 * dx2) / det;
150 if (c1 >= -
eps && c2 >= -
eps && (c1 + c2) <= 1 +
eps)
180 OCTAVE_END_NAMESPACE(
octave)
octave_idx_type rows() const
octave_idx_type numel() const
Number of elements in the array.
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
double lo_ieee_nan_value()
F77_RET_T const F77_DBLE * x
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
double min(double a, double b, double c)
double max(double a, double b, double c)