Help plotting a 3D Carioid... [message #47498] |
Wed, 15 February 2006 08:46  |
Steve[3]
Messages: 7 Registered: January 2006
|
Junior Member |
|
|
I'm a newbie to IDL, and am having a bit of trouble doing stuff that is
pretty basic in other tools. In this case, I'm trying to generate a
surface plot of a 3D cartioid function. I start by defining azimuth
and elevation angle matrices, then compute the range of the cartioid
for each angle pair. I then want to convert from spherical to
rectangular coordinates and make a surface plot of the result.
In Matlab, I was able to do the coordinate transform on the matrices in
n x n form, but it appears that IDL wants the data as column vectors.
However, somewhere it appears that things are getting messed up, as the
resulting plot has a "hole" in it. However, when I use xplot3D to plot
the result, the hole is not there...
Additionally, the surface plot just doesn't have a nice look - is there
anything a bit nicer I could do, along the lines of xplot3D, but be
able to do it in a pre-specified window (I'm going to be having the
result plot in a GUI)? Best would be to have the surface shaded and
with the color set to correspond with the magnitude of each point.
I guess what I'm looking for is a little guidance on how to get this to
look a bit nicer, and what's causing the hole when I use surface...
;ang=[0:.1:2.*pi+.1]'; (this is what I used in
Matlab...)
ang=transpose(2*!PI*findgen(64)/63)
n=size(ang, /N_ELEMENTS )
ones=fltarr(n,1)+1
theta_a=(ang##ones)
;ang2=[0:.05:pi+.05]'-pi/2; (this is what Iused in Matlab)
ang2=transpose(!PI*findgen(n)/(n-1)-!PI/2) ; (should be roughly
equivalent to above)
theta_e=transpose(ang2##ones)
rcart=1+cos(!pi/2-theta_e)
theta_a_1d=reform(theta_a,1,n*n)
theta_e_1d=reform(theta_e,1,n*n)
rcart_1d=reform(rcart,1,n*n)
sph=[theta_a_1d,theta_e_1d,rcart_1d]
rectc=cv_coord(from_sphere=sph, /to_rect)
x_1d=rectc(0,*)
y_1d=rectc(1,*)
z_1d=rectc(2,*)
x=reform(x_1d,n,n)
y=reform(y_1d,n,n)
z=reform(z_1d,n,n)
surface, z,x,y
xplot3d, x,y,z
|
|
|