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 #17711 is a reply to message #17710] Mon, 08 November 1999 00:00 Go to previous messageGo to previous message
Paul Hick is currently offline  Paul Hick
Messages: 9
Registered: November 1999
Junior Member
David Fanning wrote:
>
> 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

Reasoning by analogy to the 2D case, this should work, I think:

xcm = Total( Total(Total(array,3),2) * Indgen(s[0])) / totalMass
ycm = Total( Total(Total(array,3),1) * Indgen(s[1])) / totalMass
zcm = Total( Total(Total(array,2),1) * Indgen(s[2])) / totalMass

--
____________________________________________________________ _____
| Paul Hick (pphick@ucsd.edu) |
| Office : SERF Rm. 302 Smail : UCSD/CASS/0424 |
| Phone : (858) 534-8965 9500 Gilman Drive |
| Fax : (858) 534-0177 La Jolla CA 92093-0424 |
| WWW : http://casswww.ucsd.edu/personal/Plh.html |
|___________________________________________________________ ______|
[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: Fri Oct 10 10:07:22 PDT 2025

Total time taken to generate the page: 0.71991 seconds