function z = atan2dx(y, x)
% atan2d with quadrant symmetries enforced
  q1 = abs(y) > abs(x); t = y(q1); y(q1) = x(q1); x(q1) = t;
  q2 = x < 0; x(q2) = -x(q2);
  q = 2 * q1 + q2;
  z = atan2(y, x) / (pi / 180);         % z in [-45, 45]
  % t = q == 0;             z(t) =      + z(t);
  t = q == 1 & ~signbit(y); z(t) =  180 - z(t);
  t = q == 1 &  signbit(y); z(t) = -180 - z(t);
  t = q == 2;               z(t) =   90 - z(t);
  t = q == 3;               z(t) =  -90 + z(t);

  % Special values follow the specifications for atan2Pi in IEEE Std 754-2008
  % [x,y] = meshgrid([-inf -1 -0 0 1 inf nan], [nan inf 1 0 -0 -1 -inf]);
  % atan2dx(y,x) ->
  % [nan   nan   nan   nan   nan   nan   nan;
  %  135    90    90    90    90    45   nan;
  %  180   135    90    90    45     0   nan;
  %  180   180   180     0     0     0   nan;
  % -180  -180  -180    -0    -0    -0   nan;
  % -180  -135   -90   -90   -45    -0   nan;
  % -135   -90   -90   -90   -90   -45   nan]
end