Compute the centroid of a polytope

i like this post (click again to cancel)
0
i dont like this post (click again to cancel)

Does SAGE have a way to compute the center of mass of a polytope? I tried using polymake's centroid method, but that returned an error because the dimension of my polytope is not equal to the ambient dimension. I've read the manual and looked at the available functions but can't seem to find a SAGE command to do this. Does it exist?

EDIT: By request here's some sample _polymake_ code that fails (I'm not sure why this would be useful unless SAGE is using polymake under the hood):

polytope > $q=permutahedron(3);

polytope > print $q->CENTROID;

polymake: WARNING: could not compute 'CENTROID' probably because of unsatisfied preconditions:

precondition : DIM, AMBIENT_DIM ( CENTROID, VOLUME : VERTICES, TRIANGULATION.FACETS )

I'm guessing the error occurs because the ambient dimension of this polytope is 4 but the actual dimension of the polytope is 3; this is the same reason polymake tells me the volume of q is 0.

asked Apr 27 '11

adk gravatar image adk
3 4

updated Apr 28 '11

Could you post some example code? It's easier to debug why a command wouldn't work. cswiercz (Apr 27 '11)
My apologies. I hadn't read your question carefully enough to realize that you hadn't attempted to write any Sage code to compute the centroid. cswiercz (Apr 30 '11)

2 Answers:

i like this answer (click again to cancel)
2
i dont like this answer (click again to cancel) adk has selected this answer as correct

There is no such function currently implemented. However, it would not be difficult to add. The straightforward approach would be to triangulate the polytope, find the barycenter of the simplices, and then add their individual barycenters weighted by the fraction of the total mass.

If you want to contribute a centroid method make a trac ticket and cc me, I'd be happy to help.

link

posted May 07 '11

Volker Braun gravatar image Volker Braun
2238 5 22 52
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

The "center" (average of the vertices) is available via the center method like so:

sage: q = polytopes.permutahedron(4)
sage: q.dim()
3
sage: q.center()
(1/40000, 1/40000, 1/20000)

You can look through the other methods available in the Polyhedra documentation.

link

posted Apr 29 '11

benjaminfjones gravatar image benjaminfjones
2470 3 33 66
http://bfj7.com/
Thanks for the suggestion, but I'm not looking for the average of the vertices; I'm looking for the center of mass. I looked through the Polyhedra documentation and was unable to find a suitable command which is why I asked this question. Most likely no such command exists, but I thought I'd check to be sure. adk (Apr 29 '11)

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Tags:

Stats:

Asked: Apr 27 '11

Seen: 189 times

Last updated: May 07 '11

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.