aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2012-09-19 12:03:47 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2012-09-19 15:46:00 +0900
commit41f12ee27b269033fe818f7d52e81ba948a046c3 (patch)
treef70671129aa9e6c56666bb57c87b57ca0d65dd83
parent65feee12e5889601e375d92dfdf5f8e8fbb05092 (diff)
downloadlatinime-41f12ee27b269033fe818f7d52e81ba948a046c3.tar.gz
latinime-41f12ee27b269033fe818f7d52e81ba948a046c3.tar.xz
latinime-41f12ee27b269033fe818f7d52e81ba948a046c3.zip
Simplify distance calculating method for gesture input.
Change-Id: Ic466b787b6cc60e6d23b67c8a7f84ad4d0b521c7
-rw-r--r--native/jni/src/geometry_utils.h15
-rw-r--r--native/jni/src/proximity_info_state.cpp6
2 files changed, 6 insertions, 15 deletions
diff --git a/native/jni/src/geometry_utils.h b/native/jni/src/geometry_utils.h
index bad5eda61..3892b46a0 100644
--- a/native/jni/src/geometry_utils.h
+++ b/native/jni/src/geometry_utils.h
@@ -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 {
diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp
index ac1a39dd5..b9fce5fef 100644
--- a/native/jni/src/proximity_info_state.cpp
+++ b/native/jni/src/proximity_info_state.cpp
@@ -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 {