For Programmers: Free Programming Magazines  


Home > Archive > Matlab > March 2007 > How can I get the centroid of a convex hull









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How can I get the centroid of a convex hull
daiwen.v@gmail.com

2007-03-29, 7:14 pm

Hi,
I have used the function 'convhull' to get the points of the convex
hull. Now I need to find the centroid of this convex hull. Which
function can I use?
Thanks.

Ken Davis

2007-03-29, 7:14 pm

<daiwen.v@gmail.com> wrote in message
news:1175194158.129881.89980@e65g2000hsc.googlegroups.com...
> Hi,
> I have used the function 'convhull' to get the points of the convex
> hull. Now I need to find the centroid of this convex hull. Which
> function can I use?
> Thanks.
>

I think I might try solving symbolically for the centroid of a triangle and
then pick a point in the middle and make triangles to all the vertices and
do the integral that way.


Nevine Jacob

2007-03-30, 10:09 pm

If you are dealing with 2D, then complete your convex hull points
(the way imregionprops finds the convex image). Then the average of
all your x- and y-coordinates (separately) should give you your
centroid.
John D'Errico

2007-03-30, 10:09 pm

daiwen.v wrote:
>
>
> Hi,
> I have used the function 'convhull' to get the points of the convex
> hull. Now I need to find the centroid of this convex hull. Which
> function can I use?
> Thanks.


This will do it. If you need a faster
tool, I did some improvements to it
once.

<http://www.mathworks.com/matlabcent...objectType=file>

HTH,
John D'Errico
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com