Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to calculate centroid for non-constant desity polygon

Subject: how to calculate centroid for non-constant desity polygon

From: gtechnical@gmail.com

Date: 24 Jan, 2009 22:01:01

Message: 1 of 7

I am facing a problem of calculating centroid for a polygon, the
problem is the density of this polygon is not constant. The density
is : exp(-x^2-y^2)
I shall appreciate it very much if anyone who could offer me a
suggestion on this quesiton!
Thanks in advance.

Subject: how to calculate centroid for non-constant desity polygon

From: Matt

Date: 24 Jan, 2009 22:14:02

Message: 2 of 7

gtechnical@gmail.com wrote in message <9f8b39b8-945f-4941-b9cd-ea9fb074a228@r34g2000vbp.googlegroups.com>...
> I am facing a problem of calculating centroid for a polygon, the
> problem is the density of this polygon is not constant. The density
> is : exp(-x^2-y^2)
> I shall appreciate it very much if anyone who could offer me a
> suggestion on this quesiton!
> Thanks in advance.

It may be messy, but I don't see why it's a problem. Ar you saying you couldn't do this integral by hand?

Subject: how to calculate centroid for non-constant desity polygon

From: gtechnical@gmail.com

Date: 24 Jan, 2009 22:36:34

Message: 3 of 7

On Jan 24, 5:14=A0pm, "Matt " <mjacobson.removet...@xorantech.com>
wrote:
> gtechni...@gmail.com wrote in message <9f8b39b8-945f-4941-b9cd-ea9fb074a.=
..@r34g2000vbp.googlegroups.com>...
> > I am facing a problem of calculating centroid for a polygon, the
> > problem is the density of this polygon is not constant. The density
> > is : exp(-x^2-y^2)
> > I shall appreciate it very much if anyone who could offer me a
> > suggestion on this quesiton!
> > Thanks in advance.
>
> It may be messy, but I don't see why it's a problem. Ar you saying you co=
uldn't do this integral by hand?

I just don't know how to start? could you offer me an example for this
problem? sorry about this!

Subject: how to calculate centroid for non-constant desity polygon

From: Matt

Date: 24 Jan, 2009 22:48:01

Message: 4 of 7

gtechnical@gmail.com wrote in message <1d2ad55a-45f3-4e98-9405-0fdbcaffa613@j38g2000yqa.googlegroups.com>...
> On Jan 24, 5:14=A0pm, "Matt " <mjacobson.removet...@xorantech.com>
> wrote:
> > gtechni...@gmail.com wrote in message <9f8b39b8-945f-4941-b9cd-ea9fb074a.=
> ..@r34g2000vbp.googlegroups.com>...
> > > I am facing a problem of calculating centroid for a polygon, the
> > > problem is the density of this polygon is not constant. The density
> > > is : exp(-x^2-y^2)
> > > I shall appreciate it very much if anyone who could offer me a
> > > suggestion on this quesiton!
> > > Thanks in advance.
> >
> > It may be messy, but I don't see why it's a problem. Ar you saying you co=
> uldn't do this integral by hand?
>
> I just don't know how to start? could you offer me an example for this
> problem? sorry about this!

Well, the centroid is the integral of

 [x;y]*density(x,y)

divided by the integral of density(x,y) only, where both integrals are over your polygonal region.


The polygon can be viewed as a region bounded between 2 piecewise linear functions of x, so you should be able to decompose this region into a sequence of trapezoids. The above integrals over a trapezoidal region are do-able by hand and should lead to closed form formulas which you can then use MATLAB to compute.
 

Subject: how to calculate centroid for non-constant desity polygon

From: ImageAnalyst

Date: 24 Jan, 2009 23:05:18

Message: 5 of 7

To do it numerically, first create your polygon in an array with the
exponential values for the elements. Then....
To find the x centroid, just use sum(v*x)/sum(x).
To find the y centroid, just use sum(v*y)/sum(y).
v is the exponential formula you gave. Calculate the sum over ALL
array elements, in both the x and y directions, to get either of the
centroids.
If you have the image processing toolkit, just threshold, use bwlabel
() and then use regionprops(). Be sure to pass in your original
image, as well as your thresholded image (which specifies which pixels
contain the polygon) into regionprops().

You can compare your numerical answer with the analytical answer which
you can probably find in a book on calculus or statistics. If you
need more accuracy, just make your array bigger.
Regards,
ImageAnalyst

Subject: how to calculate centroid for non-constant desity polygon

From: Roger Stafford

Date: 25 Jan, 2009 00:47:01

Message: 6 of 7

gtechnical@gmail.com wrote in message <9f8b39b8-945f-4941-b9cd-ea9fb074a228@r34g2000vbp.googlegroups.com>...
> I am facing a problem of calculating centroid for a polygon, the
> problem is the density of this polygon is not constant. The density
> is : exp(-x^2-y^2)
> I shall appreciate it very much if anyone who could offer me a
> suggestion on this quesiton!
> Thanks in advance.

  Is this to be the centroid of the polygonal line segments or the area bounded by the polygon? In other words, is exp(-x^2-y^2 a line density or area density. These are two different problems.

Roger Stafford

Subject: how to calculate centroid for non-constant desity polygon

From: gtechnical@gmail.com

Date: 25 Jan, 2009 20:29:33

Message: 7 of 7

On Jan 24, 7:47=A0pm, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> gtechni...@gmail.com wrote in message <9f8b39b8-945f-4941-b9cd-ea9fb074a.=
..@r34g2000vbp.googlegroups.com>...
> > I am facing a problem of calculating centroid for a polygon, the
> > problem is the density of this polygon is not constant. The density
> > is : exp(-x^2-y^2)
> > I shall appreciate it very much if anyone who could offer me a
> > suggestion on this quesiton!
> > Thanks in advance.
>
> =A0 Is this to be the centroid of the polygonal line segments or the area=
 bounded by the polygon? In other words, is exp(-x^2-y^2 a line density or =
area density. =A0These are two different problems.
>
> Roger Stafford

exp(-x^2+y^2) is an area density!
Thanks you all, I will give it a try!

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us