Skip to content

Commit

Permalink
quarto vignette builder
Browse files Browse the repository at this point in the history
  • Loading branch information
wjschne committed Jul 18, 2024
1 parent 40677c0 commit 619abc0
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ Collate:
'ellipses.R'
'str.R'
'zzz.R'
VignetteBuilder: knitr
VignetteBuilder: quarto
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(get_tibble_defaults)
export(labeler)
export(nudge)
export(point)
export(polar)
export(radian)
export(round_probability)
export(style)
Expand Down
25 changes: 24 additions & 1 deletion R/points.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Point----

#' point class
#' point
#'
#' Points are specified with x and y coordinates.# Polar class ----
#' @export
#' @param x Coordinate on the x-axis
#' @param y Coordinate on the y-axis
#' @param r Radius = Distance from the origin to the point
Expand Down Expand Up @@ -99,3 +101,24 @@ point <- new_class(
new_object(S7_object(), x = d$x, y = d$y, style = d@style)
}
)


# Polar Point class ----
#' polar
#'
#' Polar points are ordinary points but are specified with an angle (theta) and a radial distance (r)
#' @rdname point
#' @export
polar <- new_class(
name = "polar",
parent = point,
constructor = function(theta = class_missing,
r = class_missing,
style = class_missing,
...) {
if (length(r) == 0) r <- 0
if (length(theta) == 0) theta <- angle(0)

p <- point(theta = theta, r = r, style = style + style(...))
new_object(p)
})
2 changes: 1 addition & 1 deletion man/ggdiagram-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions man/point.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vignettes/angles.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ my_font <- "Roboto Condensed"
```


Angles have different kinds of units associated with them: degrees, radians, and turns. The `angle` class can take turns (i.e., 1 turn = one full rotation a circle), degrees (1 turn = 360 degrees), or radians (1 turn = $2\pi$ = $\tau$).

I like &pi; just fine, but I agree with Michael Hartl's [Tau Manifesto](https://tauday.com/tau-manifesto) that we would have been better off if we had recognized that the number of radians to complete a full turn of a circle (&tau; = 2&pi; &asymp; 6.283185) is more fundamental than the number of radians to complete a half turn (&pi;).

Turns | Radians | Degrees |
:----:|:-------:|:-------:|
$\frac{1}{12}$ | $\frac{\tau}{12}=\frac{\pi}{6}$ | $30^\circ$ |
$\frac{1}{8}$ | $\frac{\tau}{8}=\frac{\pi}{4}$ | $45^\circ$ |
$\frac{1}{6}$ | $\frac{\tau}{6}=\frac{\pi}{3}$ | $60^\circ$ |
$\frac{1}{4}$ | $\frac{\tau}{4}=\frac{\pi}{2}$ | $90^\circ$ |
$\frac{1}{3}$ | $\frac{\tau}{3}=\frac{2\pi}{3}$ | $120^\circ$ |
$\frac{1}{2}$ | $\frac{\tau}{2}=\pi$ | $180^\circ$ |
$1$ | $\tau=2\pi$ | $360^\circ$ |

0 comments on commit 619abc0

Please sign in to comment.