DIST Function - 3D [message #92624] |
Tue, 26 January 2016 07:06  |
g.nacarts
Messages: 148 Registered: November 2013
|
Senior Member |
|
|
Hi
I wanted to create a 3D array [x,y,t] that when display it I'll see something not simple black images. I found the DIST() function but unfortunately I cannot use it to make a 3D array.
Can anyone help with this?
Thanks!
|
|
|
|
Re: DIST Function - 3D [message #92632 is a reply to message #92624] |
Wed, 27 January 2016 07:33   |
d.rowenhorst@gmail.co
Messages: 10 Registered: August 2008
|
Junior Member |
|
|
On Tuesday, January 26, 2016 at 10:06:18 AM UTC-5, g.na...@gmail.com wrote:
> Hi
>
> I wanted to create a 3D array [x,y,t] that when display it I'll see something not simple black images. I found the DIST() function but unfortunately I cannot use it to make a 3D array.
>
> Can anyone help with this?
>
> Thanks!
FUNCTION Dist_3d,n,m,l , calib=calib ;Return a 3d array in which each pixel = euclidian
;distance from the origin.
COMPILE_OPT idl2
On_error,2 ;Return to caller if an error occurs
IF Keyword_set(calib) NE 1 THEN calib = [1,1,1.]
IF N_elements(calib) NE 3 THEN cailb=[1,1,1.]
c0 = calib[0]*calib[0]
c1 = calib[1]*calib[1]
c2 = calib[2]*calib[2]
n1 = n[0]
m1 = (N_elements(m) LE 0) ? n1 : m[0]
l1 = (N_elements(m) LE 0) ? n1 : l[0]
x=Findgen(n1) ;Make a row
x = ((x < (n1-x)) ^ 2)*c0 ;column squares
a = Reform(Fltarr(n1,m1,l1,/NOZERO),n1,m1,l1) ;Make array
FOR i=0L, m1/2 DO BEGIN ;Row loop
y = (x + (i^2.)*c1) ;Euclidian distance
a[*,i,0] = y ;Insert the row
IF i NE 0 THEN a[*, m1-i, 0] = y ;Symmetrical
ENDFOR
x = a[*,*,0]
FOR i=0L, l1/2 DO BEGIN ;Stack loop
z = (x + (i^2.)*c2) ;Euclidian distance
a[*,*,i] = z ;Insert the row
IF i NE 0 THEN a[*, *,l1-i] = z ;Symmetrical
ENDFOR
a = Sqrt(Temporary(a))
Return,a
END
|
|
|
Re: DIST Function - 3D [message #92634 is a reply to message #92624] |
Wed, 27 January 2016 08:42  |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
Le mardi 26 janvier 2016 16:06:18 UTC+1, g.na...@gmail.com a écrit :
> Hi
>
> I wanted to create a 3D array [x,y,t] that when display it I'll see something not simple black images. I found the DIST() function but unfortunately I cannot use it to make a 3D array.
>
> Can anyone help with this?
>
> Thanks!
Maybe, by this:
function dist_3D, nx, ny, nz
x = [rebin(dindgen(1,nx), 1, nx, ny, nz), $
rebin(dindgen(1,1,ny), 1, nx, ny, nz), $
rebin(dindgen(1,1,1,nz), 1, nx, ny, nz)]
return, sqrt(total(x^2, 1))
end
alx.
|
|
|