private void ArcMove(float x, float y, float z, float i, float j, float k, float radius, bool clockwise)
        {
            // Only XY plane supported for now.

            Point            start = new Point(_device.GetCurrentX(), _device.GetCurrentY()), end;
            ArcInterpolation arc = null;

            if (radius == float.MinValue)
            {
                // Center format arc.

                if (i == float.MinValue && j == float.MinValue)
                {
                    Error("G2/3: I and J are missing");
                }

                if (i == float.MinValue)
                {
                    i = 0;
                }
                if (j == float.MinValue)
                {
                    j = 0;
                }
                if (x == float.MinValue)
                {
                    x = _device.GetCurrentX();
                }
                if (y == float.MinValue)
                {
                    y = _device.GetCurrentY();
                }
                if (z == float.MinValue)
                {
                    z = _device.GetCurrentZ();
                }

                Point center = new Point(_device.GetCurrentX() + i, _device.GetCurrentY() + j);
                end = new Point(x, y);

                arc = new ArcInterpolation(start, center, end, clockwise);
            }
            else
            {
                // Radius format arc
                // XYZ are the endpoint. R is the radius.
                if (x == float.MinValue && y == float.MinValue)
                {
                    Error("G2/3: X and Y are missing");
                }

                if (x == float.MinValue)
                {
                    x = _device.GetCurrentX();
                }
                if (y == float.MinValue)
                {
                    y = _device.GetCurrentY();
                }

                if (_distanceMode == DistanceMode.Absolute)
                {
                    end = new Point(x, y);
                }
                else
                {
                    end = new Point(_device.GetCurrentX() + x, _device.GetCurrentY() + y);
                }

                arc = new ArcInterpolation(start, end, radius, clockwise);
            }


            if (arc == null)
            {
                Error("G2/3: could not find an arc solution");
            }

            for (float t = ArcStep; t <= 1.0 + (ArcStep / 2); t += ArcStep)
            {
                Point target = arc.GetArcPoint(t);

                // Only XY supported
                _device.MoveAbsoluteLinear(target.X, target.Y, _device.GetCurrentZ());
            }
        }
        public void MoveArc(float x, float y, float z, float i, float j, float k, float radius, bool clockwise, DistanceMode distanceMode)
        {
            // Only XY plane supported for now.

            Point            start = new Point(_currentX * StepsPerMmX, _currentY * StepsPerMmY), end;
            ArcInterpolation arc = null;

            if (radius == float.MinValue)
            {
                // Center format arc.

                if (i == float.MinValue && j == float.MinValue)
                {
                    throw new Exception("G2/3: I and J are missing");
                }

                if (i == float.MinValue)
                {
                    i = 0;
                }
                if (j == float.MinValue)
                {
                    j = 0;
                }
                if (x == float.MinValue)
                {
                    x = _currentX;
                }
                if (y == float.MinValue)
                {
                    y = _currentY;
                }
                if (z == float.MinValue)
                {
                    z = _currentZ;
                }

                Point center = new Point((_currentX + i) * StepsPerMmX, (_currentY + j) * StepsPerMmY);
                end = new Point(x * StepsPerMmX, y * StepsPerMmY);

                arc = new ArcInterpolation(start, center, end, clockwise);
            }
            else
            {
                // Radius format arc
                // XYZ are the endpoint. R is the radius.
                if (x == float.MinValue && y == float.MinValue)
                {
                    throw new Exception("G2/3: X and Y are missing");
                }

                if (x == float.MinValue)
                {
                    x = _currentX;
                }
                if (y == float.MinValue)
                {
                    y = _currentY;
                }

                if (distanceMode == DistanceMode.Absolute)
                {
                    end = new Point(x * StepsPerMmX, y * StepsPerMmY);
                }
                else
                {
                    end = new Point((_currentX + x) * StepsPerMmX, (_currentY + y) * StepsPerMmY);
                }

                arc = new ArcInterpolation(start, end, radius, clockwise);
            }


            if (arc == null)
            {
                throw new Exception("G2/3: could not find an arc solution");
            }

            const float ArcStep = 0.05f;  // Make sure it's a "multiple" of 1.0f.

            int currentStepsX = (int)start.X;
            int currentStepsY = (int)start.Y;

            for (float t = ArcStep; t <= 1.0 + (ArcStep / 2); t += ArcStep)
            {
                Point target = arc.GetArcPoint(t);

                // Only XY supported
                int targetX = (int)target.X;
                int targetY = (int)target.Y;


                int dx = (int)target.X - currentStepsX;
                int dy = (int)target.Y - currentStepsY;

                MoveAxes(dx, dy);

                currentStepsX += dx;
                currentStepsY += dy;
            }

            _currentX = currentStepsX / StepsPerMmX;
            _currentY = currentStepsY / StepsPerMmY;
        }