Ok, now I'm scared. I copied the exact code from your post and got length(tri) = 1481 and dim(geodel) = 1577 3
You are right though, there seem to bee duplicates in my original bm, but removing them still got diffeent results. I fear there's something weird going on with my R installation. Cheers Raphael On 5/23/14, Rolf Turner <r.tur...@auckland.ac.nz> wrote: > > I just tried the following: > > require(deldir) > require(geometry) > set.seed(42) > bm <- data.frame(x=sample(1:82,800,TRUE),y=sample(1:82,800,TRUE)) > del <- deldir(bm) > tri <- triang.list(del) > geodel <- delaunayn(bm) > length(tri) # Got [1] 1481 > dim(geodel) # Got [1] 1481 3 > > So all seems to be in harmony in the universe. > > Something is weird about your "bm"; hard to say what without seeing it. > > One thought: Are there any duplicated points in your "bm"? (Upon > re-reading your message and noting the problem with "ptNum", I think > this might be the case.) > > Try doing something like: > > newbm <- bm[!duplicated(bm),] > > and then hit "newbm" with both deldir() and delaunayn(). > > cheers, > > Rolf Turner > > On 23/05/14 03:36, Raphael Päbst wrote: >> Hello again, >> I have found further depths of confusion concerning delaunay >> triangulations to explore. >> >> Here is the code I'm using to create the confusing results: >> >> bm <- getbm(x) # a data.frame with 2 columns and 800 rows, values are >> integers ranging from 1 to 82 >> >> del <- deldir(bm) # creating an object of type deldir with the 800 >> coordinates from bm >> tri <- triang.list(del) # creating a list of length n, holding the n >> triangles created by the delaunay triangulation with deldir(bm) as >> data.frames >> >> geodel <- delaunayn(bm) # creating a matrix with 3 columns and m rows >> for the m triangles created by the delaunay triangulation using >> delaunayn(bm) from geometry-package >> >> now, the following is what I would expect: n and m should be the same, >> since both triangulations should give me the same number of triangles, >> right? >> >> but this is what I get: >> >> nrow(geodel) = 1584 >> length(tri) = 1186 >> >> This confuses me and I have the feeling I have left out some very >> important parameter either in delaunayn() or deldir() to create the >> different results. >> There is however more confusion to come, this time in the result of >> triang.list(del): >> >> Every element in that list is a data.frame holding information on one >> triangle. It has 3 columns and 3 rows with column headers 'ptNum', 'x' >> and 'y'. Now I would expect, that 'ptNum' would give me the index at >> which I can find the coordinates 'x' and 'y' as a row in my original >> data.frame of coordinates, bm. And for example >> >> bm[1,] gives me the same 'x' and 'y' that are listed in data.frame >> tri[1] as 'ptNum' = 1. >> But for some other points this does not work and for example the 'x' >> and 'y' of 'ptNum' = 129 do not match bm[129, ]. Have I totally >> misunderstood the meaning of 'ptNum' in this case or does my mistake >> lie somewhere else? >> >> Once again please excuse my slightly chaotic description of my >> problems and my faulty english and thanks for any help you can give! > > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.