Hi All!
I´m writing a bezier interpolation method on c++.
The Problem is :
I can get a point position for the parameter (t), but i dont know how i can get a tangent vector for this point.
Any ideas?
How to get a tangent vector at bezier point
Can u get me a formula?
for example I have a 5 arguments
POINT start;
POINT end;
VECTOR tangentStart;
VECTOR tangentEnd;
double t;
Now I´ve a some method to get a outPoint:
POINT bezierInterpolate(POINT &start,
POINT &end,
VECTOR &tangentStart,
VECTOR &tangentEnd,
double t)
{
// bla bla ...
return pointPosition;
}
I would change this code to, for example, this
struct parameterPoint{
POINT position;
VECTOR tangent;
}
parameterPoint bezierInterpolate(POINT &start,
POINT &end,
VECTOR &tangentStart,
VECTOR &tangentEnd,
double t)
{
// bla bla ...
VECTOR tangent = WHAT I NEED TO WRITE HERE?????????
return parameterPoint;
}
Well here is a nice discussion of cubic Beziers
The coefficients a, b, and c are derived from the four points ( which you can get from your endpoints and tangents). Then just differentiate the parametric polynomial to get
p’(t) = 3at*t + 2bt + c
So, depending on how many tangent computations you need for a given Bezier curve, it may be useful to compute a hodograph. The idea of a hodograph is that you create a curve which when evaluated at the same t value as the original gives you the tangent.
Alternatively, there are some good speedups and simplifications that are possible if you’re computing at the endpoints of a curve. If you’re not computing tangents often, it may be simple to split the curve at your t value, and then compute the tangent at the end of that new curve.
The simplest method is just to compute the point position at t, and then at t + epsilon (where epsilon is small), and get a vector that way. Not particularily fast or accurate, but easy, and might give you what you need.
Details and formulas available here:
http://www.tsplines.com/resources/class_notes/Bezier_curves.pdf
Let me know if you need some pointers… I’ve implemented hodographs and the tangents at endpoints, I bet I can dig the code up somewhere.
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.