質問
どのように私は2 System.Drawing.Pointの間の距離を見つけることができますか?
私はGoogleで検索して、それを見つけることができませんでした...
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((×2 - ×1)^ 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))
所属していません StackOverflow