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.

  • $\begingroup$ Unclear: do you want to project the line (if yes which projection ?) or wrap it around, keeping the length ? $\endgroup$ – Yves Daoust Oct 15 '18 at 7:29
  • $\begingroup$ I want to keep the length, does projection have a more specific meaning? $\endgroup$ – WDUK Oct 15 '18 at 8:13
  • $\begingroup$ Yes it does. Nosrati's answer is an example. $\endgroup$ – Yves Daoust Oct 15 '18 at 8:22
  • $\begingroup$ You are saying that you have a mesh but ask about a line. What is the connection ? $\endgroup$ – Yves Daoust Oct 15 '18 at 8:22
  • $\begingroup$ @YvesDaoust i plan to do it for a 2D plane once i understood the math on a sphere but i wanted to start with a circle and a basic line mesh which is just a series of vertex positions in my application which is called the mesh. $\endgroup$ – WDUK Oct 15 '18 at 21:00

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


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.

  • $\begingroup$ I am a bit confused why you are using different trig functions to some other answers. I'm not familiar with arccot and cot $\endgroup$ – WDUK Oct 15 '18 at 21:01

The point that is $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 \sin \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.

  • $\begingroup$ Mind the typo . $\endgroup$ – Yves Daoust Oct 15 '18 at 8:21
  • $\begingroup$ @YvesDaoust Feel free to edit! $\endgroup$ – koalo Oct 15 '18 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.