Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function called DartNumbers() that takes the location of darts thrown as an input, and finds the number of darts that hit the regions
Write a function called DartNumbers() that takes the location of darts thrown as an input, and finds the number of darts that hit the regions yellow, red, blue, and green. A 2020 square dart board, as shown in the image below, consists of concentric circles with the center at (0,0). The radius of the yellow circle is 3 , the red circle is 5 , and the blue circle is 10. A dart which hits exactly on the line between two colors is scored as the lower of the two scores. A dart player throws 10 darts at the board randomly such that any place on the board can be hit with an equal chance. The rand() function can be used to obtain a number with uniform distribution between - 10 Jand 10. Uniform distribution with a given interval means that an equal probability exists to get a number in that interval. The inputs of the function DartNumbers( ) are: throwX: Indicates the X positions of the darts on the board. throw X is a 110 artay of random numbers between 10 and 10 with a uniform distribution using the rand function. throwY: Indicates the y positions of the darts on the board, throwY is a 110 array of random numbers between - 10 and 10 with a uniform distribution using the rand function. The outputs of the function DartNumbers consist of four numerical scalars (ex: a 11 numerical array): yollow. A numerical scalar of the number of darts in the yellow region. red: A numerical scalar of the number of darts in the red region. blue: A numerical scalar of the number of darts in the blue region. green: A numerical scalar of the number of darts in the green reglon. Hint: For each point of throwX and throwy, calculate the radius r=r2+y2. which is the distance from the center (0,0) to the point (x,y). Use this radius array and logical indexing to find the number of points in each region. The radil of the three circles on the chart board are 3 , 5, and 10. Thus, if a point has distance 3.45, the point lies between circles of radius 3 and 5, which is the red region. Restrictions: Do not use if statements or switch statements. Logical indexing should be used. Code to call your function 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started