Class for calculating value deltas. More...
#include <GestureSpeedCalc.h>
Public Member Functions | |
| GestureSpeedCalc () | |
| void | firstSample (double timestamp, double sample) |
| Insert first sample. | |
| void | insertSample (double timestamp, double sample) |
| Insert subsequent samples. | |
| double | speed () const |
| Query the current speed of data value change. | |
Private Attributes | |
| double | m_prevTimeStamp |
| double | m_prevSample |
| double | m_speed |
| double | m_prevRawSpeed |
Class for calculating value deltas.
GestureSpeedCalc objects are used by gesture recognizers to determine value deltas, aka. speed values. Values are fed into GestureSpeedCalc as timestamp,value pairs and a simple floating point value for the speed can be queried.
Definition at line 24 of file GestureSpeedCalc.h.
| WebCore::GestureSpeedCalc::GestureSpeedCalc | ( | ) |
Definition at line 26 of file GestureSpeedCalc.cpp.
| void WebCore::GestureSpeedCalc::firstSample | ( | double | timestamp, | |
| double | sample | |||
| ) |
Insert first sample.
Insert the first data sample. Initializes the previous state if any, and sets speed to 0.
| timestamp | Timestamp of data. | |
| sample | Data value at the given timestamp. |
Definition at line 43 of file GestureSpeedCalc.cpp.
References m_prevRawSpeed, m_prevSample, m_prevTimeStamp, and m_speed.
| void WebCore::GestureSpeedCalc::insertSample | ( | double | timestamp, | |
| double | sample | |||
| ) |
Insert subsequent samples.
Insert sample and possibly update speed depending on timestamp difference to previous sample(s).
| timestamp | Timestamp of data. | |
| sample | Data value at the given timestamp. |
Definition at line 59 of file GestureSpeedCalc.cpp.
References m_prevRawSpeed, m_prevSample, m_prevTimeStamp, m_speed, WebCore::speedAveragingTime, and WebCore::updateSpeedTimeThreshold.
| WebCore::GestureSpeedCalc::speed | ( | ) | const [inline] |
Query the current speed of data value change.
Queries the current speed at which the data is changing. The speed is determined by the difference between the last two accepted data samples, divided by time difference. Only samples with an undefined time interval between them are considered for speed calculations.
Definition at line 30 of file GestureSpeedCalc.h.
References m_speed.
double WebCore::GestureSpeedCalc::m_prevRawSpeed [private] |
Definition at line 36 of file GestureSpeedCalc.h.
double WebCore::GestureSpeedCalc::m_prevSample [private] |
Definition at line 34 of file GestureSpeedCalc.h.
double WebCore::GestureSpeedCalc::m_prevTimeStamp [private] |
Definition at line 33 of file GestureSpeedCalc.h.
double WebCore::GestureSpeedCalc::m_speed [private] |
Definition at line 35 of file GestureSpeedCalc.h.
1.6.2-20100208