davidcsterratt / geometry

R geometry package
16 stars 9 forks source link

Default options to delaunayn #4

Closed davidcsterratt closed 8 years ago

davidcsterratt commented 8 years ago

There are currently a number of problems with the default Qhull options given to delaunayn:

library(geometry)
square <- rbind(c(0, 0), c(0, 1), c(1, 0), c(1, 1))
delaunayn(square)
Qhull input error: Use option 'Qz' for the Delaunay triangulation or Voronoi diagram of cocircular/cospherical points.  Option 'Qz' adds a point "at infinity" (above the corresponding paraboloid).
Error in delaunayn(square) : non-zero exitcode

This can be fixed by supplying the Qz option:

delaunayn(square, "Qz")
     [,1] [,2] [,3]
[1,]    4    2    1
[2,]    4    3    1
Package                 | Default Option
---------------------------------------------------
Matlab R2015a           | Qbb Qc Qt Qx     (ndim >= 4)
                        | Qbb Qc Qt
Octave 3.8.1            | Qbb Qc Qt Qx     (ndim >= 4)
                        | Qbb Qc Qt     Qz
R 3.2.3; geometry 0.3-6 | Qbb    Qt
scipy.spatial.Delaunay  | Qbb Qc Qt Qx  Qz (ndim > 4)
                        | Qbb Qc Qt     Qz
davidcsterratt commented 8 years ago

I have fixed the first point by adding the Qz option with ndim < 4.

To bring the R implementation into line with Octave, and very similar to matlab and scipy.spatial.Delaunayn, I have added the Qc and Qz or Qx options have been added as defaults, making the default options "Qbb Qc Qt Qz" for 3 dimensions or less and "Qbb Qc Qt Qx" for 4 or more dimensions.

I have not tackled the final point, since Qbb is specified automatically in the Qhull delaunayn program and since not having Qt or QJ is liable to lead to more problems.