public PointFr?Intersection(LineFr that) { if (Slope == that.Slope) { return(null); } var xInt = XIntercept(that); if (IsVertical()) { return(new PointFr(xInt, that.YIntercept(xInt))); } return(new PointFr(xInt, YIntercept(xInt))); }
public bool IsRightOf(LineFr line) { if (line.Contains(this)) { return(false); } if (line.IsHorizontal()) { return(Y < line.YIntercept()); } if (line.IsVertical()) { return(X > line.XIntercept()); } var linePointNullable = line.Intersection(LineFr.Vertical(Fraction.Zero)); if (linePointNullable == null) { throw new ArgumentException("Wartość linePoint nie może wynosić null"); } var linePoint = (PointFr)linePointNullable; var temp = new LineFr(this, linePoint); if (Y < linePoint.Y) { if (line.Slope < 0) // a { return(temp.Slope < 0 && temp.Slope > line.Slope); } return(temp.Slope < 0 || temp.Slope > line.Slope); // b } if (Y > linePoint.Y) { if (line.Slope < 0) // c { return(temp.Slope >= 0 || temp.Slope < line.Slope); } return(temp.Slope >= 0 && temp.Slope < line.Slope); // d } return(IsRightOf(linePoint)); // 'this' ma taką samą współrzędną y jak 'linePoint' }