public Point2D GetPointByDistance(double x, double distance, AbscissaDirection direction) { if (distance.IsApproximately(0.0)) { return(new Point2D(x, CalculateY(x))); } if (distance.IsLessThanOrApproximatelyEqualTo(0.0)) { distance = Math.Abs(distance); direction = direction == AbscissaDirection.LeftToRight ? AbscissaDirection.RightToLeft : AbscissaDirection.LeftToRight; } var xDistance = Math.Sqrt(distance.Square() / (Slope.Square() + 1)); var x1 = x - xDistance; var x2 = x + xDistance; var pointX = direction == AbscissaDirection.LeftToRight ? (x1.IsGreaterThanOrApproximatelyEqualTo(x) ? x1 : x2) : (x1.IsLessThanOrApproximatelyEqualTo(x) ? x1 : x2); return(new Point2D(pointX, CalculateY(pointX))); }