Centroid computation for a 3D array in PV-Wave [message #10727] |
Fri, 09 January 1998 00:00 |
Nagesh Mallugari
Messages: 4 Registered: April 1997
|
Junior Member |
|
|
Hi!
Can anybody suggest an efficient way to compute a centroid for 3D
array in PV-Wave?
Thanks to David Foster of UCSD, he forwarded a couple of methods of
centroid computation for a 2D array in IDL which he saved from the
discussions on this news group. The following are the methods:
> sz = size(array)
> xcoors = indgen(sz(1)) # replicate(1,sz(2))
> ycoors = replicate(1,sz(1)) # indgen(sz(2))
>
> xcg = total(array*xcoors)/total(array)
> ycg = total(array*ycoors)/total(array)
---------------------------
sz = size(array)
tot = total(array)
xcg = total(total(array,2)*indgen(sz(1)))/tot
ycg = total(total(array,1)*indgen(sz(2)))/tot
But PV-Wave does not allow the usage of 'Total' function as in the second
form of the code. And though I understood how the first form of code works
for 2D centroid computation, I could not extend it to work for a 3D array.
Any suggestions will be appreciated.
thanks,
Nagesh
|
|
|