Mirror Networking
Mathd.cs
1// 'double' precision variants for some of Unity's Mathf functions.
2
3using System.Runtime.CompilerServices;
4
5namespace Mirror
6{
7 public static class Mathd
8 {
10 [MethodImpl(MethodImplOptions.AggressiveInlining)]
11 public static double LerpUnclamped(double a, double b, double t) =>
12 a + (b - a) * t;
13
15 [MethodImpl(MethodImplOptions.AggressiveInlining)]
16 public static double Clamp01(double value)
17 {
18 if (value < 0.0)
19 return 0;
20 return value > 1 ? 1 : value;
21 }
22
24 [MethodImpl(MethodImplOptions.AggressiveInlining)]
25 public static double InverseLerp(double a, double b, double value) =>
26 a != b ? Clamp01((value - a) / (b - a)) : 0;
27 }
28}
static double InverseLerp(double a, double b, double value)
Calculates the linear parameter t that produces the interpolant value within the range [a,...
static double Clamp01(double value)
Clamps value between 0 and 1 and returns value.
Definition: Mathd.cs:16
static double LerpUnclamped(double a, double b, double t)
Linearly interpolates between a and b by t with no limit to t.