public override float ProcessData(IProvider <Vector3> provider) { smoothedAccel.Update(provider.Data); currentVelocity += smoothedAccel.Average * (float)provider.Interval.TotalSeconds; currentDisplacement += currentVelocity * (float)provider.Interval.TotalSeconds; return(currentDisplacement.Length()); }
protected override void interimAction() { LastAngle = Angle; Angle = AttitudeProvider.Angle; var angleChange = Angle - LastAngle; Log.Debug("TumblerStage|Interim", $"New angle: {Angle}"); if (Math.Abs(angleChange) > 15.0) { Log.Debug("LockOpening|InterimAction", $"Caution - Angle changed by {angleChange:f1}."); } AngleTrend.Update(angleChange); }
= new RollingAverage <Vector3>(3, Vector3.Zero); // Uses a lightly smoothed rolling average instead of just the previous vector because I expect this to be pretty swingy if there's a lot of noise. public override void Add(Vector3 newVal) { newVal = newVal.Normalize(); Total += Math.Acos(previousVector.Average.Dot(newVal)); previousVector.Update(newVal); }
protected override void interimAction() { base.interimAction(); AngleRateOfChange.Update((float)(Math.Abs(Angle - LastAngle) / InterimInterval.TotalSeconds)); Plugin.Vibrate.CrossVibrate.Current.Vibration((int)Math.Max(1, 3 * AngleRateOfChange / Current.LockBeingOpened.MaxRotationRateInLiftingPhase)); }