refactor(PepLib.Core): reorganize files into logical folder structure
Move 38 files from root directory into organized subfolders: - Enums/ (7 files): StatusType, ApplicationType, DrawingType, etc. - Geometry/ (5 files): Vector, Box, Size, Spacing, Node - Models/ (15 files): Nest, Plate, Part, Program, Report, etc. - Utilities/ (7 files): MathHelper, Tolerance, ZipHelper, etc. - Extensions/ (2 files): PartListExtensions, PlateListExtensions - Interfaces/ (1 file): IMovable Update namespaces to follow folder hierarchy (e.g., PepLib.Models). Add GlobalUsings.cs for internal backward compatibility. Update Codes/ and IO/ files with new using statements. Update PepApi.Core consumers to reference new namespaces. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
53
PepLib.Core/Utilities/MathHelper.cs
Normal file
53
PepLib.Core/Utilities/MathHelper.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
namespace PepLib.Utilities
|
||||
{
|
||||
public static class MathHelper
|
||||
{
|
||||
public const double HalfPI = Math.PI * 0.5;
|
||||
public const double TwoPI = Math.PI * 2.0;
|
||||
|
||||
public static double NormalizeAngleRad(double angle)
|
||||
{
|
||||
double r = angle % TwoPI;
|
||||
return r < 0 ? TwoPI + r : r;
|
||||
}
|
||||
|
||||
public static double NormalizeAngleDeg(double angle)
|
||||
{
|
||||
double r = angle % 360.0;
|
||||
return r < 0 ? 360.0 + r : r;
|
||||
}
|
||||
|
||||
public static bool IsAngleBetween(double angle, double a1, double a2, bool reversed = false)
|
||||
{
|
||||
if (reversed)
|
||||
Generic.Swap(ref a1, ref a2);
|
||||
|
||||
var diff = NormalizeAngleRad(a2 - a1);
|
||||
|
||||
// full circle
|
||||
if (a2.IsEqualTo(a1))
|
||||
return true;
|
||||
|
||||
a1 = NormalizeAngleRad(angle - a1);
|
||||
a2 = NormalizeAngleRad(a2 - angle);
|
||||
|
||||
return diff >= a1 - Tolerance.Epsilon ||
|
||||
diff >= a2 - Tolerance.Epsilon;
|
||||
}
|
||||
|
||||
public static double RoundDownToNearest(double num, double factor)
|
||||
{
|
||||
return factor == 0 ? num : Math.Floor(num / factor) * factor;
|
||||
}
|
||||
|
||||
public static double RoundUpToNearest(double num, double factor)
|
||||
{
|
||||
return factor == 0 ? num : Math.Ceiling(num / factor) * factor;
|
||||
}
|
||||
|
||||
public static double RoundToNearest(double num, double factor)
|
||||
{
|
||||
return factor == 0 ? num : Math.Round(num / factor) * factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user