Mic*_*eth 2 c# geometry system.drawing
如果我System.Drawing.Rectangle
在画布和一个上有两个对象,计算哪个( 的任何部分,而不仅仅是它的)最接近那个Point
的最佳方法是什么?Rectangle
Rectangle
Location
Point
Point
一个单元测试的例子:
Rectangle one = new Rectangle (0, 0, 10, 10);
Rectangle two = new Rectangle (20, 20, 10, 10);
Point point = new Point(14, 14);
Rectangle actual = ClosestToPoint(point, one, two);
// should be closer to one since one's bottom right is at (10, 10)
Assert.That(actual, Is.SameAs(one));
// method to write
public Rectangle ClosestToPoint(Point p, params Rectangle[] rectangles) { }
Run Code Online (Sandbox Code Playgroud)