Java interpolate interpolate(final int x1, final double y1, final int x2, final double y2, final double... f)

Here you can find the source of interpolate(final int x1, final double y1, final int x2, final double y2, final double... f)

Description

interpolate

License

Open Source License

Declaration

public static final void interpolate(final int x1, final double y1, final int x2, final double y2,
            final double... f) 

Method Source Code

//package com.java2s;

public class Main {
    public static final void interpolate(final int x1, final double y1, final int x2, final double y2,
            final double... f) {
        // General equation of a straight line: y = mx + c
        final double m = gradient(x1, y1, x2, y2); // m = (y2 - y1) / (x2 - x1)
        final double c = y1;

        double y = c;
        for (int x = x1 + 1; x < x2; ++x) {
            f[x] = (y += m); // multiplication by repeated addition
        }// w ww  .j a  v a2  s  .  c om
    }

    public static final double gradient(final double x1, final double y1, final double x2, final double y2) {
        return (y2 - y1) / (x2 - x1);
    }
}

Related

  1. interpolate(double x1, double x2, double inbetween)
  2. interpolate(double x1, double x2, float zeroToOne)
  3. interpolate(final double min, final double max, final int currentClass, final int numOfClasses)
  4. interpolate(final float prev, final float curr, final float alpha)
  5. interpolate(final int n, final int lastN, final float interpolation)
  6. interpolate(float a, float b, float d)
  7. interpolate(float bottom, float top, float ratio)
  8. interpolate(float firstColor, float secondColor, float stage, float maxStages)
  9. interpolate(float s, float e, float t)