diff --git a/OpenNest.Core/Helper.cs b/OpenNest.Core/Helper.cs index 44aa015..60c3ed6 100644 --- a/OpenNest.Core/Helper.cs +++ b/OpenNest.Core/Helper.cs @@ -11,39 +11,6 @@ namespace OpenNest { public static class Helper { - /// - /// Rounds a number down to the nearest factor. - /// - /// - /// - /// - public static double RoundDownToNearest(double num, double factor) - { - return factor.IsEqualTo(0) ? num : System.Math.Floor(num / factor) * factor; - } - - /// - /// Rounds a number up to the nearest factor. - /// - /// - /// - /// - public static double RoundUpToNearest(double num, double factor) - { - return factor.IsEqualTo(0) ? num : System.Math.Ceiling(num / factor) * factor; - } - - /// - /// Rounds a number to the nearest factor using midpoint rounding convention. - /// - /// - /// - /// - public static double RoundToNearest(double num, double factor) - { - return factor.IsEqualTo(0) ? num : System.Math.Round(num / factor) * factor; - } - public static void Optimize(IList arcs) { for (int i = 0; i < arcs.Count; ++i) diff --git a/OpenNest.Core/Math/Rounding.cs b/OpenNest.Core/Math/Rounding.cs new file mode 100644 index 0000000..28892b2 --- /dev/null +++ b/OpenNest.Core/Math/Rounding.cs @@ -0,0 +1,40 @@ +using OpenNest.Math; + +namespace OpenNest.Math +{ + public static class Rounding + { + /// + /// Rounds a number down to the nearest factor. + /// + /// + /// + /// + public static double RoundDownToNearest(double num, double factor) + { + return factor.IsEqualTo(0) ? num : System.Math.Floor(num / factor) * factor; + } + + /// + /// Rounds a number up to the nearest factor. + /// + /// + /// + /// + public static double RoundUpToNearest(double num, double factor) + { + return factor.IsEqualTo(0) ? num : System.Math.Ceiling(num / factor) * factor; + } + + /// + /// Rounds a number to the nearest factor using midpoint rounding convention. + /// + /// + /// + /// + public static double RoundToNearest(double num, double factor) + { + return factor.IsEqualTo(0) ? num : System.Math.Round(num / factor) * factor; + } + } +} diff --git a/OpenNest.Core/Plate.cs b/OpenNest.Core/Plate.cs index 4bc49b7..5005529 100644 --- a/OpenNest.Core/Plate.cs +++ b/OpenNest.Core/Plate.cs @@ -412,8 +412,8 @@ namespace OpenNest } Size = new Size( - Helper.RoundUpToNearest(width, roundingFactor), - Helper.RoundUpToNearest(length, roundingFactor)); + Rounding.RoundUpToNearest(width, roundingFactor), + Rounding.RoundUpToNearest(length, roundingFactor)); } ///