public CurveKey2D AddKey(float time, Vector2 point) { // find insertion point int pos = Keys.Count; while (pos > 0 && time < Keys[pos - 1].Time) { pos--; } // add new key to list CurveKey2D newKey = new CurveKey2D(time, point); if (pos == Keys.Count) { Keys.Add(newKey); } else { Keys.Insert(pos, newKey); } needsUpdate = true; return(newKey); }
//q(t) = 0.5 *( (2 * P1) + // (-P0 + P2) * t + // (2*P0 - 5*P1 + 4*P2 - P3) * t2 + // (-P0 + 3*P1- 3*P2 + P3) * t3) //q'(t) = 0.5 *( (2 * P1) + // (-P0 + P2) * t + // (2*P0 - 5*P1 + 4*P2 - P3) * t2 + // (-P0 + 3*P1- 3*P2 + P3) * t3) // http://www.cubic.org/docs/hermite.htm // http://en.wikipedia.org/wiki/Catmull-Rom_spline#Catmull.E2.80.93Rom_spline public CurveKey2D AddKey(float time, Vector2 point, float tension) { CurveKey2D newKey = AddKey(time, point); newKey.Tension = tension; return(newKey); }
public CurveKey2D AddKey(float time, Vector2 point) { // find insertion point int pos = Keys.Count; while (pos > 0 && time < Keys[pos - 1].Time) pos--; // add new key to list CurveKey2D newKey = new CurveKey2D(time, point); if (pos == Keys.Count) Keys.Add(newKey); else Keys.Insert(pos, newKey); needsUpdate = true; return newKey; }