function f = passive_obstacle_avoidance(x0, obstacles)

f = [0;0;0];

n = size(obstacles,3);
for i=1:n
   obs = obstacles(:,:,i);
   
   centroid = mean(obs,2);
   obs = obs - centroid;
   
   u = max(obs, [], 2);
   l = min(obs, [], 2);
   
   vol = 1;
   for j=1:3
     vol = vol * (u(j) - l(j));
   end
   
   dir = x0 - centroid;
   dist = sqrt(dir'*dir);
   dir = dir / dist;
   
   f = f + dir*vol / dist;
end

% Correct for being pushed too far up or down
f = f + 50*[0; 0; -(x0(3) - 5)];

end

