sl.elem2linepairs: Extract Unique Edges from Triangular Mesh

View source: R/sl.elem2linepairs.R

sl.elem2linepairsR Documentation

Extract Unique Edges from Triangular Mesh

Description

Extract unique lines from elements (polygons) of an unstructured mesh. Useful for plotting to half the figure size (vector format). By default, the edges are concatenated and returned as a vector composed of segments divided by NAs.

Usage

sl.elem2linepairs(elem, concat = TRUE, verbose = FALSE)

Arguments

elem

an Nx3 matrix with the node indices of the triangular elements of an unstructured mesh.

concat

a logical value indicating whether the resulting unique edges are concatenated and returned as a vector composed of segments divided by NAs. This can be computationally advantageous, for example for line plotting. Otherwise, a two-column matrix with each row giving one pair of nodes is returned.

verbose

a logical value indicating whether print statements shall report on the function progess.

Value

If concat=TRUE (default), the resulting unique edges are concatenated and returned as a vector composed of segments divided by NAs. Otherwise, a two-column matrix with each row giving one pair of nodes is returned.

Author(s)

Helge Goessling

Examples

elem = matrix(c(c(1,2,3),c(3,2,4),c(4,2,5),c(5,2,6)),ncol=3,byrow=TRUE)

sl.elem2linepairs(elem,concat=TRUE)
## Should return:
## [1]  1  2  3  4  5  6  2  4 NA  1  3 NA  2  5

sl.elem2linepairs(elem,concat=FALSE)
## Should return:
##       [,1] [,2]
##  [1,]    1    2
##  [2,]    1    3
##  [3,]    2    3
##  [4,]    2    4
##  [5,]    2    5
##  [6,]    2    6
##  [7,]    3    4
##  [8,]    4    5
##  [9,]    5    6

FESOM/spheRlab documentation built on April 6, 2024, 6:52 p.m.