AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
InterpolationUtilities.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEngine;
5 
6 namespace HoloToolkit.Unity
7 {
11  public static class InterpolationUtilities
12  {
13  #region Exponential Decay
14 
15  public static float ExpDecay(float from, float to, float hLife, float dTime)
16  {
17  return Mathf.Lerp(from, to, ExpCoefficient(hLife, dTime));
18  }
19 
20  public static Vector2 ExpDecay(Vector2 from, Vector2 to, float hLife, float dTime)
21  {
22  return Vector2.Lerp(from, to, ExpCoefficient(hLife, dTime));
23  }
24 
25  public static Vector3 ExpDecay(Vector3 from, Vector3 to, float hLife, float dTime)
26  {
27  return Vector3.Lerp(from, to, ExpCoefficient(hLife, dTime));
28  }
29 
30  public static Quaternion ExpDecay(Quaternion from, Quaternion to, float hLife, float dTime)
31  {
32  return Quaternion.Slerp(from, to, ExpCoefficient(hLife, dTime));
33  }
34 
35  public static Color ExpDecay(Color from, Color to, float hLife, float dTime)
36  {
37  return Color.Lerp(from, to, ExpCoefficient(hLife, dTime));
38  }
39 
40 
41  public static float ExpCoefficient(float hLife, float dTime)
42  {
43  if (hLife == 0)
44  return 1;
45 
46  return 1.0f - Mathf.Pow(0.5f, dTime / hLife);
47  }
48 
49  #endregion
50  }
51 }
static float ExpCoefficient(float hLife, float dTime)
static Color ExpDecay(Color from, Color to, float hLife, float dTime)
static Vector3 ExpDecay(Vector3 from, Vector3 to, float hLife, float dTime)
static Vector2 ExpDecay(Vector2 from, Vector2 to, float hLife, float dTime)
Static class containing interpolation-related utility functions.
static Quaternion ExpDecay(Quaternion from, Quaternion to, float hLife, float dTime)
static float ExpDecay(float from, float to, float hLife, float dTime)