As stated in this section: How to convert from a Hermite curve to a Bezier curve? In particular, I'm looking for a way to convert the Curve class that uses Hermite interpolation, the Microsoft XNA Framework, which will be drawn using StreamGeometry or PathGeometry for the Windows Presentation Foundation.
I came across a similar question ([Drawing Hermite Curves in OpenGL), where the answer is the following.
[b0] = 1 [ 3 0 0 0] [h0] [b1] - [ 3 0 1 0] [h1] [b2] 3 [ 0 3 0 -1] [v0] [b3] [ 0 3 0 0] [v1]
This simplifies:
b0 = h0 b1 = h0 + v0/3 b2 = h1 - v1/3 b3 = h1
Even with this information, I'm mostly fixated on calculating breakpoints. The problem is that the Curve class provides TangentIn and TangentOut as a scalar. Given that the polynomial is drawn in two-dimensional space (time, value), this scalar must be converted to a two-dimensional vector in order to apply it to this formula. However, Iβm not sure what steps are involved with this conversion process, but I suspect that I need to apply the Hermite differentiation equation.
If this helps, this is the code used to evaluate the curve at the moment, found using Reflector.
private static float Hermite(CurveKey k0, CurveKey k1, float t) { if (k0.Continuity == CurveContinuity.Step) { if (t >= 1f) { return k1.internalValue; } return k0.internalValue; } float num = t * t; float num2 = num * t; float internalValue = k0.internalValue; float num5 = k1.internalValue; float tangentOut = k0.tangentOut; float tangentIn = k1.tangentIn; return ((((internalValue * (((2f * num2) - (3f * num)) + 1f)) + (num5 * ((-2f * num2) + (3f * num)))) + (tangentOut * ((num2 - (2f * num)) + t))) + (tangentIn * (num2 - num))); }
Any information is greatly appreciated.
source share