here are some useful links about hypot, I tried to use std::hypot(x, y), later changed to std::sqrt(a*a + b*b); http://stackoverflow.com/questions/3764978/why-hypot-function-is-so-slow also STL Bugs Fixed In Visual Studio 2012 718865 STL: hypot not hoisted into the std namespace by cmath https://blogs.msdn.microsoft.com/vcblog/2012/06/15/stl-bugs-fixed-in-visual-studio-2012/ */
| 266 | https://blogs.msdn.microsoft.com/vcblog/2012/06/15/stl-bugs-fixed-in-visual-studio-2012/ |
| 267 | */ |
| 268 | static float angle(const Vec2f& v1, const Vec2f& v2) |
| 269 | { |
| 270 | float numerator = v1[0]*v2[0] + v1[1]*v2[1]; // v1.dot(v2); |
| 271 | float v1_length = std::sqrt(v1[0]*v1[0] + v1[1]*v1[1]); |
| 272 | float v2_length = std::sqrt(v2[0]*v2[0] + v2[1]*v2[1]); |
| 273 | float denominator = v1_length * v2_length; |
| 274 | // assert(!isZero<T>(denominator)); |
| 275 | return std::acos(numerator/denominator); |
| 276 | } |
| 277 | |
| 278 | static cv::Vec2f rotate(const cv::Vec2f& v, float angle) |
| 279 | { |
no outgoing calls
no test coverage detected