PDA

Click to See Complete Forum and Search --> : [RESOLVED] Center of mass: practical aspects


krtxmrtz
Aug 21st, 2005, 04:24 AM
In this (http://www.vbforums.com/showthread.php?t=355577) earlier post of mine I mentioned I usually register 2 very similar polygons by shifting one relative to the other by the differences in the x & y coordinates of their centers of mass.
In actual practice it works fine most of the time but at times I find that, for 2 extremely similar figures, the x coordinate (and / or the y coordinate) for the center of mass comes out obviously "wrong" (i.e. comparing the figures by the naked eye). Delving into the problem I found the reason was a much higher concentration of points in a specific part of one of the 2 polygons, not obvious unless you zoomed onto that region.

So, the question I'm facing now is how to calculate the geometrical center rather than the center of mass. For example, a square with coordinates
(0,0)
(0,1)
(1,1)
(1,0)
has both its center of mass and geometrical center at (0.5, 0.5), but the square defined by:
(0,0)
(0,1)
(1,1)
(1, 0.75)
(1, 0.5)
(1, 0.25)
(1, 0)
which is identical (if you don't plot the points, just the lines connecting them) has it's center of mass at (5/7, 0.5) but it's geometrical center still

at (0.5, 0.5).

Any ideas on how to deal with this?

krtxmrtz
Aug 28th, 2005, 03:15 PM
Well, I think the way to go is by integration. In the case of a polygon it's just a matter of adding the x & y coordinates for the center of mass of the various trapeziums that the polygon can be split into (see figures below).

I think it should work, at least it did in the simple examples I used for testing.

krtxmrtz
Aug 29th, 2005, 03:33 AM
Unfortunately I made a mistake in my derivation. In the previous post, figure 2 is wrong and must be replaced by the attachment I've just uploaded.

krtxmrtz
Aug 29th, 2005, 03:40 AM
I should also add the expression for the area of the trapezium APiPi+1B:

ai = yi(xi+1 - xi) + (1/2)(xi+1 - xi)(yi+1 - yi) = (1/2)(xi+1 - xi)(yi+1 + yi)

krtxmrtz
Aug 29th, 2005, 01:39 PM
I've tried out the recipe in my app and it works like a dream. ;)