star_scale: Compute regular star polygon scale or angles

View source: R/star_scale.R

star_scaleR Documentation

Compute regular star polygon scale or angles

Description

star_scale() computes star scale value given an internal or external angle. star_angle() computes star angle (internal or external) given a scale value.

Usage

star_scale(n_vertices, angle, external = FALSE)

star_angle(n_vertices, scale, external = FALSE)

Arguments

n_vertices

Number of exterior vertices.

angle

Angle in degrees.

external

If TRUE angle should be considered an external angle.

scale

Scale from 0 to 1.

Details

grid.pattern_regular_polygon() parameterizes regular star polygons with the number of its external vertices and a scale that equals the fraction of the radius of the circle that circumscribes the interior vertices divided by the radius of the circle that circumscribes the exterior vertices. These helper functions help convert between that parameterization and either the internal or external angle of the regular star polygon.

Value

star_scale() returns a numeric value between 0 and 1 intended for use as the scale argument in grid.pattern_regular_polygon(). star_angle() returns a numeric value between 0 and 360 (degrees).

Examples

  # |8/3| star has internal angle 45 degrees and external angle 90 degrees
  scale <- star_scale(8, 45)
  scale2 <- star_scale(8, 90, external = TRUE)
  all.equal(scale, scale2)
  star_angle(8, scale)
  star_angle(8, scale, external = TRUE)

  if (require("grid")) {
    grid.pattern_regular_polygon(shape = "star8", scale = scale, angle = 0,
                                 spacing = 0.2, density = 0.8)
  }


gridpattern documentation built on Oct. 26, 2023, 1:07 a.m.