Plotting surface of a sphere using 3d Delaunay triangulated panels in R -


[edit: more general solutions can seen in answers this question]

i'm wondering if can me plot approximation of surface of sphere using xyz coordinates. have tried calculating delaunay triangulated panels using package geometry , plot iwith rgl. first attempt, looks nice, unfortunately created delaunay 3d triangles cross through sphere. plot surface:

generate 3d xyz data of sphere

n <- 10  rho <- 1 theta <- seq(0, 2*pi,, n) # azimuthal coordinate running 0 2*pi  phi <- seq(0, pi,, n) # polar coordinate running 0 pi (colatitude) grd <- expand.grid(theta=theta, phi=phi)  x <- rho * cos(grd$theta) * sin(grd$phi) y <- rho * sin(grd$theta) * sin(grd$phi) z <- rho * cos(grd$phi) xyzw <- cbind(x,y,z,w=1) 

calculate 3d delaunay triangles , plot rgl:

#install.packages("geometry") library(geometry) library(rgl)  tc <- delaunayn(xyzw[,1:3]) open3d() tetramesh(tc,cbind(x,y,z), alpha=0.2, col=5) rgl.snapshot("3d_delaunay.png") 

enter image description here

attempt @ returning surface triangles via 2d delaunay triangulation

tc <- delaunayn(xyzw[,c(1:2)]) open3d() for(i in seq(nrow(tc))){     vertices <- c(t(xyzw[tc[i,],]))     indices <- c( 1, 2, 3)     shade3d( tmesh3d(vertices,indices) , alpha=0.2, col="cyan") } rgl.snapshot("2d_delaunay.png") 

enter image description here

obviously, not working. appreciated.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -