Exemple #1
0
        public Vector2 Interpolate(float time)
        {
            // Clamp the time
            time = MathF.Clamp(0f, (float)Segments(), time);

            // Get time floored
            float Fl = MathF.Floor(time);

            // Get the segment being interpolated
            Knot St = m_Knots[(int)Fl];
            Knot En = m_Knots[(int)Fl + 1];

            // Interpolate spline and return the calculate value
            return(Vector2.Hermite(St.Point, En.Point, St.Out, En.In, time - Fl));
        }
        // Manipulating the current spline
        #region Spline Functions

        // Time will be clamped
        // Time = 0 <= time <= m_Knots.Count - 1
        public Vector2 Interpolate(float time)
        {
            // Clamp the time
            time = MathF.Clamp(0f, (float)Segments(), time);

            // Get time floored
            float Fl = MathF.Floor(time);

            // Assure floored value stays within range
            Fl = Fl >= (float)Segments() ? 0f : Fl;

            // Get the segment being interpolated
            Knot St = m_Knots[(int)Fl];
            Knot En = m_Knots[(int)Fl + 1];

            // Interpolate spline and return the calculate value
            return(Vector2.Hermite(St.Position, En.Position, St.Out, En.In, time - Fl));
        }