In this post we will discuss the implementation of Hermite and Catmull Splines in SteerLite. The projects were created by a team of 3 as part of a class project for Introduction to Computer Graphics at Rutgers University.
Hermite Videos
Curve 1
Curve 2
Curve 3
Curve 4
Original Test Case
Equation
\(p(x) = h_{00}(t)p_k + h_{10}(t)(x_{k+1} - x_{k})m_k + h_{01}(t)p_{k+1} +\) \(h_{11}(t)(x_{k+1}-x_{k})m_{k+1}\)
\[t = \frac{(x-x_k)}{x_{k+1}-x_k}\] \[h_{00}(t) = 2t^3 -3t^2 +1\] \[h_{10}(t) = t^3 -2t^2 +t\] \[h_{01}(t) = -2t^3 +3t^2\] \[h_{11}(t) = t^3 - t^2\]Catmull Rom Videos
Curve 1
Curve 2
Curve 3
Curve 4
Original Test Case
Equation
\(p(x) = h_{00}(t)p_k + h_{10}(t)(tangent_{0})m_k + h_{01}(t)p_{k+1} +\) \(h_{11}(t)(tangent_{1})m_{k+1}\)
\[t = \frac{(x-x_k)}{x_{k+1}-x_k}\] \[h_{00}(t) = 2t^3 -3t^2 +1\] \[h_{10}(t) = t^3 -2t^2 +t\] \[h_{01}(t) = -2t^3 +3t^2\] \[h_{11}(t) = t^3 - t^2\]Tangent Equation
Current point is the next point you will reach
\(Tangent_0\) has i = currentPoint -1
\(Tagent_1\) has i = currentPoint
If First Segment of Curve:
\[FirstCoef = \frac{(t_2 - t_{0})}{(t_{2} - t_{1})}\] \[FirsTerm = \frac{(p_{1} - p_0)}{ (t_{1} - t_0)}\] \[SecondCoef = -1 * \frac{(t_{1} - t_0) }{(t_{2} - t_{1})}\] \[SecondTerm = \frac{(p_2 - p_{0})}{(t_2 - t_{0})}\] \[Tangent = firstCoeff * firstTerm +\] \[secondCoeff * secondTerm\]If Last Segment of Curve:
\[FirstCoef = \frac{(t_i - t_{i-})}{(t_{i-1} - t_{i-2})}\] \[FirsTerm = \frac{(p_{i} - p_{i-1})}{ (t_{i} - t_{i-1})}\] \[SecondCoef = -1 * \frac{(t_{i} - t_{i-1}) }{(t_{i-1} - t_{i-2})}\] \[SecondTerm = \frac{(p_i - p_{i-2})}{(t_i - t_{i-2})}\] \[Tangent = firstCoeff * firstTerm +\] \[secondCoeff * secondTerm\]Any Segment between First and Last:
\[FirstCoef = \frac{(t_i - t_{i-1})}{(t_{i+1} - t_{i-1})}\] \[FirsTerm = \frac{(p_{i+1} - p_i)}{ (t_{i+1} - t_i)}\] \[SecondCoef = \frac{(t_{i+1} - t_i) }{(t_{i+1} - t_{i-1})}\] \[SecondTerm = \frac{(p_i - p_{i-1})}{(t_i - t_{i-1})}\] \[Tangent = firstCoeff * firstTerm +\] \[secondCoeff * secondTerm\]Github link: Here