Question

I'm trying to do a polar revolution solid in R, but I can´t found nothing working in R 3.0.2 For example I need do a revolution solid of this function around the x axis, before had a package for it called parametric3d, but it is only for cartesian. what do you advise me?

Example 2D.

library(plotrix)
b=seq(0,359,by=1)
c=(b)*pi/180  
a=(cos(c))^2*sin(c)
polar.plot(a,b,main="Test Polar Plot",lwd=2,line.col=4,rp.type="p")
Était-ce utile?

La solution

finally I'm solve this problem with RGL, thanks you a lot for your help. The final code is:

#####  2D #####

library(plotrix)
grad=seq(0,359,by=1)
rad=grad*pi/180  # degrees to radian
func=(cos(rad))^2*sin(rad)
func=abs(func)   # to plot negative numbers
polar.plot(func,grad,rp.type="p",radial.lim=c(0,1),
lwd=2,line.col=4,main="Polar Plot")

#####  3D #####

### Polar to Cartesians ###

x=func*cos(rad)
y=func*sin(rad)
y=abs(y)  # eliminate symmetrics ones (only y>=0)
library(rgl)
shade3d(turn3d(x, y), col = "green")

enter image description here

Autres conseils

What do you want to do with the solid? Just plot it? or something else?

If you just want to plot it then here are some options:

Convert the polar coordinates to Cartesian and use the package you did before.

Look at the rgl package for representing solids in 3d through R (probably need to convert to Cartesian coords).

Use the gnuplot program instead of R.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top