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 master.rs...@yahoo.com 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

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 peter.langfel...@gmail.com 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

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 b.rowling...@lancaster.ac.uk wrote: On Mon, Nov 8, 2010 at 5:15 PM, Peter Langfelder peter.langfel...@gmail.com 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

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 of a mountain On Tue, Nov 9

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.  Similarly suppose your mountain

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

[R] Centre of gravity of a mountain

2010-11-08 Thread Ab Hu
Hi all, I have a matrix of a mountain of form 21x21 and values in them are height (Z). Using the persp function I can view this mountain in 3D. Now, I am trying to find a measure to find the centre of gravity (maybe centroid?) of this mountain. Any idea what would be the best way to go? -- View

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,

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