Я пытаюсь создать круг в Java с помощью команды fillOval. Пользователь вводит центральные координаты и радиус для круга, но я не знаю, как найти высоту и ширину для команды fillOval.Bounding Box Algorithm в Java с только центральными точками и радиусом
import java.util.*;
import java.awt.*;
public class Circles {
public static final Scanner Console = new Scanner(System.in);
public static void main(String args[]) {
DrawingPanel panel = new DrawingPanel(400,300);
Graphics g = panel.getGraphics();
//print the beginning statement of the main method
System.out.println("");
//ask the user for the center and radius for the first circle
System.out.println("Enter the x-value for the center of the first circle: ");
double x1 = Console.nextDouble();
System.out.println("Enter the y-value for the center of the first circle: ");
double y1 = Console.nextDouble();
System.out.println("Enter the radius for the first circle: ");
double rad1 = Console.nextDouble();
//calculate the height and width of the first circle
//ask the user for the center and radius for the second circle
System.out.println("Enter the x-value for the center of the second circle: ");
double x2 = Console.nextDouble();
System.out.println("Enter the y-value for the center of the second circle: ");
double y2 = Console.nextDouble();
System.out.println("Enter the radius for the second circle: ");
double rad2 = Console.nextDouble();
//calculate the height and width of the second circle
//ask the user for the center and radius for the third circle
System.out.println("Enter the x-value for the center of the third circle: ");
double x3 = Console.nextDouble();
System.out.println("Enter the y-value for the center of the third circle: ");
double y3 = Console.nextDouble();
System.out.println("Enter the radius for the third circle: ");
double rad3 = Console.nextDouble();
//calculate the height and width of the third circle
//use the fillOval method to draw each circle
//fillOval(int x, int y, int width, int height)
Это все, что у меня есть до сих пор. Я просто не уверен, как получить высоту и ширину.
Ну, диаметр круга в 2 раза больше радиуса, а ширина и высота круга будут равны диаметру, верно? – Andreas
Ваше право. Я полностью посмотрел на это. Я, очевидно, пытался сделать это сложнее, чем это было на самом деле. Спасибо!! – Vessel