My Math Forum center of mass
 User Name Remember Me? Password

 Algebra Pre-Algebra and Basic Algebra Math Forum

 November 13th, 2013, 01:13 PM #1 Newbie   Joined: Nov 2013 Posts: 4 Thanks: 0 center of mass Hi there, I want to find the center of mass of any shape. I know the area of the shape and the coordinates of each point at the borders of the shape. The latter is also called a chain code, it is used in image processing. Example: Code: x x x x x x x x x x x x x x x x Area = 16 Coordinates of shape (starting from top left): 1,4;1,3;1,2;1,1;2,1;3,1;4,1;4,2;4,3;4,4;3,4;2,4 More complex example: Code:  x x x x x x x x x x x x x x x x x x x x Area = 20 Coordinates of shape (starting from top left): 1,3;1,2;2,2;2,1;3,1;4,1;5,1;5,2;6,2;6,3;5,3;5,4;4,4;3,4;2,4;2,3 Hope someone has a clever idea...
 November 13th, 2013, 03:42 PM #2 Global Moderator   Joined: Dec 2006 Posts: 18,551 Thanks: 1479 How do you know the area?
 November 14th, 2013, 12:27 AM #3 Newbie   Joined: Nov 2013 Posts: 4 Thanks: 0 Re: center of mass I know the area by determining the direction of the chain's coordinate. If it goes down, substract the value of the x-coordinate, if it goes up, add the value of the x-coordinate + 1. E.g. for the first example the summation will be: -1-1-1-1+5+5+5+5 = 16. The algorithm is actually little bit more complex, because of the chain going around corners, since it is not really related to my question (how to find the center) I will not describe it in detail. You may assume the area is known and correct. If I did post this in the wrong category, please don't hesitate to move it, I'm new here.
November 14th, 2013, 02:09 AM   #4
Global Moderator

Joined: Dec 2006

Posts: 18,551
Thanks: 1479

Does your area calculation work for a shape that is not convex? Also, I doubt that it works adequately for a shape that includes (or excludes) a long, narrowing spike. If your shape can be decomposed into non-overlapping rectangles, triangles, circles and certain other basic shapes for which the area and C of G are known, you can then find the overall C of G fairly easily, but making sure the components are non-overlapping might be tricky (the sum of the areas of the components must be the same as the overall area).

You could test your area calculation method on the shape below.
[attachment=0:2u3p1ali]Areas.gif[/attachment:2u3p1ali]
Attached Images
 Areas.gif (1.5 KB, 81 views)

November 14th, 2013, 04:50 AM   #5
Newbie

Joined: Nov 2013

Posts: 4
Thanks: 0

Re: center of mass

Because the application is grid based (pixels in image processing) I have changed your shape to the one attached and here is the ouput.
Code:
area          =37
chain length  =32
x[0]       =1
y[0]       =1
x[1]       =1
y[1]       =2
x[2]       =1
y[2]       =3
x[3]       =1
y[3]       =4
x[4]       =1
y[4]       =5
x[5]       =2
y[5]       =5
x[6]       =2
y[6]       =4
x[7]       =3
y[7]       =4
x[8]       =4
y[8]       =4
x[9]       =5
y[9]       =4
x[10]      =5
y[10]      =3
x[11]      =6
y[11]      =3
x[12]      =7
y[12]      =3
x[13]      =7
y[13]      =2
x[14]      =8
y[14]      =2
x[15]      =9
y[15]      =2
x[16]      =10
y[16]      =2
x[17]      =10
y[17]      =1
x[18]      =11
y[18]      =1
x[19]      =12
y[19]      =1
x[20]      =13
y[20]      =1
x[21]      =12
y[21]      =1
x[22]      =11
y[22]      =1
x[23]      =10
y[23]      =1
x[24]      =9
y[24]      =1
x[25]      =8
y[25]      =1
x[26]      =7
y[26]      =1
x[27]      =6
y[27]      =1
x[28]      =5
y[28]      =1
x[29]      =4
y[29]      =1
x[30]      =3
y[30]      =1
x[31]      =2
y[31]      =1
As I already mentioned the algorithm is more complex than actually stated above. It also works for non-convex shapes and special rules exist for 'narrow' spikes (of 1px width or height).

I don't see how I can decompose my shape in the largest possible basic shapes. I can decompose it in rectangles of width 1 (basically the way I calculate the area), but what to do with that?
Attached Images
 Areas2.gif (1.5 KB, 79 views)

 November 14th, 2013, 06:24 AM #6 Global Moderator   Joined: Dec 2006 Posts: 18,551 Thanks: 1479 Re: center of mass I'm a bit confused. You originally referred to "any shape", not just a shape made up of squares. If you deem the shape to be made up of non-overlapping squares (or rectangles) and you can list them and their sizes, you can find the C of G quite easily (though narrow spikes would presumably need special rules). Its position might not correspond exactly with a pixel position. What is the area if one excludes everything above the long blue diagonal line? Is it the sum of the areas of the outlined components found by the same method?
November 17th, 2013, 12:40 PM   #7
Newbie

Joined: Nov 2013

Posts: 4
Thanks: 0

Re: center of mass

Thanks skipjack, this
Quote:
 Its position might not correspond exactly with a pixel position.
was exactly what I overlooked. And you are right about the original question not being specific enough.

 Tags center, mass

Search tags for this page

### center of area x,y code

Click on a term to search for related topics.
 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post slice_of_god Real Analysis 1 June 4th, 2013 03:11 PM layd33foxx Calculus 1 January 28th, 2012 05:17 PM kfarnan Calculus 1 December 1st, 2011 01:14 PM astro Physics 4 September 12th, 2010 10:39 PM rekenprobleem Calculus 2 February 12th, 2009 03:09 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top

Copyright © 2018 My Math Forum. All rights reserved.