private Vector2 EnsureInPrintBounds(PrinterSettings printerSettings, Vector2 probePosition)
        {
            // check that the position is within the printing area and if not move it back in
            if (printerSettings.Helpers.UseZProbe())
            {
                var probeOffset          = printer.Settings.GetValue <Vector2>(SettingsKey.z_probe_xy_offset);
                var actualNozzlePosition = probePosition - probeOffset;

                // clamp this to the bed bounds
                Vector2         bedSize          = printer.Settings.GetValue <Vector2>(SettingsKey.bed_size);
                Vector2         printCenter      = printer.Settings.GetValue <Vector2>(SettingsKey.print_center);
                RectangleDouble bedBounds        = new RectangleDouble(printCenter - bedSize / 2, printCenter + bedSize / 2);
                Vector2         adjustedPosition = bedBounds.Clamp(actualNozzlePosition);

                // and push it back into the probePosition
                probePosition = adjustedPosition + probeOffset;
            }

            return(probePosition);
        }
        public static Vector2 EnsureInPrintBounds(PrinterConfig printer, Vector2 probePosition)
        {
            // check that the position is within the printing area and if not move it back in
            if (printer.Settings.Helpers.UseZProbe())
            {
                var probeOffset2D        = new Vector2(printer.Settings.GetValue <Vector3>(SettingsKey.probe_offset));
                var actualNozzlePosition = probePosition - probeOffset2D;

                // clamp this to the bed bounds
                Vector2 bedSize     = printer.Settings.GetValue <Vector2>(SettingsKey.bed_size);
                Vector2 printCenter = printer.Settings.GetValue <Vector2>(SettingsKey.print_center);
                var     bedBounds   = new RectangleDouble(printCenter - bedSize / 2, printCenter + bedSize / 2);
                bedBounds.Inflate(-1);
                Vector2 adjustedPosition = bedBounds.Clamp(actualNozzlePosition);

                // and push it back into the probePosition
                probePosition = adjustedPosition + probeOffset2D;
            }

            return(probePosition);
        }