MCPcopy Create free account
hub / github.com/davisking/dlib / nearest_point

Function nearest_point

dlib/geometry/rectangle.h:448–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 6

nearest_rectFunction · 0.85
clip_line_to_rectangleFunction · 0.85
on_mouse_moveMethod · 0.85
on_mouse_downMethod · 0.85
get_feature_vectorMethod · 0.85

Calls 4

leftMethod · 0.45
rightMethod · 0.45
topMethod · 0.45
bottomMethod · 0.45

Tested by

no test coverage detected