Open maikol-solis opened 4 years ago
It's definitely possible, and probably not a bad idea to give me experience with adding them - I haven't explored most of the capabilities because I really need the constrained triangulation tools and I haven't been able to get it working yet.
But, do you know about alphahull and alphashape3d packages on CRAN?
Hi Michael,
Thanks for your reply. I didn't know about the alphahull
package and it is pretty same what I'm looking for. However, testing a little, I noticed that the function ashape
only gives the edges of the complex but not the proper triangles. I don't know if you have more experience handling these objects to recover the proper triangles?
I think CGAL should reconstruct super fast the complex in one shot for a fixed radius.
Best.
happy to look if you have an example with alphahull? I might try it with CGAL too ;)
btw, it does have the triangles in ahull because
library(alphahull)
x <- matrix(runif(100), nc = 2)
ahull.obj <- ahull(x, alpha = 0.2)
plot(ahull.obj, wlines = "del")
Somewhere else I wrote code to pull coordinates out of the ahull curves, it's a bit of work
Thanks @mdsumner for your feedback. Yes ashape
and ahull
build exactly the objects in convex constructions, but with anomalous point clouds extract the exact polygons inside the alpha shape it's a little hard as you said.
Another example,
n <- 500
theta1 <- runif(n, 0, 2 * pi)
theta2 <- runif(n, 0, 2 * pi)
theta3 <- runif(n, 0, 2 * pi)
r1 <- runif(n, 0.5, 1)
r2 <- runif(n, 0.5, 1)
r3 <- runif(n, 0.5, 1)
X1c1 <- r1 * cos(theta1)
Yc1 <- r1 * sin(theta1)
X1c2 <- r2 * cos(theta2) + 3
Yc2 <- r2 * sin(theta2) + 3
X1c3 <- r3 * cos(theta3) - 3
Yc3 <- r3 * sin(theta3) + 3
X <- cbind(c(X1c1, X1c2, X1c3), c(Yc1, Yc2, Yc3))
as <- alphahull::ashape(X, alpha = 0.4)
plot(
as,
wlines = "del",
col = c("darkblue", "red4", "grey50"),
pch = "x"
)
There is another C++ library GUDHI that build this kind of objects (http://gudhi.gforge.inria.fr/doc/latest/group__alpha__complex.html). My knowledge with C++ and Rcpp is very limited but I am very intrested in see how to implement it in R.
Is it possible to include alpha shapes in 2D to this package?
https://doc.cgal.org/latest/Alpha_shapes_2/index.html#Chapter_2D_Alpha_Shapes
Thanks.