R/golden_ratio.R

Defines functions golden_ratio

Documented in golden_ratio

#' Calculate the Golden Ratio
#'
#' Divide a length using the golden ratio.
#' @param x The sum of the two quantities to be in the golden ratio.
#' @return A numeric vector of length 2, containing the two quantities \emph{a}
#' and \emph{b}, \emph{a}  being the larger.
#' @family bits and pieces
#' @export
#' @examples
#' golden_ratio(10)
golden_ratio <- function(x) {
  golden_ratio <- (1 + sqrt(5)) / 2
  a <- x / golden_ratio
  b <- x - a
  return(list(a = a, b = b))
}

Try the fritools package in your browser

Any scripts or data that you put into this service are public.

fritools documentation built on Nov. 19, 2023, 1:06 a.m.