문제

2 System.Drawing.point 사이의 거리를 어떻게 찾을 수 있습니까?

나는 Googled를 찾지 못했습니다 ...

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))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top