Premium Essay

Dart Game – Comptools2012 User Guide

In:

Submitted By excel89
Words 1129
Pages 5
Croce Roberta - Godi Valeria - Zitelli Francesco Basically we have defined a sequence of 1000 angles ranging from 0 to 2π, in radiants; we have plotted them and the result is a circumference. lines draws 9 inner circles, with radius equal to 1 * i, i ranging from 0.1 to 0.9 in sequence. lines apply the shrinking factor i because it relates to i by means of the for loop. The same structure is used to assign numbers to circles, through the function text. Target face and probabilities a) What is the probability of hitting any possible point within the inscribed area of radius ½? To draw the inscribed circle, apply a shrinking factor to both sin(a) and cos(a) in polygon function:
> 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

Similar Documents