Exemplo n.º 1
0
        /// <summary>
        /// Should solve
        /// </summary>
        /// <param name="c"></param>
        /// <param name="t0"></param>
        /// <param name="distance"></param>
        /// <returns></returns>
        public static double PointAtDistanceFrom(this ICurve c, double t0, double distance)
        {
            Func <double, double> objFunc = t1 =>
            {
                var length3 = t0 < t1?c.GetLength3(t0, t1) : c.GetLength3(t1, t0);

                return(length3 - Math.Abs(distance));
            };
            var domain = c.Domain();
            var min    = distance < 0.0 ? 0.8 * domain[0] : t0;
            var max    = distance < 0.0 ? t0 : 1.2 * domain[1];
            var solver = new BrentSearch(objFunc, min, max);

            solver.FindRoot();
            var sol = solver.Solution;

            return(sol);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Return the length of the curve between the start
        /// and end parameters.
        /// </summary>
        /// <param name="curve"></param>
        /// <returns></returns>
        public static double Length(this ICurve curve)
        {
            bool   isPeriodic;
            double end;
            bool   isClosed;
            double start;

            curve.GetEndParams(out start, out end, out isClosed, out isPeriodic);
            return(curve.GetLength3(start, end));
        }