How can I plot curves relative to other curves?

215 Views Asked by At

Suppose I have a curve – say a sine curve

y=sin(x)

Now I want to draw a second curve, y = ½sin(x), but relative to the first – so it has the first one as a “baseline”. I don’t mean just adding the values (even I can do that!) but as though space itself is curved relative to the first curve...

How impossible is it to come up with a formula to plot this..... ?

[edit] I suppose, what I mean is that at a point x along sin(x) - i.e. distance x measured along the curve, not the x-axis - draw the normal to the curve, and plot the point on that at distance ½sin(x).

1

There are 1 best solutions below

1
On

You can start by considering parallel curves (a.k.a. "offset curves"), which are curves traced by a normal segment to a curve of a certain length.

Here is the (parametric) formula for a parallel curve to a function $y=f(x)$:

$$\begin{align*} x&=t\pm\frac{h f^\prime(t)}{\sqrt{1+f^\prime(t)^2}}\\ y&=f(t)\mp\frac{h}{\sqrt{1+f^\prime(t)^2}} \end{align*}$$

It should be stressed that parallels are not functions, in general.

For $y=\sin(x)$, the parametric equations of a general parallel are

$$\begin{align*} x&=t\pm\frac{h \cos(t)}{\sqrt{1+\cos^2(t)}}\\ y&=\sin(t)\mp\frac{h}{\sqrt{1+\cos^2(t)}} \end{align*}$$

We then let $h=\sin(t)/2$; that is, a variable offset as opposed to a constant offset in the usual case; this yields

$$\begin{align*} x&=t\pm\frac{\sin(t)\cos(t)}{2\sqrt{1+\cos^2(t)}}\\ y&=\sin(t)\mp\frac{\sin(t)}{2\sqrt{1+\cos^2(t)}} \end{align*}$$

Here is a plot of $\color{#5e81b5}{\sin(x)}$ and its two offsets:

sin and variable offsets