Smooth transition between two lines (2d)

Solution 1:

OK, Ross offered you a function that is smooth but not infinitely smooth. I will offer you an infinitely smooth solution - which is moreover more explicit. Let me give you an infinitely smooth interpolation. Define (or recall) $$ \tanh (a) = \frac{e^a - e^{-a}}{e^a+e^{-a}} $$ This function goes to $\pm 1$ for $a\to\pm\infty$ but is infinitely smooth.

A smooth version of your function may be written as $$y = \frac{x}{15} + \frac{1+\tanh [K(x-30)]}{2} \left( \frac{x}{70}-\frac{x}{15} + \frac{11}{7} \right) $$ Here, $K\in R^+$ may be chosen arbitrarily. The larger $K$ you choose, the more closely my function will resemble your unsmooth function. The smaller $K$ you will choose, the "smoother" will be my function. But in the technical sense, the function above is infinitely smooth and infinitely differentiable.

Why does it work? For $x<30$ or $x\ll 30$, the factor $(1+\tanh)/2$ goes to zero, so $y$ reduces to the first term, $x/15$, as needed. On the other hand, for $x>30$ or more precisely $x\gg 30$, the factor $(1+\tanh)/2$ goes to $1$, so the parenthesis with the three terms is multiplied by one; $x/15$ gets canceled and you're left with $x/70-11/7$.

Instead of $\tanh a$, you could also use $(2 \arctan (a) / \pi)^3 $ or any other smooth function interpolating between $-1$ and $+1$. I chose the third power here to be sure that it converges to $\pm 1$ quickly enough and the linear factors don't spoil it. For this reason, $\tanh$ is safer.

You might use the method even for more than two pieces. First, merge two of them by the method, and treat is as a function that you may smoothly merge with another function, and so on.

Solution 2:

The old draftsman's approach would be to plot the two lines, then take out a circle template and make it tangent to both of them. You can do that analytically. If you pick a radius of circle you want to use, say $r$, then plot two lines $r$ away from the two you have, the center will be at the intersection. So one line becomes $y=\frac{x}{15}-\frac{r}{\sqrt{1+m^2}}$ with $m=\frac{1}{15}$, and the other becomes $y=\frac{x}{70}+\frac{11}{7}-\frac{r}{\sqrt{1+m^2}}$ with $m=\frac{1}{70}$. You can then find the intersection of these, call it $(x_0,y_0)$ and that is the center. Then the circle is $y=\sqrt{r^2-(x-x_0)^2}+y_0$. The points of tangency are the breakpoints for where to use the circle.

To see the $\LaTeX$, you can right click on any item, pick Show Source, and see it. Just put it between dollar signs to get it to display.