/// <summary> /// Computes tangents for all keys in the collection. /// </summary> /// <param name="tangentInType">The tangent in-type. <see cref="CurveKey.TangentIn"/> for more details.</param> /// <param name="tangentOutType">The tangent out-type. <see cref="CurveKey.TangentOut"/> for more details.</param> public void ComputeTangents(CurveTangent tangentInType, CurveTangent tangentOutType) { for (var i = 0; i < Keys.Count; ++i) { ComputeTangent(i, tangentInType, tangentOutType); } }
/// <summary> /// Computes all tangents for all CurveKeys in this Curve, using different tangent types for TangentOut and TangentIn. /// </summary> /// <param name="tangentInType">The type of TangentIn to compute (one of the types specified in the CurveTangent enumeration).</param><param name="tangentOutType">The type of TangentOut to compute (one of the types specified in the CurveTangent enumeration).</param> public void ComputeTangents(CurveTangent tangentInType, CurveTangent tangentOutType) { for (int keyIndex = 0; keyIndex < this.Keys.Count; ++keyIndex) { this.ComputeTangent(keyIndex, tangentInType, tangentOutType); } }
public void ComputeTangents(CurveTangent tangentInType, CurveTangent tangentOutType) { for (int i = 0; i < Keys.Count; i++) { ComputeTangent(i, tangentInType, tangentOutType); } }
public void ComputeTangent(int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType) { double num; double num5; if ((this.keys.Count <= keyIndex) || (keyIndex < 0)) { throw new ArgumentOutOfRangeException("keyIndex"); } CurveKey key = this.Keys[keyIndex]; float num2 = num = key.Position; float num3 = (float)num; float position = (float)num; float num6 = num5 = key.Value; float num7 = (float)num5; float num8 = (float)num5; if (keyIndex > 0) { position = this.Keys[keyIndex - 1].Position; num8 = this.Keys[keyIndex - 1].Value; } if ((keyIndex + 1) < this.keys.Count) { num2 = this.Keys[keyIndex + 1].Position; num6 = this.Keys[keyIndex + 1].Value; } if (tangentInType == CurveTangent.Smooth) { float num9 = num2 - position; float num10 = num6 - num8; key.TangentIn = (Math.Abs(num10) >= 1.19209289550781E-07) ? ((num10 * Math.Abs((float)(position - num3))) / num9) : 0f; } else { key.TangentIn = (tangentInType != CurveTangent.Linear) ? 0f : (num7 - num8); } if (tangentOutType == CurveTangent.Smooth) { float num11 = num2 - position; float num12 = num6 - num8; if (Math.Abs(num12) < 1.19209289550781E-07) { key.TangentOut = 0f; } else { key.TangentOut = (num12 * Math.Abs((float)(num2 - num3))) / num11; } } else if (tangentOutType == CurveTangent.Linear) { key.TangentOut = num6 - num7; } else { key.TangentOut = 0f; } }
/// <summary> /// Computes a specified type of TangentIn and a specified type of TangentOut for a given CurveKey. /// </summary> /// <param name="keyIndex">The index of the CurveKey for which to compute tangents (in the Keys collection of the Curve).</param><param name="tangentInType">The type of TangentIn to compute (one of the types specified in the CurveTangent enumeration).</param><param name="tangentOutType">The type of TangentOut to compute (one of the types specified in the CurveTangent enumeration).</param> public void ComputeTangent(int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType) { if (this.keys.Count <= keyIndex || keyIndex < 0) { throw new ArgumentOutOfRangeException("keyIndex"); } CurveKey curveKey = this.Keys[keyIndex]; double num1; float num2 = (float)(num1 = (double)curveKey.Position); float num3 = (float)num1; float num4 = (float)num1; double num5; float num6 = (float)(num5 = (double)curveKey.Value); float num7 = (float)num5; float num8 = (float)num5; if (keyIndex > 0) { num4 = this.Keys[keyIndex - 1].Position; num8 = this.Keys[keyIndex - 1].Value; } if (keyIndex + 1 < this.keys.Count) { num2 = this.Keys[keyIndex + 1].Position; num6 = this.Keys[keyIndex + 1].Value; } if (tangentInType == CurveTangent.Smooth) { float num9 = num2 - num4; float num10 = num6 - num8; curveKey.TangentIn = (double)Math.Abs(num10) >= 1.19209289550781E-07 ? num10 * Math.Abs(num4 - num3) / num9 : 0.0f; } else { curveKey.TangentIn = tangentInType != CurveTangent.Linear ? 0.0f : num7 - num8; } if (tangentOutType == CurveTangent.Smooth) { float num9 = num2 - num4; float num10 = num6 - num8; if ((double)Math.Abs(num10) < 1.19209289550781E-07) { curveKey.TangentOut = 0.0f; } else { curveKey.TangentOut = num10 * Math.Abs(num2 - num3) / num9; } } else if (tangentOutType == CurveTangent.Linear) { curveKey.TangentOut = num6 - num7; } else { curveKey.TangentOut = 0.0f; } }
public void ComputeTangents(CurveTangent tangentType) { for (int i = 0; i < Keys.Count; i++) { CurveKey k = Keys[i]; if (i == 0 || i == Keys.Count - 1) continue; var before = Keys[i - 1]; var after = Keys[i + 1]; k.TangentIn = ((after.Value - before.Value) * ((k.Position - before.Position) / (after.Position - before.Position))); k.TangentOut = ((after.Value - before.Value) * ((after.Position - k.Position) / (after.Position - before.Position))); } }
/// <summary> /// Compute specfied index key tangents. /// </summary> /// <param name="idx"></param> public void ComputeTangents(int keyIndex) { if (keyIndex < 0 || keyIndex > keys.Count || keyIndex > Int32.MaxValue - 2) { throw new ArgumentOutOfRangeException("keyIndex"); } // Compute neighbors tangents too. for (int i = keyIndex - 1; i < keyIndex + 2; ++i) { if (i >= 0 && i < keys.Count) { EditCurveKey key = keys[i]; MarkModify(key); float tangentInValue = key.TangentIn; float tangentOutValue = key.TangentOut; CurveTangent tangentIn = Convert(key.TangentInType); CurveTangent tangentOut = Convert(key.TangentOutType); OriginalCurve.ComputeTangent(i, tangentIn, tangentOut); if (Single.IsNaN(key.TangentIn)) { key.TangentIn = 0.0f; } if (Single.IsNaN(key.TangentOut)) { key.TangentOut = 0.0f; } // Restore original value if EditCurveTanget is fixed. if (key.TangentInType == EditCurveTangent.Fixed) { key.TangentIn = tangentInValue; } if (key.TangentOutType == EditCurveTangent.Fixed) { key.TangentOut = tangentOutValue; } } } }
/// <summary> /// Computes tangents for all keys in the collection. /// </summary> /// <param name="tangentInType">The tangent in-type. <see cref="CurveKey.TangentIn"/> for more details.</param> /// <param name="tangentOutType">The tangent out-type. <see cref="CurveKey.TangentOut"/> for more details.</param> public void ComputeTangents(CurveTangent tangentInType, CurveTangent tangentOutType) { for (int i = 0; i < Keys.Count; i += 1) { ComputeTangent(i, tangentInType, tangentOutType); } }
/// <summary> /// Computes tangents for all keys in the collection. /// </summary> /// <param name="tangentType">The tangent type for both in and out.</param> public void ComputeTangents(CurveTangent tangentType) { ComputeTangents(tangentType, tangentType); }
/// <summary> /// Computes tangent for the specific key in the collection. /// </summary> /// <param name="keyIndex">The index of key in the collection.</param> /// <param name="tangentInType">The tangent in-type. <see cref="CurveKey.TangentIn"/> for more details.</param> /// <param name="tangentOutType">The tangent out-type. <see cref="CurveKey.TangentOut"/> for more details.</param> public void ComputeTangent( int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType ) { // See http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.curvetangent.aspx CurveKey key = Keys[keyIndex]; float p0, p, p1; p0 = p = p1 = key.Position; float v0, v, v1; v0 = v = v1 = key.Value; if (keyIndex > 0) { p0 = Keys[keyIndex - 1].Position; v0 = Keys[keyIndex - 1].Value; } if (keyIndex < Keys.Count-1) { p1 = Keys[keyIndex + 1].Position; v1 = Keys[keyIndex + 1].Value; } switch (tangentInType) { case CurveTangent.Flat: key.TangentIn = 0; break; case CurveTangent.Linear: key.TangentIn = v - v0; break; case CurveTangent.Smooth: float pn = p1 - p0; if (MathHelper.WithinEpsilon(pn, 0.0f)) { key.TangentIn = 0; } else { key.TangentIn = (v1 - v0) * ((p - p0) / pn); } break; } switch (tangentOutType) { case CurveTangent.Flat: key.TangentOut = 0; break; case CurveTangent.Linear: key.TangentOut = v1 - v; break; case CurveTangent.Smooth: float pn = p1 - p0; if (Math.Abs(pn) < float.Epsilon) { key.TangentOut = 0; } else { key.TangentOut = (v1 - v0) * ((p1 - p) / pn); } break; } }
/// <summary> /// Computes tangent for the specific key in the collection. /// </summary> /// <param name="keyIndex">The index of a key in the collection.</param> /// <param name="tangentType">The tangent type for both in and out.</param> public void ComputeTangent(int keyIndex, CurveTangent tangentType) { ComputeTangent(keyIndex, tangentType, tangentType); }
/// <exception cref="ArgumentOutOfRangeException"><c>keyIndex</c> is out of range.</exception> public void ComputeTangent(int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType) { float num2; float num4; float num7; float num8; if ((_keys.Count <= keyIndex) || (keyIndex < 0)) { throw new ArgumentOutOfRangeException("keyIndex"); } CurveKey key = Keys[keyIndex]; float position = num8 = num4 = key.Position; float num = num7 = num2 = key.Value; if (keyIndex > 0) { position = Keys[keyIndex - 1].Position; num = Keys[keyIndex - 1].Value; } if ((keyIndex + 1) < _keys.Count) { num4 = Keys[keyIndex + 1].Position; num2 = Keys[keyIndex + 1].Value; } if (tangentInType == CurveTangent.Smooth) { float num10 = num4 - position; float num6 = num2 - num; if (Math.Abs(num6) < 1.192093E-07f) { key.TangentIn = 0f; } else { key.TangentIn = (num6 * Math.Abs((position - num8))) / num10; } } else if (tangentInType == CurveTangent.Linear) { key.TangentIn = num7 - num; } else { key.TangentIn = 0f; } if (tangentOutType == CurveTangent.Smooth) { float num9 = num4 - position; float num5 = num2 - num; if (Math.Abs(num5) < 1.192093E-07f) { key.TangentOut = 0f; } else { key.TangentOut = (num5 * Math.Abs((num4 - num8))) / num9; } } else if (tangentOutType == CurveTangent.Linear) { key.TangentOut = num2 - num7; } else { key.TangentOut = 0f; } }
public void ComputeTangent(int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType) { CurveKey curveKey = this.keys[keyIndex]; double num1; float num2 = (float)(num1 = (double)curveKey.Position); float num3 = (float)num1; float num4 = (float)num1; double num5; float num6 = (float)(num5 = (double)curveKey.Value); float num7 = (float)num5; float num8 = (float)num5; if (keyIndex > 0) { num4 = this.keys[keyIndex - 1].Position; num8 = this.keys[keyIndex - 1].Value; } if (keyIndex < this.keys.Count - 1) { num2 = this.keys[keyIndex + 1].Position; num6 = this.keys[keyIndex + 1].Value; } switch (tangentInType) { case CurveTangent.Flat: curveKey.TangentIn = 0.0f; break; case CurveTangent.Linear: curveKey.TangentIn = num7 - num8; break; case CurveTangent.Smooth: float num9 = num2 - num4; curveKey.TangentIn = (double)Math.Abs(num9) >= 1.40129846432482E-45 ? (float)(((double)num6 - (double)num8) * (((double)num3 - (double)num4) / (double)num9)) : 0.0f; break; } switch (tangentOutType) { case CurveTangent.Flat: curveKey.TangentOut = 0.0f; break; case CurveTangent.Linear: curveKey.TangentOut = num6 - num7; break; case CurveTangent.Smooth: float num10 = num2 - num4; if ((double)Math.Abs(num10) < 1.40129846432482E-45) { curveKey.TangentOut = 0.0f; break; } else { curveKey.TangentOut = (float)(((double)num6 - (double)num8) * (((double)num2 - (double)num3) / (double)num10)); break; } } }
/// <summary> /// Computes a specified type of TangentIn and a specified type of TangentOut for a given CurveKey. /// </summary> /// <param name="keyIndex">The index of the CurveKey for which to compute tangents (in the Keys collection of the Curve).</param><param name="tangentInType">The type of TangentIn to compute (one of the types specified in the CurveTangent enumeration).</param><param name="tangentOutType">The type of TangentOut to compute (one of the types specified in the CurveTangent enumeration).</param> public void ComputeTangent(int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType) { if (this.keys.Count <= keyIndex || keyIndex < 0) throw new ArgumentOutOfRangeException("keyIndex"); CurveKey curveKey = this.Keys[keyIndex]; double num1; float num2 = (float)(num1 = (double)curveKey.Position); float num3 = (float)num1; float num4 = (float)num1; double num5; float num6 = (float)(num5 = (double)curveKey.Value); float num7 = (float)num5; float num8 = (float)num5; if (keyIndex > 0) { num4 = this.Keys[keyIndex - 1].Position; num8 = this.Keys[keyIndex - 1].Value; } if (keyIndex + 1 < this.keys.Count) { num2 = this.Keys[keyIndex + 1].Position; num6 = this.Keys[keyIndex + 1].Value; } if (tangentInType == CurveTangent.Smooth) { float num9 = num2 - num4; float num10 = num6 - num8; curveKey.TangentIn = (double)Math.Abs(num10) >= 1.19209289550781E-07 ? num10 * Math.Abs(num4 - num3) / num9 : 0.0f; } else curveKey.TangentIn = tangentInType != CurveTangent.Linear ? 0.0f : num7 - num8; if (tangentOutType == CurveTangent.Smooth) { float num9 = num2 - num4; float num10 = num6 - num8; if ((double)Math.Abs(num10) < 1.19209289550781E-07) curveKey.TangentOut = 0.0f; else curveKey.TangentOut = num10 * Math.Abs(num2 - num3) / num9; } else if (tangentOutType == CurveTangent.Linear) curveKey.TangentOut = num6 - num7; else curveKey.TangentOut = 0.0f; }
public void ComputeTangents(CurveTangent tangentInType, CurveTangent tangentOutType) { throw new NotImplementedException(); }
/// <summary> /// Computes both the TangentIn and the TangentOut for a CurveKey specified by its index. /// </summary> /// <param name="keyIndex">The index of the CurveKey for which to compute tangents (in the Keys collection of the Curve).</param><param name="tangentType">The type of tangents to compute (one of the types specified in the CurveTangent enumeration).</param> public void ComputeTangent(int keyIndex, CurveTangent tangentType) { this.ComputeTangent(keyIndex, tangentType, tangentType); }
public void ComputeTangent(int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType) { CurveKey curveKey = this.keys[keyIndex]; double num1; float num2 = (float) (num1 = (double) curveKey.Position); float num3 = (float) num1; float num4 = (float) num1; double num5; float num6 = (float) (num5 = (double) curveKey.Value); float num7 = (float) num5; float num8 = (float) num5; if (keyIndex > 0) { num4 = this.keys[keyIndex - 1].Position; num8 = this.keys[keyIndex - 1].Value; } if (keyIndex < this.keys.Count - 1) { num2 = this.keys[keyIndex + 1].Position; num6 = this.keys[keyIndex + 1].Value; } switch (tangentInType) { case CurveTangent.Flat: curveKey.TangentIn = 0.0f; break; case CurveTangent.Linear: curveKey.TangentIn = num7 - num8; break; case CurveTangent.Smooth: float num9 = num2 - num4; curveKey.TangentIn = (double) Math.Abs(num9) >= 1.40129846432482E-45 ? (float) (((double) num6 - (double) num8) * (((double) num3 - (double) num4) / (double) num9)) : 0.0f; break; } switch (tangentOutType) { case CurveTangent.Flat: curveKey.TangentOut = 0.0f; break; case CurveTangent.Linear: curveKey.TangentOut = num6 - num7; break; case CurveTangent.Smooth: float num10 = num2 - num4; if ((double) Math.Abs(num10) < 1.40129846432482E-45) { curveKey.TangentOut = 0.0f; break; } else { curveKey.TangentOut = (float) (((double) num6 - (double) num8) * (((double) num2 - (double) num3) / (double) num10)); break; } } }
public void ComputeTangents(CurveTangent tangentInType, CurveTangent tangentOutType) { for (int keyIndex = 0; keyIndex < this.Keys.Count; ++keyIndex) this.ComputeTangent(keyIndex, tangentInType, tangentOutType); }
/// <summary> /// Computes all tangents for all CurveKeys in this Curve, using a specified tangent type for both TangentIn and TangentOut. /// </summary> /// <param name="tangentType">The type of TangentOut and TangentIn to compute (one of the types specified in the CurveTangent enumeration).</param> public void ComputeTangents(CurveTangent tangentType) { this.ComputeTangents(tangentType, tangentType); }
public void ComputeTangent(int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType) { // See http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.curvetangent.aspx var key = keys[keyIndex]; float p0, p, p1; p0 = p = p1 = key.Position; float v0, v, v1; v0 = v = v1 = key.Value; if (keyIndex > 0) { p0 = keys[keyIndex - 1].Position; v0 = keys[keyIndex - 1].Value; } if (keyIndex < keys.Count - 1) { p1 = keys[keyIndex + 1].Position; v1 = keys[keyIndex + 1].Value; } switch (tangentInType) { case CurveTangent.Flat: key.TangentIn = 0; break; case CurveTangent.Linear: key.TangentIn = v - v0; break; case CurveTangent.Smooth: var pn = p1 - p0; if (Math.Abs(pn) < float.Epsilon) { key.TangentIn = 0; } else { key.TangentIn = (v1 - v0) * ((p - p0) / pn); } break; } switch (tangentOutType) { case CurveTangent.Flat: key.TangentOut = 0; break; case CurveTangent.Linear: key.TangentOut = v1 - v; break; case CurveTangent.Smooth: var pn = p1 - p0; if (Math.Abs(pn) < float.Epsilon) { key.TangentOut = 0; } else { key.TangentOut = (v1 - v0) * ((p1 - p) / pn); } break; } }
public void ComputeT(int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType) { if (this.Keys.Count <= keyIndex || keyIndex < 0) { throw new ArgumentOutOfRangeException("keyIndex"); } CurveKey curveKey = this.Keys[keyIndex]; double position; double num2; double num = num2 = (position = curveKey.Position); double value; double num4; double num3 = num4 = (value = curveKey.Value); if (keyIndex > 0) { num2 = this.Keys[keyIndex - 1].Position; num4 = this.Keys[keyIndex - 1].Value; } if (keyIndex + 1 < this.Keys.Count) { position = this.Keys[keyIndex + 1].Position; value = this.Keys[keyIndex + 1].Value; } if (tangentInType == CurveTangent.Smooth) { double num5 = position - num2; double num6 = value - num4; if (Math.Abs(num6) < 1.1920929E-07f) { curveKey.TangentIn = 0f; } else { curveKey.TangentIn = (float)(num6 * Math.Abs(num2 - num) / num5); } } else { if (tangentInType == CurveTangent.Linear) { curveKey.TangentIn = (float)(num3 - num4); } else { curveKey.TangentIn = 0f; } } if (tangentOutType == CurveTangent.Smooth) { double num7 = position - num2; double num8 = value - num4; if (Math.Abs(num8) < 1.1920929E-07f) { curveKey.TangentOut = 0f; return; } curveKey.TangentOut = (float)(num8 * Math.Abs(position - num) / num7); return; } else { if (tangentOutType == CurveTangent.Linear) { curveKey.TangentOut = (float)(value - num3); return; } curveKey.TangentOut = 0f; return; } }
public void ComputeTangent(int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType) { float num2; float num4; float num7; float num8; if ((this.keys.Count <= keyIndex) || (keyIndex < 0)) { throw new ArgumentOutOfRangeException("keyIndex"); } CurveKey key = this.Keys[keyIndex]; float position = num8 = num4 = key.Position; float num = num7 = num2 = key.Value; if (keyIndex > 0) { position = this.Keys[keyIndex - 1].Position; num = this.Keys[keyIndex - 1].Value; } if ((keyIndex + 1) < this.keys.Count) { num4 = this.Keys[keyIndex + 1].Position; num2 = this.Keys[keyIndex + 1].Value; } if (tangentInType == CurveTangent.Smooth) { float num10 = num4 - position; float num6 = num2 - num; if (Math.Abs(num6) < 1.192093E-07f) { key.TangentIn = 0f; } else { key.TangentIn = (num6 * Math.Abs((float) (position - num8))) / num10; } } else if (tangentInType == CurveTangent.Linear) { key.TangentIn = num7 - num; } else { key.TangentIn = 0f; } if (tangentOutType == CurveTangent.Smooth) { float num9 = num4 - position; float num5 = num2 - num; if (Math.Abs(num5) < 1.192093E-07f) { key.TangentOut = 0f; } else { key.TangentOut = (num5 * Math.Abs((float) (num4 - num8))) / num9; } } else if (tangentOutType == CurveTangent.Linear) { key.TangentOut = num2 - num7; } else { key.TangentOut = 0f; } }
public void ComputeT(int keyIndex, CurveTangent tangentType) { this.ComputeT(keyIndex, tangentType, tangentType); }