forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterpolationUtilities.cs
More file actions
51 lines (40 loc) · 1.52 KB
/
InterpolationUtilities.cs
File metadata and controls
51 lines (40 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using UnityEngine;
namespace HoloToolkit.Unity
{
/// <summary>
/// Static class containing interpolation-related utility functions.
/// </summary>
public static class InterpolationUtilities
{
#region Exponential Decay
public static float ExpDecay(float from, float to, float hLife, float dTime)
{
return Mathf.Lerp(from, to, ExpCoefficient(hLife, dTime));
}
public static Vector2 ExpDecay(Vector2 from, Vector2 to, float hLife, float dTime)
{
return Vector2.Lerp(from, to, ExpCoefficient(hLife, dTime));
}
public static Vector3 ExpDecay(Vector3 from, Vector3 to, float hLife, float dTime)
{
return Vector3.Lerp(from, to, ExpCoefficient(hLife, dTime));
}
public static Quaternion ExpDecay(Quaternion from, Quaternion to, float hLife, float dTime)
{
return Quaternion.Slerp(from, to, ExpCoefficient(hLife, dTime));
}
public static Color ExpDecay(Color from, Color to, float hLife, float dTime)
{
return Color.Lerp(from, to, ExpCoefficient(hLife, dTime));
}
public static float ExpCoefficient(float hLife, float dTime)
{
if (hLife == 0)
return 1;
return 1.0f - Mathf.Pow(0.5f, dTime / hLife);
}
#endregion
}
}