# Function to represent curve between two 2D points

I need a (simplest) function that interpolates values in range from predefined point $A$ to $B$ with rules:

• it must be smooth curve
• direction near $B$ must be the same as predefined $D$ vector

I have a variant to build circle arc but is too complex. Maybe some sort of splines, but I don't know how to represent it with my $A$, $B$ points and $D$ vector.

-
I would guess Bezier Curves. en.wikipedia.org/wiki/B%C3%A9zier_curve – axblount Aug 21 '12 at 14:38
How to set control point so the curve will have exact D direction in point B? – brigadir Aug 21 '12 at 14:44
You will have the place the middle point $M$ along the line through $B$ in direction $D$. You can place $M$ anywhere along that line. Roughly speaking, placing $M$ closer to the mid point between $A$ and $B$ (still along the $B$-$D$ line) will give you a smoother curve. – axblount Aug 21 '12 at 14:47
Basically the midpoint $M$ should be $B-D$. – axblount Aug 21 '12 at 14:54

Given a starting point $A$, ending point $B$ and final direction $D$, you can define a quadratic Bezier curve. Let $M=B-D$, $M$ being the middle point used to define the curve. The curve $f$ is given by
$$f(t)=(1-t)[(1-t)A+tM]+t[(1-t)M+tB],\ 0\leq t\leq 1$$
You can adjust the smoothness of the curve by changing the placement of $M$. You can do this by choosing a scaling factor $x>0$ and setting $M=B-xD$.
Yes, looks like what I need. Thanks. x should be 1, otherwise the curve 'magnets' to one of points. – brigadir Aug 21 '12 at 15:30