Created
June 10, 2015 18:32
-
-
Save eriksk/e5e588f4c043aeaacf4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public const float PiOverTwo = (float)Math.PI * 2f; | |
public static float SLerp(float x, float y, float amount) | |
{ | |
float diff = (float)Math.Abs(y - x); | |
if (diff > Math.PI) | |
{ | |
if (y > x) | |
x += PiOverTwo; | |
else | |
y += PiOverTwo; | |
} | |
float value = (x + ((y - x)*amount)); | |
if (value >= 0f && value <= PiOverTwo) | |
return value; | |
return (value % PiOverTwo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment