function [xNew,yNew] = Centralize(x,y)
% x and y are column n-vectors that define the vertices of a polygon P.
% xNew and yNew are the vertices of a polygon obtained by translating
% P so that its centroid is at (0,0).

n = length(x);

% Compute the centroid...
xBar = sum(x)/n; yBar = sum(y)/n;

% Translate the polygon...
xNew = x-xBar; yNew = y-yBar;