Java interpolate interpolate(double x1, double x2, float zeroToOne)

Here you can find the source of interpolate(double x1, double x2, float zeroToOne)

Description

interpolate

License

Open Source License

Parameter

Parameter Description
x1 a parameter
x2 a parameter
zeroToOne a parameter

Return

x + zeroToOne * (x2 - x)

Declaration

public static double interpolate(double x1, double x2, float zeroToOne) 

Method Source Code

//package com.java2s;
/* /*from w w w.j a v  a 2 s . c om*/
    
 Created on Mar 4, 2005
    
 The Bungee View applet lets you search, browse, and data-mine an image collection.  
 Copyright (C) 2006  Mark Derthick
    
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.  See gpl.html.
    
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
    
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    
 You may also contact the author at 
 mad@cs.cmu.edu, 
 or at
 Mark Derthick
 Carnegie-Mellon University
 Human-Computer Interaction Institute
 Pittsburgh, PA 15213
    
 */

public class Main {
    /**
     * @param x1
     * @param x2
     * @param zeroToOne
     * @return x + zeroToOne * (x2 - x)
     */
    public static double interpolate(double x1, double x2, float zeroToOne) {
        if (zeroToOne == 1.0f)
            // avoid roundoff errors
            return x2;
        // print(" "+x1+" "+x2+" "+zeroToOne+" "+x1 + zeroToOne * (x2 - x1));
        return x1 + zeroToOne * (x2 - x1);
    }

    /**
     * @param x1
     * @param x2
     * @param zeroToOne
     * @return x + zeroToOne * (x2 - x)
     */
    public static float interpolate(float x1, float x2, float zeroToOne) {
        if (zeroToOne == 1.0f)
            // avoid roundoff errors
            return x2;
        return x1 + zeroToOne * (x2 - x1);
    }
}

Related

  1. interpolate(double fromAngle, double toAngle, double ratio)
  2. interpolate(double oldP, double newP, float partialTicks)
  3. interpolate(double p0, double p1, double p2, double p3, double t)
  4. interpolate(double x, double x1, double y1, double x2, double y2)
  5. interpolate(double x1, double x2, double inbetween)
  6. interpolate(final double min, final double max, final int currentClass, final int numOfClasses)
  7. interpolate(final float prev, final float curr, final float alpha)
  8. interpolate(final int n, final int lastN, final float interpolation)
  9. interpolate(final int x1, final double y1, final int x2, final double y2, final double... f)