Answers for "Average of Vectors [Math]"
http://answers.unity.com/questions/1605901/average-of-vectors-math.html
The latest answers for the question "Average of Vectors [Math]"Answer by Ymrasu
http://answers.unity.com/answers/1605916/view.html
There is something called Trimmed Mean to get the average while avoiding outliers. I don't think Unity has a built in function for it. Here is a quick one I threw together:
// using System.Linq;
List<Vector3> TrimmedMean(List<Vector3> list, float percent = 0.01f)
{
int trim = Mathf.CeilToInt(percent * list.Count);
List<Vector3> trimmedList = list.OrderBy(x => x.sqrMagnitude).ToList();
trimmedList.RemoveRange(trimmedList.Count-trim, trim);
trimmedList.RemoveRange(0, trim);
return trimmedList;
}
It takes a list of vectors and a percent (0-1). It sorts the vectors by their sqrMagnitude and trims out the top and bottom by the percentage of vectors in the list. That gets rid of extreme values, but can also get rid of normal values at the ends too.Sun, 24 Feb 2019 21:47:34 GMTYmrasu