On 09/01/2012 10:12 AM, gli wrote:
hi, i want to draw a simple circle by using 3d package RGL.
i think i can use the command rgl.lines by studying the code from:
http://www.swiftless.com/tutorials/opengl/circle.html
but is there a faster and easier way to do it??
The code on that page is much more complicated than necessary. rgl will
handle most of the calls to OpenGL; you just need to work out the
geometry of the circle.
The difficulty you might have is whether you want something that appears
to be a circle, or something that is a circle in user-coordinates. For
the latter, try something like:
n <- 300
theta <- seq(0, 2*pi, len=n)
x <- cos(theta)
y <- sin(theta)
z <- rep(0, n)
lines3d(x,y,z)
The former is harder; I'd probably do it by drawing a sphere and turning
off lighting, but the overlaps don't look quite right if they aren't all
the same colour:
spheres3d(rnorm(10), rnorm(10), rnorm(10), lit=FALSE, col=rainbow(10))
Duncan Murdoch
______________________________________________
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.