Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the alignment angular vector by finding the average angular position of all
        /// the neightbors and the difference between that and that of the agent.
        /// </summary>
        /// <param name="neighbors"></param>
        public static Quaternion Alignment(Quaternion orientation, IEnumerable <Body> neighbors)
        {
            var average = Quaternion.Average(neighbors.Select(b => b.AngularPosition));

            return(average);
            // return Quaternion.ToEuler((average * orientation.Inverse()).Normal());
        }