Here you can find the source of lerpAngle(float fromRadians, float toRadians, float progress)
Parameter | Description |
---|---|
fromRadians | start angle in radians |
toRadians | target angle in radians |
progress | interpolation value in the range [0, 1] |
public static float lerpAngle(float fromRadians, float toRadians, float progress)
//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; } }