MMMVelocityMeter
Objective-C
@interface MMMVelocityMeter : NSObject
Swift
class MMMVelocityMeter : NSObject
A little helper for velocity/acceleration calculations: you feed it values with timestamps and can get the most recent acceleration/velocity values.
-
Resets the state of the meter, all values added before are forgotten.
Declaration
Objective-C
- (void)reset;
Swift
func reset()
-
Adds a coordinate and a corresponding timestamp.
Declaration
Objective-C
- (void)addValue:(CGFloat)value timestamp:(NSTimeInterval)timestamp;
Swift
func addValue(_ value: CGFloat, timestamp: TimeInterval)
-
Adds a coordinate with the current timstamp.
Declaration
Objective-C
- (void)addValue:(CGFloat)value;
Swift
func addValue(_ value: CGFloat)
-
Calculates velocity and acceleration based on recently added values.
Declaration
Objective-C
- (void)calculateVelocity:(nonnull CGFloat *)velocity acceleration:(nonnull CGFloat *)acceleration;
Swift
func calculateVelocity(_ velocity: UnsafeMutablePointer<CGFloat>, acceleration: UnsafeMutablePointer<CGFloat>)