Spaceman85
Mitglied
Hallo,
wie berechne ich denn Abstand zwischen einen Punkt und einer Geraden (2D)?
Danke
wie berechne ich denn Abstand zwischen einen Punkt und einer Geraden (2D)?
Danke
Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature currently requires accessing the site using the built-in Safari browser.
public double getDistance(Point a, Point r1, Point r2)
{
// Point x = new Point();
// Point ar = new Point();
// x.x = r2.x - r1.x;
// x.y = r2.y - r1.y;
// ar.x = a.x * x.x;
// ar.y = a.y * x.y;
//
// double distance = ((Math.sqrt(((ar.x*ar.x)+(ar.y*ar.y))))/(Math.sqrt((a.x*a.x)+(a.y*a.y))));
double m= (r2.y -r1.y)/(r2.x -r1.x);
double n = r1.y-(m*r1.x);
double distance = Math.abs(((m*a.x) - (a.y+n))/Math.sqrt((m*m)+1));
return distance;
}