public bool IsParallel(Line line) { Vector firstLineDirectionVector = GetDirectionVector(); Vector secondLineDirectionVector = line.GetDirectionVector(); firstLineDirectionVector.Normalize(secondLineDirectionVector.GetLength()); if (!(firstLineDirectionVector - secondLineDirectionVector).IsZeroVector()) { firstLineDirectionVector = firstLineDirectionVector * (-1.0); } Vector difference = firstLineDirectionVector - secondLineDirectionVector; return(difference.IsZeroVector()); }
/// <summary> /// Возвращает точку на отрезку, делящую его в заданном отношении считая от вершины A. /// </summary> public Point GetDividingPointByRatio(double ratio) { if (ratio < 0) { ratio = 0; } if (ratio > 1) { ratio = 1; } var fromAToB = new Vector(A, B); fromAToB.Normalize(ratio * GetLength()); return(A + fromAToB); }