function V = ScatPot2(p,t,u,time)
% Specifies physical potential V.
global posx posy g num

% Triangle point indices
it1 = t(1,:);
it2 = t(2,:);
it3 = t(3,:);
% Find centroids of triangles
x = (p(1,it1) + p(1,it2) + p(1,it3))/3;
y = (p(2,it1) + p(2,it2) + p(2,it3))/3;

if 1 % Gaussian scatterers
sig = 0.68; %1/sqrt(2); % NOTE CAREFULLY: this sets scatterer width. The parameter 'sig' is related BUT NOT EQUAL to \sigma from the paper. It's a simple relation, though: sig/sqrt(2) = \sigma. Thus, to get \sigma=1/2, set sig to 1/sqrt(2), and to get \sigma=0.48, set sig to 0.68.
V = 0;
for n=1:num
    x0 = posx(n)-0.5;
    y0 = posy(n)-0.5;
    V = V + g*exp(-((x-x0).^2 + (y-y0).^2)/sig^2);
end
end
