summaryrefslogtreecommitdiff
path: root/indra/llmath/llmath.h
diff options
context:
space:
mode:
authorNyx (Neal Orman) <nyx@lindenlab.com>2011-04-08 15:58:11 -0400
committerNyx (Neal Orman) <nyx@lindenlab.com>2011-04-08 15:58:11 -0400
commit2deea74cf6f08376e14e2f7e5333fc6959d2af19 (patch)
tree80429812cfb4f88a151627830dceb4a8f2e278dd /indra/llmath/llmath.h
parent534ac19ed5a6abe68ea654a5444b7e486f8ce06a (diff)
parent8807496ed78b36658f488d901842852d63f73cb9 (diff)
merging mesh-development into nyx's mesh development
Diffstat (limited to 'indra/llmath/llmath.h')
-rw-r--r--indra/llmath/llmath.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h
index 25b29ac1a8..eea7c977fb 100644
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -29,6 +29,7 @@
#include <cmath>
#include <cstdlib>
+#include <vector>
#include "lldefs.h"
//#include "llstl.h" // *TODO: Remove when LLString is gone
//#include "llstring.h" // *TODO: Remove when LLString is gone
@@ -497,6 +498,44 @@ inline F32 llgaussian(F32 x, F32 o)
return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2*o*o));
}
+//helper function for removing outliers
+template <class VEC_TYPE>
+inline void ll_remove_outliers(std::vector<VEC_TYPE>& data, F32 k)
+{
+ if (data.size() < 100)
+ { //not enough samples
+ return;
+ }
+
+ VEC_TYPE Q1 = data[data.size()/4];
+ VEC_TYPE Q3 = data[data.size()-data.size()/4-1];
+
+ VEC_TYPE min = (VEC_TYPE) ((F32) Q1-k * (F32) (Q3-Q1));
+ VEC_TYPE max = (VEC_TYPE) ((F32) Q3+k * (F32) (Q3-Q1));
+
+ U32 i = 0;
+ while (i < data.size() && data[i] < min)
+ {
+ i++;
+ }
+
+ S32 j = data.size()-1;
+ while (j > 0 && data[j] > max)
+ {
+ j--;
+ }
+
+ if (j < data.size()-1)
+ {
+ data.erase(data.begin()+j, data.end());
+ }
+
+ if (i > 0)
+ {
+ data.erase(data.begin(), data.begin()+i);
+ }
+}
+
// Include simd math header
#include "llsimdmath.h"