public static void CartesianToPolar(Point center, Point point, out double radius, out double degree)
        {
            var d = point - center;

            radius = d.Length;
            degree = GunTraverseHelper.NormalizeAngle(-Math.Atan2(d.Y, d.X) * 180 / Math.PI);
        }
        public static double RotateAngle(double from, double to, double delta, double limitRight, double limitLeft)
        {
            from = GunTraverseHelper.NormalizeAngle(from);
            to   = GunTraverseHelper.NormalizeAngle(to);

            if (Math.Abs(from - to) < 0.0001)
            {
                return(to);
            }

            delta = GunTraverseHelper.NormalizeAngle(delta);
            double direction;

            if (from < to)
            {
                if (limitRight + limitLeft < 360 &&
                    from <= limitRight &&
                    to >= 360 - limitLeft)
                {
                    direction = -1.0;
                }
                else if (to - from > 180)
                {
                    direction = -1.0;
                }
                else
                {
                    direction = 1.0;
                }
            }
            else
            {
                if (limitRight + limitLeft < 360 &&
                    to <= limitRight &&
                    from >= 360 - limitLeft)
                {
                    direction = 1.0;
                }
                else if (from - to > 180)
                {
                    direction = 1.0;
                }
                else
                {
                    direction = -1.0;
                }
            }

            var result = from + delta * direction;

            if ((from < to && result > to) || (from > to && result < to))
            {
                result = to;
            }

            return(result);
        }