1
$\begingroup$

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

enter image description here

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.

  • 0
    I would guess Bezier Curves. http://en.wikipedia.org/wiki/B%C3%A9zier_curve2012-08-21
  • 0
    How to set control point so the curve will have exact `D` direction in point `B`?2012-08-21
  • 0
    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.2012-08-21
  • 0
    Basically the midpoint $M$ should be $B-D$.2012-08-21

1 Answers 1

1

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$.

  • 0
    Yes, looks like what I need. Thanks. `x` should be 1, otherwise the curve 'magnets' to one of points.2012-08-21