File size: 1,101 Bytes
b6a0fc3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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;
}
}
} |