[Math] Formula to map any given point on circumference of circle with given radius

circlescoordinate systemsgeometry

I am working on a project where I need this.

Mathematically : I need a formula to map any given point P(x,y) on circumference of a circle of given radius r and center c in 2D space.

Insights of project: It is related to Computer User Interface and Graphic manipulation.

For instance: I have a circle with given radius on the monitor fixed at center and there is an element (X) on its circumference, Now I use Mouse Pointer co-ordinates to move X but the problem is X need to be moved only on the circumference irrespective of mouse movement, since, mouse can move anywhere on the 2D space. So i need a formula so i could map the mouse coordinates as points on circumference everytime mouse is moved. I need to calculate the point on circumference in respective of mouse coordinates.

Please refer Image for clarity on topic

Thanks

Real scenario

Best Answer

enter image description here Let C be the circle located inside the first quadrant. (The logic will be the same if the origin is located at the top left corner.) We let its equation be $F(x, y) = (x – h)^2 + (y – k)^2 - r^2 = 0$.

Initial task == Testing whether the mouse pointer (at T(p, q)) is inside or outside of the circle.

This is easily done by testing whether F(p, q) is greater than or equal to or smaller than 0. The conclusion will be outside/ on/ inside the circle accordingly.

We assume that T(p, q) is inside the circle.

The corresponding point (the one on the circumference) is then (p, m) where m will have 2 values (? and ??).

From the fact that $m – k = \pm \sqrt(r^2 – (p – h)^2)$, and with the help of the diagram, we conclude that $?? = k + \sqrt(r^2 – (p – h)^2)$.