public final double grad(int par1, double par2, double par4)
    {
    	int j = par1 & 15;
        double d2 = (double)(1 - ((j & 8) >> 3)) * par2;
        double d3 = j < 4 ? 0.0D : (j != 12 && j != 14 ? par4 : par2);
        return ((j & 1) == 0 ? d2 : -d2) + ((j & 2) == 0 ? d3 : -d3);
    }