Use atan2 to calculate angles instead of acos.