Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f959ea5 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by android-build-merger
Browse files

Rename a constant in VelocityTracker

am: e7d47752

Change-Id: I3d96f749154fe0a3ee894628d2c940b7de09705a
parents 522901b5 e7d47752
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1090,7 +1090,7 @@ static float kineticEnergyToVelocity(float work) {
static float calculateImpulseVelocity(const nsecs_t* t, const float* x, size_t count) {
    // The input should be in reversed time order (most recent sample at index i=0)
    // t[i] is in nanoseconds, but due to FP arithmetic, convert to seconds inside this function
    static constexpr float NANOS_PER_SECOND = 1E-9;
    static constexpr float SECONDS_PER_NANO = 1E-9;

    if (count < 2) {
        return 0; // if 0 or 1 points, velocity is zero
@@ -1103,7 +1103,7 @@ static float calculateImpulseVelocity(const nsecs_t* t, const float* x, size_t c
            ALOGE("Events have identical time stamps t=%" PRId64 ", setting velocity = 0", t[0]);
            return 0;
        }
        return (x[1] - x[0]) / (NANOS_PER_SECOND * (t[1] - t[0]));
        return (x[1] - x[0]) / (SECONDS_PER_NANO * (t[1] - t[0]));
    }
    // Guaranteed to have at least 3 points here
    float work = 0;
@@ -1113,7 +1113,7 @@ static float calculateImpulseVelocity(const nsecs_t* t, const float* x, size_t c
            continue;
        }
        float vprev = kineticEnergyToVelocity(work); // v[i-1]
        float vcurr = (x[i] - x[i-1]) / (NANOS_PER_SECOND * (t[i] - t[i-1])); // v[i]
        float vcurr = (x[i] - x[i-1]) / (SECONDS_PER_NANO * (t[i] - t[i-1])); // v[i]
        work += (vcurr - vprev) * fabsf(vcurr);
        if (i == count - 1) {
            work *= 0.5; // initial condition, case 2) above