Premium Essay

> polygon(.5*sin(a),.5*cos(a),col="red")

Dart game – CompTools2012 user guide

In this user guide we are going to solve some problems related to the dart game. Follow us step by step and enjoy the game! We want to build a target face for throwing darts, like the one in the figure. We assume that it is a circle of radius 1 with center in the origin point. For the construction of the target, the reference is paragraph 6.2 of Using R for scientific computing by Karline Soetaert. We present here the necessary script:

> a plot(cos(a),sin(a),type="l",lwd=2,xlab="" ,ylab="",axes=T, asp=1) Ten Inner circles at equal distance: > for (i in seq( 0.1,0.9,by=0.1)) lines(i*sin(a), i*cos(a)) >polygon(sin(a)*0.1,cos(a)*0.1,col="red") > for (i in 1:10) text(x = 0, y = i/100.025, labels = 11-i, font = 2) >for (i in 1:9) text(x = 0, y = -1 + (i/10-0.025), labels = i, font = 2)

The polygon command will cover the inner circles: launch again the previous for loops to obtain the following image:

> for (i in seq( 0.1,0.9,by=0.1)) lines(i*sin(a), i*cos(a)) > for (i in 1:10) text(x = 0, y = i/100.025, labels = 11-i, font = 2) >for (i in 1:9) text(x = 0, y = -1 + (i/10-0.025), labels = i, font = 2)

1

Croce