{{ message }}

Instantly share code, notes, and snippets.

🎯
Focusing
Last active Jan 8, 2019
Hat number 3 in R
View hat3.R
 x <- function(k, t) { c( -sin(4*pi*k/1000) + sin(t)*sin(t/3)/5, -0.5*sin(8*pi*k/1000) + cos(t)/2 ) } y <- function(k, t) { c( -cos(2*pi*k/1000) + cos(t)*cos(t/3)/2, -0.5*cos(4*pi*k/1000) + sin(t)/3
Created Jan 19, 2019
Program to generate a Pentalath/Ndengrod board using original layout
View pentalath-board.R
 library(ggplot2) hexdf <- function (size = 1, mid = c(0, 0), angle = 90) { width <- size * 1 height <- size * 0.865 xy <- shape:::getellipse(width, height, mid = mid, dr = 2 * pi/6) tibble::as_tibble(structure(as.data.frame( shape::rotatexy(xy,angle = angle, mid = mid)), class = "data.frame", names = c("x", "y")), validate = FALSE) }
Created Jan 19, 2019
Program to generate a Yavalath board
View yavalath-board.R
 # Yavalath board library(ggplot2) hexdf <- function (size = 1, mid = c(0, 0), angle = 90) { width <- size * 1 height <- size * 0.865 xy <- shape:::getellipse(width, height, mid = mid, dr = 2 * pi/6) tibble::as_tibble(structure(as.data.frame( shape::rotatexy(xy,angle = angle, mid = mid)), class = "data.frame", names = c("x", "y")), validate = FALSE)
Last active Jan 21, 2019
Three circles
View three_circles.R
 circleFunc <- function(center = c(0,0), diameter = 1, npoints = 100, start = 0, end = 2*pi) { tt <- seq(start, end, length.out = npoints) data.frame(x = center + diameter / 2 * cos(tt), y = center + diameter / 2 * sin(tt)) } add.alpha <- function(col, alpha = 1) { if(missing(col)) stop("Please provide a vector colors.")
Created Jan 26, 2019
Lots of circle placed in a larger circle with some noise
View noisyCircles.R
 library(ggplot2) circle_alpha <- 0.3 radius1 <- 25 radius2 <- 75 how_many <- 200 reverse_colors <- FALSE circleFunc <- function(center = c(0,0), radius = 1, npoints = 100, start = 0, end = 2*pi) {
Created Mar 28, 2019
View polygon.R
 polygon <- function(n) { tibble( x = accumulate(1:(n-1), ~.x+cos(.y*2*pi/n), .init = 0), y = accumulate(1:(n-1), ~.x+sin(.y*2*pi/n), .init = 0), xend = accumulate(2:n, ~.x+cos(.y*2*pi/n), .init = cos(2*pi/n)), yend = accumulate(2:n, ~.x+sin(.y*2*pi/n), .init = sin(2*pi/n))) } ggplot(polygon(5) + geom_segment(aes(x=x, y=y, xend=xend, yend=yend)) + theme_void() + coord_equal()
Created Apr 7, 2019