Java Lerp LerpDegrees(float start, float end, float amount)

Here you can find the source of LerpDegrees(float start, float end, float amount)

Description

Lerp Degrees

License

Open Source License

Declaration

public static float LerpDegrees(float start, float end, float amount) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static float LerpDegrees(float start, float end, float amount) {
        float difference = Math.abs(end - start);
        if (difference > 180) {
            // We need to add on to one of the values.
            if (end > start) {
                // We'll add it on to start...
                start += 360;/*from w  w  w . j ava2s. c o m*/
            } else {
                // Add it on to end.
                end += 360;
            }
        }

        // Interpolate it.
        float value = (start + ((end - start) * amount));

        // Wrap it..
        float rangeZero = 360;

        if (value >= 0 && value <= 360)
            return value;

        return (value % rangeZero);
    }
}

Related

  1. lerp(int a, int b, float value)
  2. lerp(int a, int b, int mul, int div)
  3. lerpa(double a1, double a2, double t)
  4. lerpAndPremultiplyColorWithAlpha(float t, int[] color1, int[] color2)
  5. lerpAngle(float fromRadians, float toRadians, float progress)
  6. lerpInt(int i1, int i2, double f)
  7. lerpQuad(double p0, double k0, double p1, double t)
  8. lerpTowards(float from, float to, float factor)