4.4

4.4 | 5 ratings Rate this file 123 downloads (last 30 days) File Size: 1.46 KB File ID: #8514

Centroid of a Convex n-Dimensional Polyhedron

by Michael Kleder

 

19 Sep 2005 (Updated 21 Sep 2005)

No BSD License  

Computes the center of gravity of a convex polyhedron in any number of dimensions.

Download Now | Watch this File

File Information
Description

USAGE: C = centroid(P)
 
P = Matrix of convex polyhedron vertices: each row is a vertex, and each column is a dimension.
C = Row vector of centroid coordinates. Each column is a dimension.

Notes:
(1) This function computes the centroid by partitioning into simplices and determining the weighted sum of their centroids.
(2) Written in response to a question on comp.soft-sys.matlab

Michael Kleder, Sep 2005

MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
13 Oct 2005 Birajashis Pattnaik

Ohh this is fantastic.

03 Nov 2005 Glen Lichtwark

This is a very handy function, thanx.

26 Oct 2006 fady dawoud

very nice!! a question though, does the algorithm still work if the points dont form a convex surface.

10 Nov 2006 The Author

Answer to Fady Dawoud: If the points do not form a convex polyhedron, then the function gives you an error telling you what happened.

01 May 2007 Roja B

Hi,

thank you, this is a very useful function. my only problem is when I try to use it in 2-D. how do you think I can fix this?

03 May 2007 The Author

Answer to Roja B:
As an example in 2-D, try
P=centroid([0 0;1 1;2 0]);
plot([0 1 2 0],[0 1 0 0],...
'b-',P(1),P(2),'r.');

06 Mar 2008 Charlotte B

thanks for this function! but what happens with a concave polyhedron? do you have suggestions on how to calculate the center of gravity of these shapes?

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
centroid Michael Kleder 22 Oct 2008 08:00:21
center Michael Kleder 22 Oct 2008 08:00:21
gravity Michael Kleder 22 Oct 2008 08:00:22
polgyon Michael Kleder 22 Oct 2008 08:00:22
polyhedron Michael Kleder 22 Oct 2008 08:00:22
centroid asdd 07 Nov 2008 14:56:29
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com