In this 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?
Last edited by krtxmrtz; Aug 29th, 2005 at 01:37 PM.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
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.
Last edited by krtxmrtz; Aug 28th, 2005 at 03:25 PM.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Re: Center of mass: practical aspects [Probably resolved]
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.
Last edited by krtxmrtz; Aug 29th, 2005 at 08:24 AM.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
I've tried out the recipe in my app and it works like a dream.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)