diff options
author | 2013-01-20 19:48:41 -0800 | |
---|---|---|
committer | 2013-01-20 19:48:41 -0800 | |
commit | 9a2dffdbd14c4a481d576dfb573e5fbe977a79c0 (patch) | |
tree | d5d0a07321973a516bd87b10b94d1bb0f5a15244 /native/jni/src/geometry_utils.h | |
parent | c5da4e4b9681467925c698c1e5653e21936152a8 (diff) | |
parent | 0c2227ab991774768414d8ea60a469f005eb9f1a (diff) | |
download | latinime-9a2dffdbd14c4a481d576dfb573e5fbe977a79c0.tar.gz latinime-9a2dffdbd14c4a481d576dfb573e5fbe977a79c0.tar.xz latinime-9a2dffdbd14c4a481d576dfb573e5fbe977a79c0.zip |
am 0c2227ab: Clean up in geometry_utils.h
* commit '0c2227ab991774768414d8ea60a469f005eb9f1a':
Clean up in geometry_utils.h
Diffstat (limited to 'native/jni/src/geometry_utils.h')
-rw-r--r-- | native/jni/src/geometry_utils.h | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/native/jni/src/geometry_utils.h b/native/jni/src/geometry_utils.h index 4bff80f15..64bbbd4b8 100644 --- a/native/jni/src/geometry_utils.h +++ b/native/jni/src/geometry_utils.h @@ -21,7 +21,6 @@ #include "defines.h" -#define M_PI_F 3.14159265f #define ROUND_FLOAT_10000(f) ((f) < 1000.0f && (f) > 0.001f) \ ? (floorf((f) * 10000.0f) / 10000.0f) : (f) @@ -29,15 +28,6 @@ namespace latinime { static inline float SQUARE_FLOAT(const float x) { return x * x; } -static inline float getSquaredDistanceFloat(const float x1, const float y1, const float x2, - const float y2) { - return SQUARE_FLOAT(x1 - x2) + SQUARE_FLOAT(y1 - y2); -} - -static AK_FORCE_INLINE int getDistanceInt(const int x1, const int y1, const int x2, const int y2) { - return static_cast<int>(hypotf(static_cast<float>(x1 - x2), static_cast<float>(y1 - y2))); -} - static AK_FORCE_INLINE float getAngle(const int x1, const int y1, const int x2, const int y2) { const int dx = x1 - x2; const int dy = y1 - y2; @@ -54,52 +44,5 @@ static AK_FORCE_INLINE float getAngleDiff(const float a1, const float a2) { } return diff; } - -static inline float pointToLineSegSquaredDistanceFloat(const float x, const float y, const float x1, - const float y1, const float x2, const float y2, const bool extend) { - const float ray1x = x - x1; - const float ray1y = y - y1; - const float ray2x = x2 - x1; - const float ray2y = y2 - y1; - - const float dotProduct = ray1x * ray2x + ray1y * ray2y; - const float lineLengthSqr = SQUARE_FLOAT(ray2x) + SQUARE_FLOAT(ray2y); - const float projectionLengthSqr = dotProduct / lineLengthSqr; - - float projectionX; - float projectionY; - if (!extend && projectionLengthSqr < 0.0f) { - projectionX = x1; - projectionY = y1; - } else if (!extend && projectionLengthSqr > 1.0f) { - projectionX = x2; - projectionY = y2; - } else { - projectionX = x1 + projectionLengthSqr * ray2x; - projectionY = y1 + projectionLengthSqr * ray2y; - } - return getSquaredDistanceFloat(x, y, projectionX, projectionY); -} - -// Normal distribution N(u, sigma^2). -struct NormalDistribution { - public: - NormalDistribution(const float u, const float sigma) - : mU(u), mSigma(sigma), - mPreComputedNonExpPart(1.0f / sqrtf(2.0f * M_PI_F * SQUARE_FLOAT(sigma))), - mPreComputedExponentPart(-1.0f / (2.0f * SQUARE_FLOAT(sigma))) {} - - float getProbabilityDensity(const float x) const { - const float shiftedX = x - mU; - return mPreComputedNonExpPart * expf(mPreComputedExponentPart * SQUARE_FLOAT(shiftedX)); - } - -private: - DISALLOW_IMPLICIT_CONSTRUCTORS(NormalDistribution); - const float mU; // mean value - const float mSigma; // standard deviation - const float mPreComputedNonExpPart; // = 1 / sqrt(2 * PI * sigma^2) - const float mPreComputedExponentPart; // = -1 / (2 * sigma^2) -}; // struct NormalDistribution } // namespace latinime #endif // LATINIME_GEOMETRY_UTILS_H |