function z = toPolar(x)
  if length(x) == 2
      z = [norm(x), atan2(x(2),x(1))];
  else
      z = [norm(x), angle(x)];
  end
