comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Center of mass???
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Center of mass??? [message #17778 is a reply to message #17710] Mon, 08 November 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Object Widgets
Next Topic: Re: where() and IEEE NaN

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:56:50 PDT 2025

Total time taken to generate the page: 0.00438 seconds