I am using a GUI that draws a tracer point in a window The m
I am using a GUI that draws a tracer point in a window. The method I wrote above draws a circle in the GUI. I need to find a way to draw another circle, with its center being the point on the circumference of the above circle. So the x and y values I get from the above method should be the center of my new circle. Everything I try seems to only modify the existing circle and I\'m so stuck! Please explain your code. :)
public static void draws piral (Display panel pane l get Width 2 int CenterX int centerY panel. get Height 2 double degAng 270; double radius 150 double x, y, radAng while true 180 radAng degAng Math PI CenterX radius Math.cos ra y center Y radius Math.sin radAng panel draw NextPoint (int) x, int y i degAng 0.45;Solution
public static void drawSpiral(Display panel) {
int centerX = panel.getWidth() / 2;
int centerY = panel.getHeight() / 2;
double degAng = 0;
double radius = 150;
double x, y, radAng;
while (degAng < 360) {
radAng = (degAng * Math.PI) / 180;
x = centerX + radius * Math.cos( radAng );
y = centerY + radius * Math.sin( radAng );
panel.drawNextPoint( (int) x, (int) y);
degAng += 0.45;
}
centerX = x;
centerY = y;
double degAng = 0;
double radius = 150;
double x, y, radAng;
while (degAng < 360) {
radAng = (degAng * Math.PI) / 180;
x = centerX + radius * Math.cos( radAng );
y = centerY + radius * Math.sin( radAng );
panel.drawNextPoint( (int) x, (int) y);
degAng += 0.45;
}
}
