translate linear coordinates to circular space

113 Views Asked by At

I have $5$ points ($P_0 \rightarrow P_4$) on a straight line, and $4$ control points ($C_1 \rightarrow C_4$) that I use to connect the points with quadratic bezier curves (as seen in the top part of the image below).

linear to circular drawing

What I want to do is bend this 'linear' layout into 'circular' space, as seen in the bottom part. Is there a formula I can apply to my points' $xy$ coordinates to achieve this? If so I would like to have a variable with which I can control the curvature (e.g. $0$ for straight, $0.5$ for semi-circle, $1$ for full circle.

(apologies if I'm not expressing myself well - I'm a coder - so please feel free to edit the question)

1

There are 1 best solutions below

0
On

WLOG I assume that $P_0=(-1,0)$ and $P_4=(1,0)$ (if not, a translation+rotation+scaling will achieve that).

Now consider a circle of radius $r$ passing by the two given points. By Pythagoras, its center is at $(0,-h)$ with $h:=\sqrt{r^2-1}$, and the half-aperture angle is $\alpha=\arcsin\dfrac1r$.

Using polar coordinates with the pole at $(0,-h)$, you will map the abscissas to angles ($x\to\theta=\dfrac\pi2+x\alpha$) and the ordinates to moduli ($y\to\rho=r+y$), and

$$X=(r+y)\cos(\frac\pi2+x\alpha)=(r+y)\sin(x\alpha),\\Y=(r+y)\sin(\frac\pi2+x\alpha)-h=(r+y)\cos(x\alpha)-h.$$

This way the origin $(0, 0)$ maps to the Cartesian coordinates $(0,r-h)$ and the endpoints $(\pm1,0)$ to themselves.


Note that for very large $r$, $\alpha\approx\dfrac1r$ and $h\approx r$ so that

$$X\approx(r+y)\frac xr\approx x,$$

$$Y\approx (r+y)\cdot1-h\approx y.$$