| 446 | |
| 447 | template <typename T> |
| 448 | inline const dlib::vector<T,2> nearest_point ( |
| 449 | const rectangle& rect, |
| 450 | const dlib::vector<T,2>& p |
| 451 | ) |
| 452 | { |
| 453 | dlib::vector<T,2> temp(p); |
| 454 | if (temp.x() < rect.left()) |
| 455 | temp.x() = rect.left(); |
| 456 | else if (temp.x() > rect.right()) |
| 457 | temp.x() = rect.right(); |
| 458 | |
| 459 | if (temp.y() < rect.top()) |
| 460 | temp.y() = rect.top(); |
| 461 | else if (temp.y() > rect.bottom()) |
| 462 | temp.y() = rect.bottom(); |
| 463 | |
| 464 | return temp; |
| 465 | } |
| 466 | |
| 467 | // ---------------------------------------------------------------------------------------- |
| 468 |
no test coverage detected