[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Center of mass???
- Subject: Re: Center of mass???
- From: davidf(at)dfanning.com (David Fanning)
- Date: Mon, 8 Nov 1999 08:29:03 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <3826E4D0.6E84F53B@mrc.ks.se>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:17160
Anders Wennerberg (anders@mrc.ks.se) writes:
> I have tried to find a routine that could calculate the center of
> mass, in preliminary 2D but in near future 3D. I would be happy if
> anyone could give direction where to find that kind of routine.
Here is how you do it in 2D. I've never had to extend
this to 3D, but when you figure it out, please let us
know. I'll write up an article on it. :-)
s = Size(array, /Dimensions)
totalMass = Total(array)
xcm = Total(Total(array,2) * Indgen(s[0])) / totalMass
ycm = Total(Total(array,1) * Indgen(s[1])) / totalMass
Cheers,
David
P.S. Thanks to David Foster for the algorithm above.
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155