Skip to contents

These functions checks certain aspects of a polygons topology. They all operate only on the outer boundary of a polygon and thus ignores all holes it may have. A convex polygon is one whose boundary exclusively have the same turn direction as it is traversed. A simply polygon is a polygon with no intersections between its edges except at the end points of neighboring edges). A relatively simple polygon is like a simple polygon except it allows a shared end point between non-neighboring edges, with the requirement that it remains orientable (it must not "cross over" at a vertex). A relatively simple polygon is always simple. Relative simplicity is one of the requirements of rings in a valid polygon.

Usage

is_convex(x)

is_simple(x)

is_relatively_simple(x)

Arguments

x

A polyclid_polygon vector

Value

a logical vector of the same length as x

Examples


square <- polygon(
  c(0, 10, 10, 0),
  c(0, 0, 10, 10)
)
cross <- polygon(
  c(0, 10, 10, 0),
  c(0, 10, 0, 10)
)
butterfly <- polygon(
  c(0, 5, 10, 10, 5, 0),
  c(0, 5, 0, 10, 5, 10)
)
cross2 <- polygon(
  c(0, 5, 10, 10, 5, 0),
  c(0, 5, 10, 0, 5, 10)
)
is_convex(square)
#> [1] TRUE
is_convex(cross)
#> [1] FALSE
is_convex(butterfly)
#> [1] FALSE
is_convex(cross2)
#> [1] FALSE

is_simple(square)
#> [1] TRUE
is_simple(cross)
#> [1] FALSE
is_simple(butterfly)
#> [1] FALSE
is_simple(cross2)
#> [1] FALSE

is_relatively_simple(square)
#> [1] TRUE
is_relatively_simple(cross)
#> [1] FALSE
is_relatively_simple(butterfly)
#> [1] TRUE
is_relatively_simple(cross2)
#> [1] TRUE