Java interpolate interpolate(float s, float e, float t)

Here you can find the source of interpolate(float s, float e, float t)

Description

interpolate

License

LGPL

Declaration

public static float interpolate(float s, float e, float t) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static float interpolate(float s, float e, float t) {
        float t2 = (1.0f - fastCos(t * 3.14159265358979323f)) / 2.0f;
        return (s * (1.0f - t2) + (e) * t2);
    }//from  ww w .  j  ava  2s .  co m

    public static float fastCos(float x) {
        if (x < -3.14159265) {
            x += 6.28318531;
        } else {
            if (x > 3.14159265) {
                x -= 6.28318531;
            }
        }
        x += 1.57079632;
        if (x > 3.14159265) {
            x -= 6.28318531;
        }

        if (x < 0) {
            return (float) (1.27323954 * x + 0.405284735 * x * x);
        } else {
            return (float) (1.27323954 * x - 0.405284735 * x * x);
        }
    }
}

Related

  1. interpolate(final int n, final int lastN, final float interpolation)
  2. interpolate(final int x1, final double y1, final int x2, final double y2, final double... f)
  3. interpolate(float a, float b, float d)
  4. interpolate(float bottom, float top, float ratio)
  5. interpolate(float firstColor, float secondColor, float stage, float maxStages)
  6. interpolate(float t, float a, float b)
  7. interpolate(float var1, float var2, float var3)
  8. interpolate(int a, int b, int theta, int reciprocal)
  9. interpolate(int i, int n, float u1, float u2, float du)