You are on page 1of 3

R Notebook

Question 1
Assumptions:
- Both the fox and the rabbit run with constant speeds sf 0=16 m/s and sr 0=13 m/s
respectively.
- The rabbit is considered to be captured by the fox, if the distance between them is smaller
than or equal to 0.1 meter.
- The fox is initially located at (−250 ,−550 ) and the rabbit is initially located at the origin
( 0 , 0 ) . - The rabbit’s burrow is located at (−600 , 600 ) .

- The fox pursues the rabbit with the initial speed sf 0=16 m/s in one of the following two
possible ways:
- If the rabbit is in sight, the fox’s attack path points directly towards the rabbit (the
direction of the velocity vector of the fox is exact from the fox to the rabbit).
- If the view of the rabbit is blocked by the corner S of an impenetrable warehouse
(assuming that the warehouse is extended indefinitely to the west), then the fox runs
directly towards this corner. If the rabbit is still not in sight when the corner is reached,
then the fox moves parallel to the N-S perimeter of the warehouse until it sees the rabbit.
The fox is initially located at (−250 ,−550 ) and the rabbit is initially located at ( 0 , 0 ) . The
rabbit runs towards its burrow at (−600 , 600 ) in a straight line with initial speed s 0=13 The
fox pursues the rabbit with the initial speed s 0=16 in one of the following two possible
ways:
• if the rabbit is in sight, the fox’s attack path points directly towards the rabbit (the
direction of the velocity vector of the fox is exact from the fox to the rabbit);
• if the view of the rabbit is blocked by the corner S of an impenetrable warehouse
(assuming that the warehouse is extended indefinitely to the west), then the fox
runs directly towards this corner. If the rabbit is still not in sight when the corner is
reached, then the fox moves parallel to the N-S perimeter of the warehouse until it
sees the rabbit.
The rabbit can be captured before it reaches its burrow. The time $T$ and the location of
the fox when either the rabbit is captured or the rabbit escapes to the burrow are as
follows:

• Location of the fox: ( F x , F y ) =(−250−16 t ,−550−16 t )

The distance travelled by the fox in time T is as follows:


• Distance travelled by the fox: d=16 t=16∗0.00625

Question 2

Code:
Q1
% initial configuration

syms t

d=0.1; % distance threshold for capture

% fox

v_f=16; % initial speed

F_x=-250-v_f*t; % x-coordinate of fox


F_y=-550-v_f*t; % y-coordinate of fox

% rabbit

v_r=13; % initial speed

R_x=v_r*t; % x-coordinate of rabbit


R_y=v_r*t; % y-coordinate of rabbit

% burrow

B_x=-600;
B_y=600;

% time of capture/escape

T=d/v_f;

% distance travelled by fox

d=v_f*T;

% plot

ezplot(F_x,[-250,-550])
hold on

ezplot(F_y,[-250,-550])

ezplot(R_x,[0,13])

ezplot(R_y,[0,13])

plot(B_x,B_y,'o')

hold off

axis([-850 50 -850 850])

legend('Fox','Rabbit','Burrow')

xlabel('x-coordinate (m)')

ylabel('y-coordinate (m)')

You might also like