Class SmootherVector<T extends Vector2>


  • public class SmootherVector<T extends Vector2>
    extends java.lang.Object
    Template class to help calculate the average value of a history of values. This can only be used with types that have a 'zero' value and that have the += and / operators overloaded. Example: Used to smooth frame rate calculations.
    Author:
    sallyx (https://www.sallyx.org/sally/en/game-ai/)
    • Constructor Summary

      Constructors 
      Constructor Description
      SmootherVector​(int SampleSize, T ZeroValue)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T update​(T mostRecentValue)
      Each time you want to get a new average, feed it the most recent value and this method will return an average over the last SampleSize updates
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SmootherVector

        public SmootherVector​(int SampleSize,
                              T ZeroValue)
    • Method Detail

      • update

        public T update​(T mostRecentValue)
        Each time you want to get a new average, feed it the most recent value and this method will return an average over the last SampleSize updates
        Parameters:
        mostRecentValue - the most recent value
        Returns:
        an average over the last SampleSize updates