#' Get coordination of spiral curve
#' @param theta a numeric vector of radius.
#' @param a,b scalar numeric value that control the shape of the spiral curve.
#' @param clockwise logical, direction of rotation of the spiral curve.
#' @rdname arch_spiral
#' @examples
#' arch_spiral(seq(0, 2 * pi, length.out = 200))
#' arch_spiral(seq(0, 2 * pi, length.out = 200), clockwise = TRUE)
#' @author Houyun Huang
#' @export
arch_spiral <- function(theta, a = 0.2, b = 0.1, clockwise = FALSE) {
t <- (a + b * theta)
if(identical(clockwise, TRUE)) {
x <- t * sin(theta)
y <- t * cos(theta)
} else {
x <- t * cos(theta)
y <- t * sin(theta)
}
angle <- if(clockwise) {
(atan2(y, x) * 180 / pi) %% 360
} else {
(theta * 180 / pi) %% 360
}
data.frame(x = x,
y = y,
angle = angle)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.