anglePolygon: Internal angles of a polygon

Description Usage Arguments Details Value Author(s) References Examples

View source: R/anglePolygon.R

Description

This function computes the internal angles of a polygon, given the coordinates of its vertices.

Usage

1
anglePolygon(point, degree = FALSE)

Arguments

point

a list containing coordinates of the polygon vertices in either clockwise or anti-clockwise direction

degree

if TRUE, returns the internal angles in degrees instead of radians

Details

The sum of all the internal angles of a polygon with n-vertices must be equal to the product of n-2 with 180 (degrees) or pi (radians). This function is useful for detecting tps data files that contain errors (e.g. wrong sequence of digitizing landmarks, missing landmarks) so that corrective steps can be taken.

Value

A list with two components:

angle

a matrix; the rows represents the vertices and the columns contain the latters' geometrical information: first column for x coordinate, second column for y coordinate, and third column for the assocaited internal angle (in radians)

orientation

a character indicating the direction of ordering the vertices: m for anti-clockwise and p for clockwise

Author(s)

Thian Liang Cheow Tl2cheow@yahoo.com

References

Khang TF, Soo OYM, Tan WB, Lim LHS. (2016). Monogenean anchor morphometry: systematic value, phylogenetic signal, and evolution. PeerJ 4:e1668.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#internal angles of a right-angled triangle in degrees
anglePolygon(list(c(0,1),c(0,0),c(1,0)),degree=TRUE)

data(ligophorus_tpsdata)

#polygonal approximation of anchor shape
#the right ventral anchor
anchorpolygon <- anglePolygon(matrix2list(ligophorus_tpsdata$bantingensis[[1]][1:11,]), degree=TRUE)

#there are 11 landmarks, do the sum of internal angles should be (11-2)x180 = 1620
sum(anchorpolygon$angle[,3])

#does this make sense?
polyVis(1, havelist=TRUE, listdata=ligophorus_tpsdata$bantingensis)

monogeneaGM documentation built on May 29, 2017, 9:18 p.m.