mirror of
https://github.com/chev2/botw-toolset.git
synced 2026-05-10 11:31:45 +00:00
MathExt.Lerp method
This commit is contained in:
parent
4a8e738b0d
commit
a9639a43b3
1 changed files with 17 additions and 0 deletions
|
|
@ -21,5 +21,22 @@ namespace BOTWToolset
|
||||||
else if (val.CompareTo(max) > 0) return max;
|
else if (val.CompareTo(max) > 0) return max;
|
||||||
else return val;
|
else return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Linearly interpolates a value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="from">Value to interpolate.</param>
|
||||||
|
/// <param name="to">Value to interpolate to.</param>
|
||||||
|
/// <param name="delta">Amount to interpolate - should be between 0 and 1.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static float Lerp(float from, float to, float delta)
|
||||||
|
{
|
||||||
|
if (delta > 1)
|
||||||
|
return to;
|
||||||
|
if (delta < 0)
|
||||||
|
return from;
|
||||||
|
|
||||||
|
return from + (to - from) * delta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue