Plotting ellipsoids / oblate spheroids in rgl

杀马特。学长 韩版系。学妹 提交于 2019-12-10 11:55:44

问题


I have been using rgl to plot spheres, but now I need to plot ellipsoids. The package includes ellipse3d; however, this seems to be for fitting ellipsoids to data, using matrices and stuff I'm not very good at.

What I want is a simple way to plot ellipsoids, in a similar way to spheres, using the centre coordinates and the scales in each direction. Can anyone help me out?


回答1:


If you don't need the ellipse rotated around the axes, then you can just use a diagonal matrix for x (this plots a sphere, and defines the virtual "axes" along the x, y, z axes) and use the centre and scale parameters to shift the location and change the proportions.

plot3d(ellipse3d(diag(3),centre=c(1,2,4),scale=c(1,2,5)))



回答2:


There's one in my cda package,

library(cda)
library(rgl) 
## single ellipsoid
plot3d(rgl.ellipsoid(a=2,b=1,c=5))

## multiple ellipsoids, translated and rotated 
cl <- helix(0.5, 1, 36, delta=pi/6, n.smooth=1e3)
sizes <- equal_sizes(0.04,0.02,0.02,NROW(cl$positions))
rgl.ellipsoids(cl$positions, sizes, cl$angles, col="gold") 



来源:https://stackoverflow.com/questions/26757560/plotting-ellipsoids-oblate-spheroids-in-rgl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!