AddPointPoly: Adds a point to a previously defined polygon

Description Usage Arguments Value Examples

View source: R/AddPointPoly.R

Description

AddPointPoly creates a matrix to represent the polygon that connects several points

Usage

1
AddPointPoly(Poly, point, position)

Arguments

Poly

Polygon object, previously created with function CreatePolygon or CreateRegularPolygon

point

Vector containing the xy-coordinates of the point to be added to the polygon

position

Integer indicating the position of the point in the original polygon, after which the new point is being added (considering that every polygon is an ordered list of points). It is convenient to visualize the polygon with label = T in order to avoid mistakes

Value

Returns a matrix which contains the points of the polygon. Each row represents one of the points

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x_min <- -5
x_max <- 5
y_min <- -5
y_max <- 5
CoordinatePlane(x_min, x_max, y_min, y_max)
n <- 5
C <- c(0,0)
l <- 2
Penta <- CreateRegularPolygon(n, C, l)
Penta <- AddPointPoly(Penta, CenterPolygon(Penta), 1)
Draw(Penta, "blue", label = TRUE)

Example output


LearnGeom documentation built on July 14, 2020, 5:06 p.m.