如何找到 2 System.Drawing.Point 之间的距离?
我用谷歌搜索并没有找到它......
Dim p1 As New Point(0, 10)
Dim p2 As New Point(10, 10)
Dim distance = ??
在这种情况下,它应该是 10,但是这里呢?
Dim p1 As New Point(124, 942)
Dim p2 As New Point(34, 772)
Dim distance = ??
谢谢!
距离公式:sqrt( (x2 - x1)^2 + (y2 - y1)^2 )
Point p1 = new Point(7, 5);
Point p2 = new Point(26, 29);
double distance = Math.Round(Math.Sqrt(Math.Pow((p2.X - p1.X), 2) + Math.Pow((p2.Y - p1.Y), 2)), 1);
如果你想知道人们给你的公式来自哪里,这被概括为勾股定理。
伪代码:
SquareRoot(Square(p1.x - p2.x)+Square(p1.y-p2.y))