@brief Computes the average similarity between |rect| and |pivot|. By similarity between two rects we mean a fraction of the area of rects intersection to the area of the smallest rect. @return [0, 1]
| 267 | /// rects intersection to the area of the smallest rect. |
| 268 | /// @return [0, 1] |
| 269 | double GetSimilarity(m2::RectD const & pivot, m2::RectD const & rect) |
| 270 | { |
| 271 | double const area = min(Area(pivot), Area(rect)); |
| 272 | if (area == 0.0) |
| 273 | return 0.0; |
| 274 | m2::RectD p = pivot; |
| 275 | if (!p.Intersect(rect)) |
| 276 | return 0.0; |
| 277 | return Area(p) / area; |
| 278 | } |
| 279 | |
| 280 | // Returns shortest distance from the |pivot| to the |rect|. |
| 281 | // |
no test coverage detected