[Math] Calculating point on a circle, given an offset

trigonometry

I have what seemed like a very simple issue, but I just cannot figure it out. I have the following circles around a common point:

enter image description here

The Green and Blue circles represent circles that orbit the center point. I have been able to calculate the distance/radius from the point to the individual circles, but I am unable to plot the next point on either circle, given an angle from the center point. Presently, my calculation looks like the following:

The coordinates of one of my circles is:

y1 = 152
x1 = 140.5

And my calculation for the next point, 1 degree from the starting point (140.5,152) is:

distance = SQRT((160-x1)^2 + (240-y1)^2) = 90.13
new x = 160 - (distance x COS(1 degree x (PI / 180)))
new y = 240 - (distance x SIN(1 degree x (PI / 180)))

My new x and y give me crazy results, nothing even close to my circle.

I can't figure out how to calculate the new position, given the offset of 160, 240 being my center, and what I want to rotate around. Where am I going wrong?

Update:

I have implemented what I believe to be the correct formula, but I'm only getting a half circle, e.g.

x1 = starting x coordinate, or updated coordinate
y1 = starting y coordinate, or updated y coordinate    
cx = 100 (horizontal center)
cy = 100 (vertical center)

radius = SQRT((cx - x1)^2 + (cy - y1)^2)
arc = ATAN((y1 - cy) / (x1 - cx))
newX = cx + radius * COS(arc - PI - (PI / 180.0))
newY = cy + radius * SIN(arc - PI - (PI / 180.0))

Set the values so next iteration of drawing, x1 and y1 will be the new
base for the calculation.
x1 = newX
y1 = newY

enter image description here

The circle begins to draw at the correct coordinates, but once it hits 180 degrees, it jumps back up to zero degrees. The dot represents the starting point. Also, the coordinates are going counterclockwise, when they need to go clockwise. Any ideas?

Best Answer

Update 2: Here is the graph I got for $(x_{1},y_{1})=( 78. 965,12. 354)$, for the parametric circle $(x(t),y(t))$ centered at $(100,100)$

$$x=100+90.135\cos \left( 1.3527+\pi -t\frac{\pi }{180}\right) ,$$

$$y=100+90.135\sin \left( 1.3527+\pi -t\frac{\pi }{180}\right) .$$

together with the 4 points $(x(t),y(t))$ for $t=0,90,180,270$

$$(x_{1},y_{1})=(x(0),y(0)),(x(90),y(90)),(x(180),y(180)),(x(270),y(270)).$$

enter image description here

You might use the following equations in a for loop with $k=0$ to $k=359$, step $1$:

$$x=100+90.135\cos \left( 1.3527+\pi -k\frac{\pi }{180}\right) ,$$

$$y=100+90.135\sin \left( 1.3527+\pi -k\frac{\pi }{180}\right) .$$

to draw the "orbit" with a 1 degree interval.


Update: corrected coordinates of $(x_{1},y_{1})=(140.5,152)$.

You need to consider the new angle and not only the $1{{}^\circ}$ change. The argument of $\cos$ and $\sin$ is this new angle and not $1{{}^\circ}$.

Let $(x_{c},y_{c})=(160,240)$ be the center of the set of circles and $(x_{1},y_{1})=(140.5,152)$. The radius $r$ is

$$\begin{eqnarray*} r &=&\sqrt{\left( x_{c}-x_{1}\right) ^{2}+\left( y_{c}-y_{1}\right) ^{2}} \\ &=&\sqrt{\left( 160-140.5\right) ^{2}+\left( 240-152\right) ^{2}} \\ &=&90.135 \end{eqnarray*}$$

Call $(x,y)$ the new coordinates of $(x_{1},y_{1})$ rotated by an angle of $-1{{}^\circ}=-\dfrac{\pi }{180}$ around $(x_{c},y_{c})$ with a radius $r$. The new angle is $\theta'=\theta -\frac{\pi }{180}$, $\theta $ being the initial angle. Then

$$\begin{eqnarray*} x &=&x_{c}+r\cos \left( \theta -\frac{\pi }{180}\right), \\ y &=&y_{c}+r\sin \left( \theta -\frac{\pi }{180}\right), \end{eqnarray*}$$ where $\theta $ is the angle $\theta =\arctan \dfrac{y_{1}-y_{c}}{x_{1}-x_{c}}:$

$$\begin{eqnarray*} \theta &=&\arctan \frac{152-240}{140.5-160}=1.3527+\pi \text{ rad.}\\ &=&\frac{1.3527\times 180{{}^\circ}}{\pi }+180{{}^\circ}=257. 5{{}^\circ}\end{eqnarray*}$$ Thus $$\begin{eqnarray*} x &=&160+90.135\cos \left( 1.3527+\pi -\frac{\pi }{180}\right)= 138. 96 \\y &=&240+90.135\sin \left( 1.3527+\pi -\frac{\pi }{180}\right) = 152. 35 \end{eqnarray*}$$

enter image description here

Related Question