I am developing a software for creating graphs and have stuck at a point.
I use cardinal splines to connect two points, say A and B. Between A and B I do not have a fixed number of points, so no fixed number of "sub-curves". The user may add or delete points thus curving or straightening the line.
From what I have understood, when a point is entered, it divides the line into two "sub-curves" and so on. So we have (n-1) "sub-curves" for n points.
What I want to do is to be able to select a random point on the line and find in which "sub-curve" it belongs. Is there an equation that can do that?
I have found the following equation:
P(t) = s(-t3 + 2t2 – t)P1 + s(-t3 + t2)P2 + (2t3 – 3t2 + 1)P2 + s(t3 – 2t2 + t)P3 + (-2t3 + 3t2)P3 + s(t3 – t2)P4
"the following vector equation applies for an arbitrary point P(t) on the curve from P2 to P3".
But shouldn't there be a variable for P(t) point?
Thank you in advance.