Ask Your Question
3

How to triangulate polygon with sage?

asked 2012-04-05 01:56:02 +0200

Bill gravatar image

If I feed sage a list of vertices, then the polygon() function can create a 2D polygon determined by visiting these edges in order (with self-intersections, repeated edges, holes, etc.).

Does sage have a built-in method to triangulate the resulting polygon? (It appears to me as though this is not the case.)

If not, I would love to see your homemade code to do this.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2012-04-05 10:39:33 +0200

Volker Braun gravatar image

The polygon() function is for plotting, not for polyhedral computations. You can do the following:

sage: square = Polyhedron([(0,0), (1,0), (0,1), (1,1)])
sage: square
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 4 vertices
sage: square.triangulate()
(<0,1,3>, <0,2,3>)

If you are more serious about triangulations, this should get you started. As usual, the online help is your friend if you want to know more:

sage: pc = PointConfiguration([(0,0), (1,0), (0,1), (1,1)])
sage: pc
A point configuration in QQ^2 consisting of 4 points. The triangulations of this point configuration are assumed to be connected, not necessarily fine, not necessarily regular.
sage: pc.triangulations_list()
[(<0,1,2>, <1,2,3>), (<0,1,3>, <0,2,3>)]
edit flag offensive delete link more

Comments

Thanks for the suggestion. Unfortunately, I am working in a setting where taking the convex hull of the vertices of my polygon is not what I want to do. (My polygons have holes in them.)

Bill gravatar imageBill ( 2012-04-05 11:41:30 +0200 )edit

I don't think Sage has anything for non-convex polygons. One should implement Chazelle's algorithm, I suppose (http://wiki.xomb.org/images/0/09/Chazelle_PolygonCutting.pdf)

Volker Braun gravatar imageVolker Braun ( 2012-04-05 12:21:24 +0200 )edit

I will look at that algorithm. Thanks.

Bill gravatar imageBill ( 2012-04-05 14:29:07 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-04-05 01:56:02 +0200

Seen: 932 times

Last updated: Apr 05 '12