Graphics Programs Reference
In-Depth Information
50
45
40
35
30
25
20
15
10
5
0
0
5
10
15
20
25
30
35
40
45
50
It is not so clear from the picture where to hide, although it looks like the
Captain has a pretty good chance of surviving a small number of shots.
But 100 shots may be enough to find him. Intuition says he ought to stay
close to the boundary.
(b)
Below is a series of commands that places Picard at the center of the
arena, fires the death ray 100 times, and then determines the health of
Picard. It uses the function lifeordeath , which computes the fate of
the Captain after a single shot.
function r = lifeordeath(x1, y1, x0, y0)
%This file computes the number of illumatons.
%that arrive at the point (x1, y1), assuming the death,
%ray strikes 1 meter above the point (x0, y0).
%If that number exceeds 50, a ''1” is returned in the
%variable ''r”; otherwise a '0” is returned for ''r”.
dosage = 10000/(4*pi*((x1 - x0)ˆ2 + (y1 - y0)ˆ2 + 1));
if dosage > 50
r=1;
 
Search WWH ::




Custom Search