Tanoda
SmoothedQuaternion.cs
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright (C) Ultraleap, Inc. 2011-2020. *
3
* *
4
* Use subject to the terms of the Apache License 2.0 available at *
5
* http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6
* between Ultraleap and you, your company or other organization. *
7
******************************************************************************/
8
9
using
UnityEngine
;
10
11
namespace
Leap.Unity
{
18
[System.Serializable]
19
public
class
SmoothedQuaternion
{
20
public
Quaternion
value
= Quaternion.identity;
// Filtered value
21
public
float
delay
= 0f;
// Mean delay
22
public
bool
reset
=
true
;
// Reset on Next Update
23
24
public
void
SetBlend
(
float
blend,
float
deltaTime = 1f) {
25
delay
= deltaTime * blend / (1f - blend);
26
}
27
28
public
Quaternion
Update
(Quaternion input,
float
deltaTime = 1f) {
29
if
(deltaTime > 0f && !
reset
) {
30
float
alpha =
delay
/ deltaTime;
31
float
blend = alpha / (1f + alpha);
32
// NOTE: If delay -> 0 then blend -> 0,
33
// reducing the filter to this.value = value.
34
// NOTE: If deltaTime -> 0 blend -> 1,
35
// so the change in the filtered value will be suppressed
36
value
= Quaternion.Slerp(
value
, input, 1f - blend);
37
}
else
{
38
value
= input;
39
reset
=
false
;
40
}
41
return
value
;
42
}
43
}
44
}
Leap.Unity.SmoothedQuaternion
Time-step independent exponential smoothing.
Definition:
SmoothedQuaternion.cs:19
Leap.Unity.SmoothedQuaternion.SetBlend
void SetBlend(float blend, float deltaTime=1f)
Definition:
SmoothedQuaternion.cs:24
Leap.Unity.SmoothedQuaternion.delay
float delay
Definition:
SmoothedQuaternion.cs:21
Leap.Unity.SmoothedQuaternion.Update
Quaternion Update(Quaternion input, float deltaTime=1f)
Definition:
SmoothedQuaternion.cs:28
Leap.Unity.SmoothedQuaternion.value
Quaternion value
Definition:
SmoothedQuaternion.cs:20
Leap.Unity.SmoothedQuaternion.reset
bool reset
Definition:
SmoothedQuaternion.cs:22
Leap.Unity
Definition:
AssetFolderPropertyDrawer.cs:15
UnityEngine
Definition:
HSVPicker/UtilityScripts/BoxSlider.cs:7
Source
Assets
Plugins
LeapMotion
Core
Scripts
Algorithms
SmoothedQuaternion.cs
Generated by
1.9.3