Esempio n. 1
0
        /// <summary>
        /// Samples a curve in an adaptive way. <br/>
        /// <em>Corresponds to this algorithm http://ariel.chronotext.org/dd/defigueiredo93adaptive.pdf </em>
        /// </summary>
        /// <param name="curve">The curve to sampling.</param>
        /// <param name="tolerance">The tolerance for the adaptive division.</param>
        /// <returns>A tuple collecting the parameter where it was sampled and the points.</returns>
        public static (List <double> tValues, List <Point3> pts) AdaptiveSample(NurbsBase curve, double tolerance = GSharkMath.MinTolerance)
        {
            if (curve.Degree != 1)
            {
                return(AdaptiveSampleRange(curve, curve.Knots[0], curve.Knots[curve.Knots.Count - 1], tolerance));
            }
            KnotVector copyKnot = new KnotVector(curve.Knots);

            copyKnot.RemoveAt(0);
            copyKnot.RemoveAt(copyKnot.Count - 1);
            return(copyKnot, curve.ControlPointLocations);
        }