VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Vector3 AVR.Avatar.AVR_PoseNaturalizationFilter.get_weighted_average_reference ( Vector3  p)
inlineprivate

Definition at line 77 of file AVR_PoseNaturalizationFilter.cs.

78  {
79  // TODO: we are sorting the whole list here but only want the first k items. -> Needless performance cost.
80  List<Vector3> kn = _refpoints.OrderBy(item => Vector3.Distance(item, p)).Take(Mathf.Min(take_k, _refpoints.Count)).ToList();
81 
82  Vector3 sum = Vector3.zero;
83  float wsum = 0;
84  foreach (var v in kn)
85  {
86  float w = 1.0f / (0.0001f + Vector3.Distance(v, p));
87  wsum += w;
88  sum += w * v;
89  }
90 
91  sum /= wsum;
92 
93  return sum;
94  }
int take_k
How many points to incorporate into the weighted average.