protected static T _defaultGetAverageFunc(RollingAverage <T> self) { return((self.isValidYet) ? self.currentAverage : Operator <T> .Add(Operator.MultiplyAlternative(self.currentAverage, self.readyPart), Operator.MultiplyAlternative(self.defaultAverage, self.unreadyPart))); }
public NewGlyphTrainingStage(int targetGlyphIndex, Focus Focus, OrientationSensorProvider Provider = null) : base($"Training glyph {Glyph.AllGlyphs[targetGlyphIndex].Name}") { TargetGlyphIndex = targetGlyphIndex; TargetGlyph = Glyph.AllGlyphs[targetGlyphIndex]; Implement = Focus; Res.DebuggingSignalFlag = true; verbLog("Ctor"); Stillness = new StillnessProvider(); //Stillness.StartDisplayLoop(Current, 750); SetUpProvider(Stillness); Volume = 0.1f; verbLog("Averages"); //AverageAttitude = new AdvancedRollingAverageQuat(timeFrameInPeriods: 15); AverageAttitude = new RollingAverage <Quaternion>(timeFrameInPeriods: 10); AttitudeProvider = Provider ?? new GravityOrientationProvider(Implement.FrameShift); AttitudeProvider.Activate(); if (targetGlyphIndex == 0) { lastOrientation = Quaternion.Identity; } else { lastOrientation = Glyph.AllGlyphs[targetGlyphIndex - 1].Orientation; } verbLog("Auto-activation"); Activate(); }
public GlyphTrainingStage(string label, Focus Focus, OrientationSensorProvider Provider = null) : base(label) { Implement = Focus; Res.DebuggingSignalFlag = true; verbLog("Ctor"); Stillness = new StillnessProvider(); //Stillness.StartDisplayLoop(Current, 750); SetUpProvider(Stillness); Volume = 0.1f; verbLog("Averages"); //AverageAttitude = new AdvancedRollingAverageQuat(timeFrameInPeriods: 15); AverageAttitude = new RollingAverage <Quaternion>(timeFrameInPeriods: 10); AttitudeProvider = Provider ?? new GravityOrientationProvider(Implement.FrameShift); AttitudeProvider.Activate(); if (Current.SpellBeingTrained.Glyphs.Count == 0) { lastOrientation = Quaternion.Identity; } else { lastOrientation = Current.SpellBeingTrained.Glyphs.Last().Orientation; } verbLog("Auto-activation"); Activate(); }
public void SetUpTiming(TimeSpan interval, float initialAverage, bool isAdjustmentAfterStart = false) { expectedInterval = interval; expectedIntervalMin = TimeSpan.FromSeconds(interval.TotalSeconds * 0.85); expectedIntervalMax = TimeSpan.FromSeconds(interval.TotalSeconds * 1.15); Score = new RollingAverage <float>((float)(halfLife.TotalSeconds / interval.TotalSeconds), initialAverage, !isAdjustmentAfterStart); depreciationCoefficient = (float)Math.Pow(0.5, interval.TotalSeconds / halfLife.TotalSeconds); }
public SmoothedList(List <T> sourceList, bool SmoothNow = false, float timeFrameInPeriods = 10f) : this(timeFrameInPeriods) { if (!SmoothNow) { Average = new RollingAverage <T>(timeFrameInPeriods, sourceList.LastOrDefault(), false); List = sourceList; } else { Average = new RollingAverage <T>(timeFrameInPeriods, sourceList.FirstOrDefault(), false); List = new List <T>() { sourceList.FirstOrDefault() }; foreach (var pt in sourceList.Skip(1)) { Add(pt); } } }
public void Clear() { ((IList <T>)List).Clear(); Average = new RollingAverage <T>(timeFrame, initialAvg); }
public SmoothedList(float timeFrameInPeriods = 10f, T?initialAverage = null) : base() { Average = new RollingAverage <T>(timeFrameInPeriods, initialAverage); timeFrame = timeFrameInPeriods; initialAvg = initialAverage; }