public double DistanceToLine(LineDescription2D l1) { //PointD vect1 = new PointD(l1.directionVector[0], l1.directionVector[1]); //PointD vect2 = l1.p0 - new SizeD(this); //double retDist = (vect1.X * vect2.Y - vect1.Y * vect2.X) / (l1.directionVectorLength); //return Math.Abs(retDist); return(l1.Distance(this)); }
public static PointD CrossPoint(LineDescription2D l1, LineDescription2D l2) { PointD pc = new PointD(); if ((l1.directionVector == l2.directionVector) || (l1.directionVector == -l2.directionVector)) { return(PointD.nullPointD()); } double d1 = l2.p0.Y * l1.directionVector.X - l1.p0.Y * l1.directionVector.X + l1.p0.X * l1.directionVector.Y - l2.p0.X * l1.directionVector.Y; double d2 = l1.directionVector.Y * l2.directionVector.X - l1.directionVector.X * l2.directionVector.Y; double t2Cross = d1 / d2; pc = (l2.p0 + l2.directionVector * t2Cross).ToPointD(); return(pc); }