예제 #1
0
        public PointDouble GetPointAtLength(double length)
        {
            if (!length.IsFinite())
            {
                throw new ArgumentException("length is not finite");
            }
            if (this.points.Count == 0)
            {
                return(PointDouble.NaN);
            }
            if (length < 0.0)
            {
                return(this.points[0]);
            }
            if (length >= this.length)
            {
                return(this.points[this.points.Count - 1]);
            }
            int num = ListUtil.BinarySearch <double, SegmentedListStruct <double>, DefaultComparerStruct <double> >(this.lengthAtPoint.AsStruct <double>(), length, new DefaultComparerStruct <double>());

            if (num >= 0)
            {
                return(this.points[num]);
            }
            int num2 = ~num;

            if (num2 == this.lengthAtPoint.Count)
            {
                return(this.points[this.points.Count - 1]);
            }
            int         num3 = num2 - 1;
            PointDouble num4 = this.points[num3];
            PointDouble num5 = this.points[num2];
            double      num6 = this.lengthAtPoint[num3];
            double      num7 = this.lengthAtPoint[num2];

            if (num6 == num7)
            {
                return(num4);
            }
            double num8 = (length - num6) / (num7 - num6);
            double num9 = 1.0 - num8;

            return(new PointDouble((num4.X * num9) + (num5.X * num8), (num4.Y * num9) + (num5.Y * num8)));
        }