Learn R Programming

ads (version 1.4)

triangulate: Triangulate polygon

Description

Function triangulate decomposes a simple polygon (optionally having holes) into contiguous triangles.

Usage

triangulate(outer.poly, holes)

Arguments

outer.poly
a list with two component vectors x and y giving vertice coordinates of the polygon or a vector (xmin,ymin,xmax,ymax) giving coordinates $(ximn,ymin)$ and $(xmax,ymax)$ of the origin and the opposite corner of a
holes
(optional) a list (or a list of list) with two component vectors x and y giving vertices coordinates of inner polygon(s) delineating hole(s) within the outer.poly.

Value

  • A list of 6 variables, suitable for using in swin and spp, and giving the vertices coordinates $(ax,ay,bx,by,cx,cy)$ of the triangles that pave the polygon. For a polygon with t holes totalling $n$ vertices (outer contour + holes), the number of triangles produced is $(n-2)+2t$, with $n<200$ in="" this="" version="" of="" the="" program.<="" li="">

encoding

latin1

Details

In argument outer.poly, the vertices must be listed following boundary of the polygon without any repetition (i.e. do not repeat the first vertex). Argument holes may be a list of vertices coordinates of a single hole (i.e. with $x$ and $y$ component vectors) or a list of list for multiple holes, where each holes[[i]] is a list with $x$ and $y$ component vectors. Holes' vertices must all be inside the outer.poly boundary (vertices on the boundary are considered outside). Multiple holes do not overlap each others.

References

Goreaud, F. and P�lissier, R. 1999. On explicit formula of edge effect correction for Ripley's K-function. Journal of Vegetation Science, 10:433-438. Narkhede, A. & Manocha, D. 1995. Fast polygon triangulation based on Seidel's algoritm. Pp 394-397 In A.W. Paeth (Ed.) Graphics Gems V. Academic Press. http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html.

See Also

spp, swin

Examples

Run this code
data(BPoirier)
  BP <- BPoirier
  plot(BP$poly1$x, BP$poly1$y)
  
  # a single polygon triangulation
  tri1 <- triangulate(BP$poly1)
  plot(swin(BP$rect, tri1))
  
  # a single polygon with a hole
  tri2 <- triangulate(c(-10,-10,120,100), BP$poly1)
  plot(swin(c(-10,-10,120,100), tri2))

Run the code above in your browser using DataLab