using System; namespace FastPrint.Geometry { public static class BsplineMitchellNetravali { // Cubic B-spline basis function public static double BSpline(double t) { t = Math.Abs(t); if (t < 1) return (3 * t * t * t - 6 * t * t + 4) / 6.0; else if (t < 2) return (-t * t * t + 6 * t * t - 12 * t + 8) / 6.0; return 0.0; } // Mitchell-Netravali filter public static double MitchellNetravali(double x, double B = 1.0 / 3.0, double C = 1.0 / 3.0) { x = Math.Abs(x); if (x < 1) return ((12 - 9 * B - 6 * C) * Math.Pow(x, 3) + (-18 + 12 * B + 6 * C) * Math.Pow(x, 2) + (6 - 2 * B)) / 6.0; else if (x < 2) return ((-B - 6 * C) * Math.Pow(x, 3) + (6 * B + 30 * C) * Math.Pow(x, 2) + (-12 * B - 48 * C) * x + (8 * B + 24 * C)) / 6.0; return 0.0; } } }