Created
January 6, 2010 17:28
-
-
Save CerebralMastication/270439 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drawBoard <- function() { | |
require(plotrix) # for the draw circle function only | |
plot(-260:260, -260:260, type="n", xlab="", ylab="", asp = 1, main="Dart Board") | |
draw.circle(0, 0, 12.7/2, border="purple", lty=1, lwd=1) # bull | |
draw.circle(0, 0, 31.8/2, border="purple", lty=1, lwd=1) # outer bull | |
draw.circle(0, 0, 107, border="purple", lty=1, lwd=1) | |
draw.circle(0, 0, 99, border="purple", lty=1, lwd=1) | |
draw.circle(0, 0, 162, border="purple", lty=1, lwd=1) | |
draw.circle(0, 0, 170, border="purple", lty=1, lwd=1) | |
draw.circle(0, 0, 107, border="purple", lty=1, lwd=1) | |
draw.circle(0, 0, 99, border="purple", lty=1, lwd=1) | |
draw.circle(0, 0, 451/2, border="black", lty=1, lwd=1) #outer edge of board | |
angle.inc <- 2 * pi/20 # 20 sections in a board | |
angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) | |
angles <- angles - .5 * pi / 10 #dart boards are rotated slightly | |
xSeries <- sin(angles) * 170 | |
ySeries <- cos(angles) * 170 | |
for (i in 1:20){ | |
lines(c(0,xSeries[i]),c(0,ySeries[i] )) | |
} | |
points <- c(20, 1, 18, 4, 13, 6, 10, 15, 2, 17, 3, 19, 7, 16, 8, 11, 14, 9, 12, 5) | |
angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) | |
xSeries <- sin(angles) * 180 | |
ySeries <- cos(angles) * 180 | |
for (i in 1:20){ | |
text(xSeries[i],ySeries[i], points[i] ) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment