Approximating the unit tangent vectors of discrete data!

249 Views Asked by At

I do have a set of discrete data of n points $(P_{1}, P_{2}, …., P_{n})$ in 3d space, each point $P_{i}$ has 3 components for (x, y, z). I’m trying to fit a sequence of cubic Bezier curves to these data using an algorithm provided by [Andrew S. Glassner. Graphics Gems I. Academic Press Inc., 1990 ].

To do that I need to be able to calculate the tangent vector at each point $P_{i}$, including the two endpoints $P_{1}$ and $P_{n}$. What I’m currently doing is approximating the tangent vector in $P_{1}$ by a vector going form $P_{1}$ to $P_{2}$ as $(P_{2}-P_{1})$, and in $P_{n}$ by a vector going from $P_{n}$ to $P_{n-1}$ as $(P_{n-1}-P_{n})$, and in any intermediate point $P_{i}$ by a vector from $P_{i-1}$ to $P_{i+1}$ as $(P_{i+1} - P_{i-1})$ . This solution works as desired for most of the cases, but when the data points are too far away from each other, my approximation of the tangent vectors in the two endpoints $P_{1}$ and $P_{n}$ becomes very rough, and the error of fitted curves is therefore very big.

So I thought I'll post this here to see if somebody could have an idea for how to get better approximation of tangent vectors. Appreciate any help or suggestions.