private protected (_CurveNode <T> A, _CurveNode <T> B, float Amount) FindSample(float offset) { if (_Keys.Count == 0) { return(default(_CurveNode <T>), default(_CurveNode <T>), 0); } var(keyA, keyB, amount) = SamplerFactory.FindPairContainingOffset(_Keys.Keys, offset); return(_Keys[keyA], _Keys[keyB], amount); }
private protected (_CurveNode <T>, _CurveNode <T>, float) FindSample(float offset) { if (_Keys.Count == 0) { return(default(_CurveNode <T>), default(_CurveNode <T>), 0); } var offsets = SamplerFactory.FindPairContainingOffset(_Keys.Keys, offset); return(_Keys[offsets.Item1], _Keys[offsets.Item2], offsets.Item3); }
/// <summary> /// Sets the incoming tangent to an existing point. /// </summary> /// <param name="offset">The offset of the existing point.</param> /// <param name="tangent">The tangent value.</param> public void SetIncomingTangent(float offset, T tangent) { Guard.IsTrue(_Keys.ContainsKey(offset), nameof(offset)); offset -= float.Epsilon; var offsets = SamplerFactory.FindPairContainingOffset(_Keys.Keys, offset); var a = _Keys[offsets.Item1]; var b = _Keys[offsets.Item2]; if (a.Degree == 1) { a.OutgoingTangent = GetTangent(a.Point, b.Point); } a.Degree = 3; b.IncomingTangent = tangent; _Keys[offsets.Item1] = a; _Keys[offsets.Item2] = b; }
/// <summary> /// Sets the outgoing tangent to an existing point. /// </summary> /// <param name="offset">The offset of the existing point.</param> /// <param name="tangent">The tangent value.</param> public void SetOutgoingTangent(float offset, T tangent) { Guard.IsTrue(_Keys.ContainsKey(offset), nameof(offset)); var(keyA, keyB, _) = SamplerFactory.FindPairContainingOffset(_Keys.Keys, offset); var a = _Keys[keyA]; var b = _Keys[keyB]; if (keyA != keyB) { if (a.Degree == 1) { b.IncomingTangent = GetTangent(a.Point, b.Point); } _Keys[keyB] = b; } a.Degree = 3; a.OutgoingTangent = tangent; _Keys[keyA] = a; }
public override Vector3 GetPoint(Single offset) { var sample = FindSample(offset); switch (sample.Item1.Degree) { case 0: return(sample.Item1.Point); case 1: return(Vector3.Lerp(sample.Item1.Point, sample.Item2.Point, sample.Item3)); case 3: return(SamplerFactory.InterpolateCubic ( sample.Item1.Point, sample.Item1.OutgoingTangent, sample.Item2.Point, sample.Item2.IncomingTangent, sample.Item3 )); default: throw new NotSupportedException(); } }
public override Quaternion GetPoint(float offset) { var sample = FindSample(offset); switch (sample.A.Degree) { case 0: return(sample.A.Point); case 1: return(Quaternion.Slerp(sample.A.Point, sample.B.Point, sample.Amount)); case 3: return(SamplerFactory.InterpolateCubic ( sample.A.Point, sample.A.OutgoingTangent, sample.B.Point, sample.B.IncomingTangent, sample.Amount )); default: throw new NotSupportedException(); } }
protected override Vector3 GetTangent(Vector3 fromValue, Vector3 toValue) { return(SamplerFactory.CreateTangent(fromValue, toValue)); }
protected override Quaternion GetTangent(Quaternion fromValue, Quaternion toValue) { return(SamplerFactory.CreateTangent(fromValue, toValue)); }