# HG changeset patch # User Rik # Date 1580435036 28800 # Node ID 2e6dc7e2b191f84a5eddbbd64bcf192ca1125191 # Parent 262cdfc6faf915b8b3bd5c34c45c20760dace26a Use appropriate Qhull options as necessary to obtain triangulation (bug #50494). * __delaunayn__.cc (F__delaunayn__): Set default options for 2-D & 3-D input to "Qt Qbb Qc" (no "Qz"). * delaunay.m: Document that default options for 2-D,3-D input are "Qt Qbb Qc". * delaunayn.m: Document that default options for 2-D,3-D input are "Qt Qbb Qc". Document that if triangulation fails, "Qz" will be added for 2-D inputs and Qhull called a second time. Add try/catch block that calls internal function __delaunayn__ once with no options, and if an error results, calls with "Qt Qbb Qc Qz" for 2-D inputs. * griddata.m: Remove previous fix for bug #50494 which set Qhull options. * griddatan.m: Remove previous fix for bug #50494 which set Qhull options. diff -r 262cdfc6faf9 -r 2e6dc7e2b191 libinterp/dldfcn/__delaunayn__.cc --- a/libinterp/dldfcn/__delaunayn__.cc Thu Jan 30 15:12:52 2020 -0500 +++ b/libinterp/dldfcn/__delaunayn__.cc Thu Jan 30 17:43:56 2020 -0800 @@ -133,7 +133,7 @@ // Default options std::string options; if (dim <= 3) - options = "Qt Qbb Qc Qz"; + options = "Qt Qbb Qc"; else options = "Qt Qbb Qc Qx"; diff -r 262cdfc6faf9 -r 2e6dc7e2b191 scripts/geometry/delaunay.m --- a/scripts/geometry/delaunay.m Thu Jan 30 15:12:52 2020 -0500 +++ b/scripts/geometry/delaunay.m Thu Jan 30 17:43:56 2020 -0800 @@ -55,7 +55,10 @@ ## contains options passed to the underlying qhull command. ## See the documentation for the Qhull library for details ## @url{http://www.qhull.org/html/qh-quick.htm#options}. -## The default options are @code{@{"Qt", "Qbb", "Qc", "Qz"@}}. +## The default options are @code{@{"Qt", "Qbb", "Qc"@}}. +## If QHull fails for 2-D input the triangulation is attempted again with +## the options @code{@{"Qt", "Qbb", "Qc", "Qz"@}} which may result in +## reduced accuracy. ## ## If @var{options} is not present or @code{[]} then the default arguments are ## used. Otherwise, @var{options} replaces the default argument list. diff -r 262cdfc6faf9 -r 2e6dc7e2b191 scripts/geometry/delaunayn.m --- a/scripts/geometry/delaunayn.m Thu Jan 30 15:12:52 2020 -0500 +++ b/scripts/geometry/delaunayn.m Thu Jan 30 17:43:56 2020 -0800 @@ -45,11 +45,15 @@ ## The default options depend on the dimension of the input: ## ## @itemize -## @item 2-D and 3-D: @var{options} = @code{@{"Qt", "Qbb", "Qc", "Qz"@}} +## @item 2-D and 3-D: @var{options} = @code{@{"Qt", "Qbb", "Qc"@}} ## ## @item 4-D and higher: @var{options} = @code{@{"Qt", "Qbb", "Qc", "Qx"@}} ## @end itemize ## +## If QHull fails for 2-D input the triangulation is attempted again with +## the options @code{@{"Qt", "Qbb", "Qc", "Qz"@}} which may result in +## reduced accuracy. +## ## If @var{options} is not present or @code{[]} then the default arguments are ## used. Otherwise, @var{options} replaces the default argument list. ## To append user options to the defaults it is necessary to repeat the @@ -64,7 +68,17 @@ print_usage (); endif - T = __delaunayn__ (pts, varargin{:}); + if (isempty (varargin) || isempty (varargin{1})) + try + T = __delaunayn__ (pts); + catch + if (columns (pts) <= 2) + T = __delaunayn__ (pts, "Qt Qbb Qc Qz"); + endif + end_try_catch + else + T = __delaunayn__ (pts, varargin{:}); + endif if (isa (pts, "single")) tol = 1e3 * eps ("single"); diff -r 262cdfc6faf9 -r 2e6dc7e2b191 scripts/geometry/griddata.m --- a/scripts/geometry/griddata.m Thu Jan 30 15:12:52 2020 -0500 +++ b/scripts/geometry/griddata.m Thu Jan 30 17:43:56 2020 -0800 @@ -86,8 +86,7 @@ z = z(:); ## Triangulate data. - ## Bug #50494 (loss of precision unless non-default Qhull options used) - tri = delaunay (x, y, {"Qt", "Qbb", "Qc"}); + tri = delaunay (x, y); zi = NaN (size (xi)); if (strcmp (method, "cubic")) diff -r 262cdfc6faf9 -r 2e6dc7e2b191 scripts/geometry/griddatan.m --- a/scripts/geometry/griddatan.m Thu Jan 30 15:12:52 2020 -0500 +++ b/scripts/geometry/griddatan.m Thu Jan 30 17:43:56 2020 -0800 @@ -60,11 +60,6 @@ error ("griddatan: dimensional mismatch"); endif - ## Bug #50494 (loss of precision unless non-default Qhull options used) - if (isempty (varargin) && n <= 3) - varargin{1} = {"Qt", "Qbb", "Qc"}; - endif - ## triangulate data tri = delaunayn (x, varargin{:});