问题
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