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

Commit 41f12ee2 authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi
Browse files

Simplify distance calculating method for gesture input.

Change-Id: Ic466b787b6cc60e6d23b67c8a7f84ad4d0b521c7
parent 65feee12
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -64,17 +64,8 @@ static inline float getAngleDiff(float a1, float a2) {
    return diff;
}

// static float pointToLineSegSquaredDistanceFloat(
//         float x, float y, float x1, float y1, float x2, float y2) {
//     float A = x - x1;
//     float B = y - y1;
//     float C = x2 - x1;
//     float D = y2 - y1;
//     return fabsf(A * D - C * B) / sqrtf(C * C + D * D);
// }

static inline float pointToLineSegSquaredDistanceFloat(
        float x, float y, float x1, float y1, float x2, float y2) {
        float x, float y, float x1, float y1, float x2, float y2, bool extend) {
    const float ray1x = x - x1;
    const float ray1y = y - y1;
    const float ray2x = x2 - x1;
@@ -86,10 +77,10 @@ static inline float pointToLineSegSquaredDistanceFloat(

    float projectionX;
    float projectionY;
    if (projectionLengthSqr < 0.0f) {
    if (!extend && projectionLengthSqr < 0.0f) {
        projectionX = x1;
        projectionY = y1;
    } else if (projectionLengthSqr > 1.0f) {
    } else if (!extend && projectionLengthSqr > 1.0f) {
        projectionX = x2;
        projectionY = y2;
    } else {
+3 −3
Original line number Diff line number Diff line
@@ -504,7 +504,7 @@ int32_t ProximityInfoState::getAllPossibleChars(
    if (index >= mInputXs.size()) {
        return filterSize;
    }
    int i = filterSize;
    int newFilterSize = filterSize;
    for (int j = 0; j < mProximityInfo->getKeyCount(); ++j) {
        if (mNearKeysVector[index].test(j)) {
            const int32_t keyCodePoint = mProximityInfo->getCodePointOf(j);
@@ -517,11 +517,11 @@ int32_t ProximityInfoState::getAllPossibleChars(
                }
            }
            if (insert) {
                filter[i++] = keyCodePoint;
                filter[newFilterSize++] = keyCodePoint;
            }
        }
    }
    return i;
    return newFilterSize;
}

float ProximityInfoState::getAveragePointDuration() const {