Project line onto a circle

2.4k Views Asked by At

Say i have a straight line, how would you project it on to a circle as an arc length where by the centre normal of the line is fixed to (0,1)*r on the circle?

Basically what i am trying to do in my code is i have a mesh and i want to warp it around a circle, but i don't know the math for it.

Here is an image to visually show it:

enter image description here

I drew it with a mouse so its not great.

How do you figure out the position on the circumference, based from the local distance from the green marker for some circle with known origin and radius.

3

There are 3 best solutions below

0
On BEST ANSWER

The point of abscissa $s$ on the line wraps to a point at curvilinear abscissa $s$ from the top point, which is also at an angle $s$ clockwise from that point.

In polar coordinates

$$\theta=\frac\pi2-s,\\\rho=1$$ and in Cartesian

$$x=\sin s,\\y=\cos s.$$

2
On

The distance $g$ to the right on the line corresponds to $g$ on the circumference in clockwise direction. Since the whole circumference is $2\pi r$, it is a ratio of $\frac{g}{2\pi r}$ that directly corresponds to the angle in radians $\varphi = \frac{g}{r}$.

Finally you need a polar transformation

$x=r\sin\varphi = r \sin \frac{g}{r}$

$y=r\cos\varphi = r \cos \frac{g}{r}$

Note that, in contrast the the usual definition of a polar transformation, the $\varphi=0$ is at the top and we use clockwise radians, so we switch $sin$ and $cos$.

For the left part of the line you do not have to change anything. A negative value of $g$ will result in a negative $\varphi$, but since $cos$ and $sin$ are periodic, this corresponds to a point on the circumference in the counterclockwise direction.

1
On

Let $y=1$ be your line and $x^2+y^2=1$ be the circle. Any point $(x,1)$ project to the point $(\cos\operatorname{arccot} x, \sin\operatorname{arccot} x)$ on the circle. Also any point $(\cos t, \sin t)$ on the circle project to the point $(\cot t,1)$ on line.