コード例 #1
0
        public PointOnPath AdvancePoint(PointOnPath pt, ref double dist)
        {
            // assert that we're looking at the same segment
            Debug.Assert(Equals(pt.segment));

            if (pt.dist + dist <= 0)
            {
                // handle the case of negative distance going before start point
                dist += pt.dist;
                return(StartPoint);
            }
            else if (pt.dist + dist >= cb.ArcLength)
            {
                // handle the case of positive distance going after end point
                dist -= cb.ArcLength - pt.dist;
                return(EndPoint);
            }
            else
            {
                // we're in the range that we can achieve
                double targetDist = pt.dist + dist;
                double tValue     = cb.FindT(targetDist);
                double actDist    = cb.PartialArcLength(tValue);

                dist = 0;
                return(new PointOnPath(this, targetDist, cb.Bt(tValue)));
            }
        }