001    package railo.runtime.img.interpolation;
002    
003    public class Mitchell implements Interpolation
004    {
005        public double f(double x) {
006            double b = 0.3333333333333333;
007            double c = 0.3333333333333333;
008            if (x < 0.0)
009                x = -x;
010            if (x < 1.0) {
011                x = ((12.0 - 9.0 * b - 6.0 * c) * (x * x * x)
012                     + (-18.0 + 12.0 * b + 6.0 * c) * x * x + (6.0 - 2.0 * b));
013                return x / 6.0;
014            }
015            if (x < 2.0) {
016                x = ((-1.0 * b - 6.0 * c) * (x * x * x)
017                     + (6.0 * b + 30.0 * c) * x * x + (-12.0 * b - 48.0 * c) * x
018                     + (8.0 * b + 24.0 * c));
019                return x / 6.0;
020            }
021            return 0.0;
022        }
023        
024        public double getSupport() {
025            return 2.0;
026        }
027    }