Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Ab Hu
Peter Langfelder wrote: > > Sorry, I'm not sure what you want to do in points 2-4. Shrink the > mountain vertically or horizontally? You can for example look up image > resizing algorithms if you want to shrink the area under the mountain > but keep the shape of the mountain (approximately) the

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Peter Langfelder
>> >> 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. >> > >> >  Similar

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Peter Langfelder > Sent: Tuesday, November 09, 2010 3:49 PM > To: Barry Rowlingson > Cc: r-help@r-project.org; Ab Hu > Subject: Re: [R] Centre of gravity

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Peter Langfelder
On Tue, Nov 9, 2010 at 3:40 PM, Barry Rowlingson wrote: > On Mon, Nov 8, 2010 at 5:15 PM, Peter Langfelder > wrote: > >> If you also need the z coordinate, it simply the mean of the matrix Z. >> >> zCenter = mean(Z) > >  How can that be right? Suppose your mountain is very flat, so that > your mo

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Barry Rowlingson
On Mon, Nov 8, 2010 at 5:15 PM, Peter Langfelder wrote: > If you also need the z coordinate, it simply the mean of the matrix Z. > > 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 th

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Peter Langfelder
On Mon, Nov 8, 2010 at 11:31 PM, Ab Hu wrote: > > Thanks! Works great. > I have more questions on this, so I'll continue here: > > Now that I have the weighted mean, is it possible to reduce the size of > mountain based on this weighted mean such the original matrix remains 21x21 > while the mount

Re: [R] Centre of gravity of a mountain

2010-11-08 Thread Ab Hu
Thanks! Works great. I have more questions on this, so I'll continue here: Now that I have the weighted mean, is it possible to reduce the size of mountain based on this weighted mean such the original matrix remains 21x21 while the mountain shrinks/converges. Step for my analysis: 1) Find cent

Re: [R] Centre of gravity of a mountain

2010-11-08 Thread Peter Langfelder
Weighted mean of x and y coordinates (sorry for the pun :)), that is something like n = 21 y = matrix( c(1:n), n, n) x = matrix( c(1:n), n, n, byrow = TRUE) # These are the Center of mass coordinates: xCenter = sum(x * Z)/sum(Z); yCenter = sum(y * Z)/sum(Z); If you also need the z coordinate, it