Ejemplo n.º 1
0
        public static IEnumerable <CurveIterator <T> > Iterate <T>(this curve <T> c, float stepMultiplier)
        {
            float sl    = c.length;
            float islsl = 1 / (sl * sl);

            float t = 0;

            while (true)
            {
                CurveIterator <T> i;
                i.t        = t;
                i.value    = c.value(t);
                i.velocity = c.velocity(t);
                yield return(i);

                if (t == 1)
                {
                    yield break;
                }

                float dt = MathExOps.Clamp(MathTypeTag <T> .Get().scalar(i.velocity) * islsl * stepMultiplier, islsl, 1);
                t = MathExOps.Clamp01(t + dt);
            }
        }
Ejemplo n.º 2
0
        public static IEnumerable <CurveIterator <T> > IterateEquidistant <T>(this curve <T> c, float fraction)
        {
            var   d      = c.distance;
            float length = d.length;
            float delta  = d.length * fraction;

            float cd = 0;

            while (true)
            {
                CurveIterator <T> i;
                i.t        = d.time(cd);
                i.value    = c.value(i.t);
                i.velocity = c.velocity(i.t);
                yield return(i);

                if (cd == length)
                {
                    yield break;
                }

                cd = MathExOps.Clamp(cd + delta, 0, length);
            }
        }
Ejemplo n.º 3
0
 [Serializable] public class controller_type : curve_controller <curve <T>, T> { public controller_type(curve <T> c) : base(c)
                                                                                 {
                                                                                 }
Ejemplo n.º 4
0
 [Serializable] public class distance_type : curve_distance <curve <T>, T> { public distance_type(curve <T> c) : base(c)
                                                                             {
                                                                             }
Ejemplo n.º 5
0
 public static IEnumerable <CurveIterator <T> > Iterate <T>(this curve <T> c)
 {
     return(c.Iterate(1f));
 }