diff options
author | 2012-09-19 15:19:26 -0700 | |
---|---|---|
committer | 2012-09-19 15:19:26 -0700 | |
commit | f5ecf29afc6a3bd53ff838843b3dc9bb79f99a90 (patch) | |
tree | 00253a3cbb58ce4a3e4927184f18c9a620c7861a /native/jni/src/geometry_utils.h | |
parent | d9ea76cdf6c7d49d1aab5b7fc95b0118b683b051 (diff) | |
parent | edbd4a06604352f35978000d2bb990ab597dc5c4 (diff) | |
download | latinime-f5ecf29afc6a3bd53ff838843b3dc9bb79f99a90.tar.gz latinime-f5ecf29afc6a3bd53ff838843b3dc9bb79f99a90.tar.xz latinime-f5ecf29afc6a3bd53ff838843b3dc9bb79f99a90.zip |
am edbd4a06: am 63dd5b4c: Merge "Simplify distance calculating method for gesture input." into jb-mr1-dev
* commit 'edbd4a06604352f35978000d2bb990ab597dc5c4':
Simplify distance calculating method for gesture input.
Diffstat (limited to 'native/jni/src/geometry_utils.h')
-rw-r--r-- | native/jni/src/geometry_utils.h | 15 |
1 files changed, 3 insertions, 12 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 { |