Question

PLEASE USE JAVA Write a program that draws the circumscribed circle (also known as the circumcircle)...

Write a program that draws the circumscribed circle (also known as the circumcircle) of a given triangle ABC; this circle passes through points A, B, and C. These points will be specified by the user by clicking the mouse button. Remember, the three perpendicular bisectors of the three edges of a triangle all pass through one point, the circumcenter, which is the center of the circumscribed circle.

``````PLEASE UPVOTE

import java.awt.*;
import static java.awt.Color.BLACK;
import static java.awt.Color.BLUE;
import static java.awt.Color.RED;
import java.awt.geom.*;
import static java.lang.Math.sqrt;
import javax.swing.JComponent;

{

private double [] coordinatesX;
private double [] coordinatesY;

public graficadorTriangulo (double [] valoresX, double [] valoresY )
{

}

public void paintComponent (Graphics g)

{

super.paintComponent(g);

Graphics2D g2 = (Graphics2D) g;

Line2D.Double ladoaLin = new Line2D.Double(click1Pun, click2Pun);
Line2D.Double ladobLin = new Line2D.Double(click1Pun, click3Pun);
Line2D.Double ladocLin = new Line2D.Double(click2Pun, click3Pun);

double perimetroTriangulo = magnitudA + magnitudB + magnitudC;

Point2D.Double incentroPunto = new Point2D.Double(incentroX,incentroY);

double magnitudD = Math.sqrt( ( (incentroX - coordenadasX[3] ) * ( incentroX- coordenadasX[3] ) ) + ( ( incentroY - coordenadasY[3] ) * ( incentroY - coordenadasY[3] ) ) );

Line2D.Double centroaLin = new Line2D.Double(incentroPunto, click1Pun);
Line2D.Double centrobLin = new Line2D.Double(incentroPunto, click2Pun);
Line2D.Double centrocLin = new Line2D.Double(incentroPunto, click3Pun);

double magnitudBase = sqrt(magPerpendicularX*magPerpendicularX + magPerpendicularY*magPerpendicularY);
magPerpendicularX /= magnitudBase;
magPerpendicularY /= magnitudBase ;

double lambda = (magPerpendicularX * (incentroX - coordenadasX[0])) + (magPerpendicularY * (incentroY - coordenadasY[0]));
double x4 = (magPerpendicularX * lambda) + coordenadasX[0];
double y4 = (magPerpendicularY * lambda) + coordenadasY[0];

Point2D.Double pointPerpendicular=  new Point2D.Double(x4,y4);

Line2D.Double ladoH = new Line2D.Double(incentroPunto, pointPerpendicular);

double magnitudRadioincentro= Math.sqrt( ( (x4 - incentroX ) * ( x4- incentroX ) ) + ( ( y4 - incentroY ) * ( y4 - incentroY ) ) );

int x = (int)incentroX;
int y = (int)incentroY;

int x2 = (int)incentroX;
int y2 = (int)incentroY;

x = x-(magnitudDiametroincentro/2);
y = y-(magnitudDiametroincentro/2);

Math.sqrt((magnitudA+magnitudB+magnitudC)*
((magnitudB+magnitudC)-magnitudA)*
((magnitudC+magnitudA)-magnitudB)*
((magnitudA+magnitudB)-magnitudC));

x2 = x2-(magnitudDiametrocircuncentro/2);
y2 = y2-(magnitudDiametrocircuncentro/2);
g.setColor(Color.GREEN);
g.drawOval(x,y,magnitudDiametroincentro,magnitudDiametroincentro);
g.setColor(Color.GREEN);
g.drawOval(x2,y2,magnitudDiametrocircuncentro,magnitudDiametrocircuncentro);

if(angle < 0){
angle += 360;

}
System.out.println("***********" + angle);
g.setColor(Color.BLACK);

g.setColor(Color.BLUE);
g2.draw(centroaLin);
g2.draw(centrobLin);
g2.draw(centrocLin);

g.setColor(Color.RED);

}

}

ADDITIONAL CODE TO FIND THE CIRCUMCENTER
A=((u-t)*z^2+(-u^2+t^2-q^2+p^2)*z+t*u^2+(-t^2+s^2-p^2)*u+(q^2-s^2)*t)/((q-p)*z+(p-s)*u+(s-q)*t)

B=-((q-p)*z^2+(p-s)*u^2+(s-q)*t^2+(q-p)*s^2+(p^2-  q^2)*s+p*q^2-p^2*q)/((q-p)*z+(p-s)*u+(s-q)*t)

C=-((p*u-q*t)*z^2+(-p*u^2+q*t^2-p*q^2+p^2*q)*z+s*t*u^2+(-s*t^2+p*s^2-p^2*s)*u+(q^2*s-q*s^2)*t)/((q-p)*z+(p-s)*u+(s-q)*t)``````