Title: | Triangle - A 2D Quality Mesh Generator and Delaunay Triangulator |
---|---|
Description: | This is a port of Jonathan Shewchuk's Triangle library to R. From his description: "Triangle generates exact Delaunay triangulations, constrained Delaunay triangulations, conforming Delaunay triangulations, Voronoi diagrams, and high-quality triangular meshes. The latter can be generated with no small or large angles, and are thus suitable for finite element analysis." |
Authors: | Jonathan Richard Shewchuk [ctb, cph], David C. Sterratt [cph, aut, cre], Elias Pipping [ctb], Michael Sumner [ctb] |
Maintainer: | David C. Sterratt <[email protected]> |
License: | CC BY-NC-SA 4.0 |
Version: | 1.6-0.14 |
Built: | 2024-11-04 05:34:31 UTC |
Source: | https://github.com/davidcsterratt/rtriangle |
Generate 2D Quality meshes and constrained Delaunay triangulations
This package is a wrapper of Jonathan Richard Shewchuk's Triangle
package. triangulate
triangulates a Planar
Straight Line Graph (PSLG), a collection of vertices and
segments created with pslg
. A mesh in the can be
created within an arbitrary closed outline and the maximum area
and minimum angle of the triangles in the mesh can be specified.
David C. Sterratt [email protected]
Jonathan Richard Shewchuk, Triangle: Engineering a 2D Quality Mesh Generator and Delaunay Triangulator, in “Applied Computational Geometry: Towards Geometric Engineering” (Ming C. Lin and Dinesh Manocha, editors), volume 1148 of Lecture Notes in Computer Science, pages 203-222, Springer-Verlag, Berlin, May 1996. (From the First ACM Workshop on Applied Computational Geometry.)
Jonathan Richard Shewchuk, Delaunay Refinement Algorithms for Triangular Mesh Generation, Computational Geometry: Theory and Applications 22(1-3):21-74, May 2002.
## Create an object with a concavity p <- pslg(P=rbind(c(0, 0), c(0, 1), c(0.5, 0.5), c(1, 1), c(1, 0)), S=rbind(c(1, 2), c(2, 3), c(3, 4), c(4, 5), c(5, 1))) ## Plot it plot(p) ## Triangulate it tp <- triangulate(p) plot(tp) ## Triangulate it subject to minimum area constraint tp <- triangulate(p, a=0.01) plot(tp) ## Load a data set containing a hole A <- read.pslg(file.path(system.file(package = "RTriangle"), "extdata", "A.poly")) plot(A) ## Triangulate the PSLG tA <- triangulate(A) plot(tA) ## Triangulate the PSLG with triangles in which no angle ## is smaller than 20 degrees tA <- triangulate(A, q=20) plot(tA) ## Triangulate the PSLG with triangles in which no triangle has ## area greater than 0.001 tA <- triangulate(A, a=0.001) plot(tA)
## Create an object with a concavity p <- pslg(P=rbind(c(0, 0), c(0, 1), c(0.5, 0.5), c(1, 1), c(1, 0)), S=rbind(c(1, 2), c(2, 3), c(3, 4), c(4, 5), c(5, 1))) ## Plot it plot(p) ## Triangulate it tp <- triangulate(p) plot(tp) ## Triangulate it subject to minimum area constraint tp <- triangulate(p, a=0.01) plot(tp) ## Load a data set containing a hole A <- read.pslg(file.path(system.file(package = "RTriangle"), "extdata", "A.poly")) plot(A) ## Triangulate the PSLG tA <- triangulate(A) plot(tA) ## Triangulate the PSLG with triangles in which no angle ## is smaller than 20 degrees tA <- triangulate(A, q=20) plot(tA) ## Triangulate the PSLG with triangles in which no triangle has ## area greater than 0.001 tA <- triangulate(A, a=0.001) plot(tA)
Plot pslg
object
## S3 method for class 'pslg' plot(x, ...)
## S3 method for class 'pslg' plot(x, ...)
x |
|
... |
Arguments to be passed to methods. |
David Sterratt
Plots a triangulation object produced with triangulate
## S3 method for class 'triangulation' plot(x, ...)
## S3 method for class 'triangulation' plot(x, ...)
x |
Triangulation object produced with |
... |
Arguments to be passed to methods. |
David Sterratt
A Planar Straight Line Graph (PSLG) is a collection of vertices and segments. Segments are edges whose endpoints are vertices in the PSLG, and whose presence in any mesh generated from the PSLG is enforced.
pslg(P, PB = NA, PA = NA, S = NA, SB = NA, H = NA)
pslg(P, PB = NA, PA = NA, S = NA, SB = NA, H = NA)
P |
A 2-column matrix of x-y co-ordinates of vertices. There is one row per vertex. |
PB |
Vector of boundary markers of vertices. For each
vertex this is 1 if the point should be on a boundary of any mesh
generated from the PSLG and 0 otherwise. There should be as many
elements in |
PA |
Matrix of attributes which are typically
floating-point values of physical quantities (such as mass or
conductivity) associated with the nodes of a finite element
mesh. When triangulating using |
S |
A 2-column matrix of segments in which each row is
a segment. Segments are edges whose endpoints are vertices
in the PSLG, and whose presence in any mesh generated from the
PSLG is enforced. Each segment refers to the indices in |
SB |
Vector of boundary markers of segments. For each segment
this is 1 if the segment should be on a boundary of any mesh
generated from the PSLG and 0 otherwise. There should be as many
elements in |
H |
2-column matrix of holes, with one hole per row.Holes are specified by identifying a point inside each hole. After the triangulation is formed, Triangle creates holes by eating triangles, spreading out from each hole point until its progress is blocked by PSLG segments; you must be careful to enclose each hole in segments, or your whole triangulation might be eaten away. If the two triangles abutting a segment are eaten, the segment itself is also eaten. Do not place a hole directly on a segment; if you do, Triangle will choose one side of the segment arbitrarily. |
An object containing the input of type pslg
that
contains the information supplied in the inputs. This function
does some sanity checking of its inputs.
David Sterratt
Read a Planar Straight Line Graph from a .poly
file, as
used in Shewchuk's Triangle library
(http://www.cs.cmu.edu/~quake/triangle.poly.html).
read.pslg(file)
read.pslg(file)
file |
File name of |
pslg
object. See pslg
.
David Sterratt
Triangulate a planar straight line graph using the Triangle
library (http://www.cs.cmu.edu/~quake/triangle.html). The
triangulation is a constrained conforming Delaunay triangulation
in which additional vertices, called Steiner points, can be
inserted into segments to improved the quality of the
triangulation. To prevent the insertion of Steiner points on
boundary segments, specify Y=TRUE
. If the maximum triangle
area a
is specified, the area of each triangle is not
allowed to exceed this value. If the the minimum angle q
is
specified, no triangle angle is allowed to be below this value.
triangulate( p, a = NULL, q = NULL, Y = FALSE, j = FALSE, D = FALSE, S = 10000, V = 0, Q = TRUE )
triangulate( p, a = NULL, q = NULL, Y = FALSE, j = FALSE, D = FALSE, S = 10000, V = 0, Q = TRUE )
p |
Planar straight line graph object; see
|
a |
Maximum triangle area. If specified, triangles cannot be larger than this area. |
q |
Minimum triangle angle in degrees. |
Y |
If |
j |
If |
D |
If |
S |
Specifies the maximum number of added Steiner points. If
set to |
V |
Verbosity level. Specify higher values for more detailed information about what the Triangle library is doing. |
Q |
If |
A object with class triangulation
. This contains
the information in the same format as the PSLG, p
, with
an updated list of points P
and point attributes
PA
, along with the following variables:
T |
Triangulation specified as 3 column matrix
in which each row contains indices in |
E |
Set of edges in the triangulation. |
EB |
Boundary markers of edges. For each edge this is 1 if the point is on a boundary of the triangulation and 0 otherwise. |
VP |
The points of the Voronoi tessalation as a 2-column matrix |
VE |
Set of edges of the Voronoi tessalation. An index of -1 indicates an infinite ray. |
VN |
Directions of infinite rays of Voroni tessalation as a 2-column matrix with the same number of rows as |
VA |
Matrix of attributes associated with the polygons of the Voronoi tessalation. |
David Sterratt
## Create an object with a concavity p <- pslg(P=rbind(c(0, 0), c(0, 1), c(0.5, 0.5), c(1, 1), c(1, 0)), S=rbind(c(1, 2), c(2, 3), c(3, 4), c(4, 5), c(5, 1))) ## Plot it plot(p) ## Triangulate it tp <- triangulate(p) plot(tp) ## Triangulate it subject to minimum area constraint tp <- triangulate(p, a=0.01) plot(tp) ## Load a data set containing a hole A <- read.pslg(file.path(system.file(package = "RTriangle"), "extdata", "A.poly")) plot(A) ## Produce a constrained Delaunay triangulation of the PSLG tA <- triangulate(A, Y=TRUE) plot(tA) ## Produce a conforming Delaunay triangulation of the PSLG tA <- triangulate(A, D=TRUE) plot(tA) ## Triangulate the PSLG with triangles in which no angle ## is smaller than 20 degrees tA <- triangulate(A, q=20) plot(tA) ## Triangulate the PSLG with triangles in which no triangle has ## area greater than 0.001 tA <- triangulate(A, a=0.001) plot(tA)
## Create an object with a concavity p <- pslg(P=rbind(c(0, 0), c(0, 1), c(0.5, 0.5), c(1, 1), c(1, 0)), S=rbind(c(1, 2), c(2, 3), c(3, 4), c(4, 5), c(5, 1))) ## Plot it plot(p) ## Triangulate it tp <- triangulate(p) plot(tp) ## Triangulate it subject to minimum area constraint tp <- triangulate(p, a=0.01) plot(tp) ## Load a data set containing a hole A <- read.pslg(file.path(system.file(package = "RTriangle"), "extdata", "A.poly")) plot(A) ## Produce a constrained Delaunay triangulation of the PSLG tA <- triangulate(A, Y=TRUE) plot(tA) ## Produce a conforming Delaunay triangulation of the PSLG tA <- triangulate(A, D=TRUE) plot(tA) ## Triangulate the PSLG with triangles in which no angle ## is smaller than 20 degrees tA <- triangulate(A, q=20) plot(tA) ## Triangulate the PSLG with triangles in which no triangle has ## area greater than 0.001 tA <- triangulate(A, a=0.001) plot(tA)