/// <summary> /// Gets the bottomlevel of the branch. Interpolates linearly between points /// </summary> /// <param name="chainage"></param> /// <returns></returns> public double GetBottomLevelAtChainage(double chainage) { if (chainage <= ChainageStart) return CrossSections.First().BottomLevel; if (chainage >= ChainageEnd) return CrossSections.Last().BottomLevel; LinearSplineInterpolation lsp = new LinearSplineInterpolation(CrossSections.Select(xc=>xc.Chainage).ToList(), CrossSections.Select(xc=>xc.BottomLevel).ToList()); return lsp.Interpolate(chainage); }
public XYPoint GetPointAtChainage(double chainage) { var distinctpoints = Points.DistinctBy(pp => pp.Chainage).ToList(); LinearSplineInterpolation lspx = new LinearSplineInterpolation(distinctpoints.Select(xc => xc.Chainage).ToList(), distinctpoints.Select(xc => xc.X).ToList()); LinearSplineInterpolation lspy = new LinearSplineInterpolation(distinctpoints.Select(xc => xc.Chainage).ToList(), distinctpoints.Select(xc => xc.Y).ToList()); return new XYPoint(lspx.Interpolate(chainage), lspy.Interpolate(chainage)); }