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:
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
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?