Frage

Wie kann ich den Abstand zwischen 2 System.Drawing.Point finden?

ich gegoogelt und fand es nicht ...

Dim p1 As New Point(0, 10)
Dim p2 As New Point(10, 10)
Dim distance = ??

In diesem Fall sollte es 10 sein, aber was ist hier?

Dim p1 As New Point(124, 942)
Dim p2 As New Point(34, 772)
Dim distance = ??

Danke!

War es hilfreich?

Lösung

Entfernung Formel: sqrt ((x2 - x1) ^ 2 + (y2 - y1) ^ 2)

Andere Tipps

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);

Wenn Sie wissen wollen, wo die Formel, die Menschen, die Sie geben herkommt, wird dies als Die Satz des Pythagoras .

Pseudocode:

SquareRoot(Square(p1.x - p2.x)+Square(p1.y-p2.y))
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top