package org.joml;

/**
 * Provides basic interpolation functions.
 * 
 * @author Kai Burjack
 */
public class Interpolate {

    /**
     * Interpolates between the given two values with their associated tangens
     * using hermite interpolation.
     * 
     * @param v0
     *            the first value
     * @param t0
     *            the tangent of the first value
     * @param v1
     *            the second value
     * @param t1
     *            the tangent of the second value
     * @param t
     *            the interpolation parameter, within <tt>[0..1]</tt>
     * @return the interpolated value
     */
    public static double hermite(double v0, double t0, double v1, double t1, double t) {
        double t2 = t * t;
        double t3 = t2 * t;
        double result;
        if (t == 0.0)
            result = v0;
        else if (t == 1.0)
            result = v1;
        else
            result = (2.0 * v0 - 2.0 * v1 + t1 + t0) * t3 + (3.0 * v1 - 3.0 * v0 - 2.0 * t0 - t1) * t2 + t0 * t + v0;
        return result;
    }

    /**
     * Uses hermite interpolation with zero tangents to produce smooth values
     * between <code>v1</code> and <code>v2</code> based on the value of
     * <code>t</code>.
     * 
     * @param v1
     * @param v2
     * @param t
     *            the interpolation parameter, within <tt>[0..1]</tt>
     * @return the interpolated value
     */
    public static double smoothStep(double v1, double v2, double t) {
        double result = t > 1.0 ? 1.0 : (t < 0.0 ? 0.0 : t);
        result = hermite(v1, 0.0, v2, 0.0, result);
        return result;
    }

}

@@ -1,8 +1,1111 @@
+/*%0D%0A * (C) Copyright 2015 Kai Burjack%0D%0A%0D%0A Permission is hereby granted, free of charge, to any person obtaining a copy%0D%0A of this software and associated documentation files (the %22Software%22), to deal%0D%0A in the Software without restriction, including without limitation the rights%0D%0A to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0D%0A copies of the Software, and to permit persons to whom the Software is%0D%0A furnished to do so, subject to the following conditions:%0D%0A%0D%0A The above copyright notice and this permission notice shall be included in%0D%0A all copies or substantial portions of the Software.%0D%0A%0D%0A THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0D%0A IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0D%0A FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0D%0A AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0D%0A LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0D%0A OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN%0D%0A THE SOFTWARE.%0D%0A%0D%0A */%0D%0A
 package 

Add license header to class Interpolate