# Object orbitting 2D circle java

I'm using this code to make a square that orbits a circle . When I use it however the rect(); is quite far away from the circumference of the circle, I would like to make it closer. All variables are floats. YPos and XPos are the x and y of the circles origin.

charx = XPos[0] + cos(angle)*Sizes[0];
chary = YPos[0] + sin(angle)*Sizes[0];
angle += 0.1;
fill(255,255,255);
rect(charx, chary, 10,10);}


Any idea what I should change? This is probably something very simple, but I'm very new to Java.

• define: is quite far away from the circumference of the circle, i would like to make it closer. more exactly. – MickLH Jul 2 '16 at 19:09