public Fraction Tangent(LineFr that) // tan(theta) = (m1 - m2)/(1 + (m1*m2)) { if (isParallelTo(that)) { return(Fraction.Zero); } if (IsVertical()) { if (that.IsHorizontal()) { return(-1); } return(Slope.Inverse()); } if (that.IsVertical()) { if (that.IsHorizontal()) { return(-1); } return(Slope); } if (isPerpendicularTo(that)) { return(-1); } return((Slope - that.Slope) / (1 + Slope * that.Slope)); }
public LineFr PerpendicularLine(PointFr p) { if (IsHorizontal()) { return(Vertical(p.X)); } if (IsVertical()) { return(Horizontal(p.Y)); } var newSlope = Slope.Inverse(); return(new LineFr(newSlope, p)); }