Example #1
0
            public static void Cubic(ref Core.Mathematics.Vector2 value1, ref Core.Mathematics.Vector2 value2, ref Core.Mathematics.Vector2 value3, ref Core.Mathematics.Vector2 value4, float t, out Core.Mathematics.Vector2 result)
            {
                // http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Interpolation_on_the_unit_interval_without_exact_derivatives
                float t2 = t * t;
                float t3 = t2 * t;

                float factor0 = -t3 + 2.0f * t2 - t;
                float factor1 = 3.0f * t3 - 5.0f * t2 + 2.0f;
                float factor2 = -3.0f * t3 + 4.0f * t2 + t;
                float factor3 = t3 - t2;

                // TODO: Use Vector3(ref,out) functions
                result.X = 0.5f * (value1.X * factor0 + value2.X * factor1 + value3.X * factor2 + value4.X * factor3);
                result.Y = 0.5f * (value1.Y * factor0 + value2.Y * factor1 + value3.Y * factor2 + value4.Y * factor3);
            }
Example #2
0
 public static void Linear(ref Core.Mathematics.Vector2 value1, ref Core.Mathematics.Vector2 value2, float t, out Core.Mathematics.Vector2 result)
 {
     Core.Mathematics.Vector2.Lerp(ref value1, ref value2, t, out result);
 }