compute_polygon_perimeter: Compute polygon perimeter

Description Usage Arguments Value Author(s) Examples

View source: R/compute-polygon-perimeter.R

Description

This function takes in a data frame containing one or more polygons, and computes the perimeter of each polygon

Usage

1

Arguments

vertex.df

A data frame where each row corresponds to the vertex of a polygon. It must contain the columns x, y, and optionally group (must be integer). x and y specify the coordinates of the vertex, and group is used to indicate which polygon the vertex belongs to. If vertex.df contains only a single polygon, group can be omitted.

Value

A data frame that contains two columns:

group

The group number of the polygon

perimeter

The perimeter of the polygon

Author(s)

Mathias Isaksen mathiasleanderi@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Example with multiple polygons
vertex.df = compute_regular_polygons(
  center = data.frame(x = c(0, 10), y = c(0, 0)),
  radius = 1,
  num.edges = c(4, 1000)
)
perimeter.df = compute_polygon_perimeter(vertex.df)

# The perimeters should be around 4*sqrt(2) and 2*pi
print(perimeter.df)

mathiasisaksen/artKIT documentation built on Dec. 21, 2021, 2:52 p.m.