Java Lerp lerpAngle(float fromRadians, float toRadians, float progress)

Here you can find the source of lerpAngle(float fromRadians, float toRadians, float progress)

Description

Linearly interpolates between two angles in radians.

License

Open Source License

Parameter

Parameter Description
fromRadians start angle in radians
toRadians target angle in radians
progress interpolation value in the range [0, 1]

Return

the interpolated angle in the range [0, PI2[

Declaration

public static float lerpAngle(float fromRadians, float toRadians, float progress) 

Method Source Code

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

public class Main {
    static public final float PI = 3.1415927f;
    static public final float PI2 = PI * 2;

    /** Linearly interpolates between two angles in radians. Takes into account that angles wrap at two pi and always takes the
     * direction with the smallest delta angle.
     *//from  w  w w. j a  va2s  .  c  o  m
     * @param fromRadians start angle in radians
     * @param toRadians target angle in radians
     * @param progress interpolation value in the range [0, 1]
     * @return the interpolated angle in the range [0, PI2[ */
    public static float lerpAngle(float fromRadians, float toRadians, float progress) {
        float delta = ((toRadians - fromRadians + PI2 + PI) % PI2) - PI;
        return (fromRadians + delta * progress + PI2) % PI2;
    }
}

Related

  1. lerp(float value1, float value2, float amount)
  2. lerp(int a, int b, float value)
  3. lerp(int a, int b, int mul, int div)
  4. lerpa(double a1, double a2, double t)
  5. lerpAndPremultiplyColorWithAlpha(float t, int[] color1, int[] color2)
  6. LerpDegrees(float start, float end, float amount)
  7. lerpInt(int i1, int i2, double f)
  8. lerpQuad(double p0, double k0, double p1, double t)
  9. lerpTowards(float from, float to, float factor)