Calculating another point on a circle from radiants

139 Views Asked by At

I have a program that tells me the angle in radians of a cursor from another item, let's say it's a star.

image

What I want is to take this $(X_2,Y_2)$ point and deviate it a bit on the left or right from the cursor angle. Creating the following $(X_3,Y_3)$ point. I know the coordinates of the center of the circle and the current cursor position.

image

How do I create an $(X_3,Y_3)$ point by adding a few radians to the original angle?

1

There are 1 best solutions below

2
On BEST ANSWER

let $r=\sqrt{(x-x_0)^2+(y-y_0)^2}$ the radius of the circle where $(x_0,y_0)$ coordinates of the center and $(x,y) $of the point belonging to that circle.

$\theta=arccos(\frac{(x-x_0)}{r})+\delta$

$cos(\theta)=\frac{X-x_0}{r}$

$$X=x_0+r\cos(arccos(\frac{(x-x_0)}{r})+\delta)$$

$Y-y_0=\sqrt{r^2-(X-x_0)^2}$

$$Y=y_0+\sqrt{r^2-(r\cos(arccos(\frac{(x-x_0)}{r})+\delta))^2}$$

Where:

-$\delta$ the angle added

-$(x_0,y_0)$ and $(x,y)$ are the coordinates of the points

-$(X,Y)$ the point resulted

Here is a simulation of it.