>> >> zCenter = mean(Z)
>> >
>> >  How can that be right? Suppose your mountain is very flat, so that
>> > your mountain is effectively a cube. The Z values are all the same,
>> > and so their mean is the same. However the centre of mass is, by
>> > symmetry, clearly at height/2.
>> >
>> >  Similarly suppose your mountain matrix is one large cell value and
>> > all the rest are near zero - the mean Z will be close to zero but the
>> > centre of mass will be almost half way up the single cell value,
>> > because all the near-zeros contribute nothing to the centre of mass
>> > position.
>>
>> Yup, the z coordinate is wrong. Only the x and y are right.
>>
>> Peter
>>
>
> I believe that should have been mean(z)/2

mean(z)/2 isn't correct either. The correct answer it is the weighted
mean of the center of mass coordinate of each column (which is z/2),
and the weight (mass of the columns) is also z, that is the result is

zCenter = 0.5 * sum(z^2)/sum(z)

Apologies for the wrong formula for the cm coordinate z.

Peter

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to