//LinesIntersectionPoint.java // enter a line and a point. find perpendicular bisector from point thru line. import java.awt.*; import javax.swing.*; import java.text.*; import java.util.*; public class LinesIntersectionPoint extends JApplet { //public static void main (String[] args) { public void init () { double A, B, C, A2, B2, C2, x1, y1, m, b, m2, b2, xI, yI, d; String input; StringTokenizer st; DecimalFormat d4 = new DecimalFormat ("0.0000"); input = JOptionPane.showInputDialog("Enter coefficients A,B,C of line in standard form: Ax+By=C"); st = new StringTokenizer(input); A = Double.parseDouble(st.nextToken()); B = Double.parseDouble(st.nextToken()); C = Double.parseDouble(st.nextToken()); input = JOptionPane.showInputDialog("Enter coordinates of point (x,y)"); st = new StringTokenizer(input); x1 = Double.parseDouble(st.nextToken()); y1 = Double.parseDouble(st.nextToken()); m = -A/B; b = C/B; if (A != 0) A2 = B/A; else A2 = 1000000000.0; B2 = -1; C2 = B/A*x1-y1; m2 = -A2/B2; b2 = C2/B2; xI = (b2-b)/(m-m2); yI = m*xI+b; d = Math.sqrt((xI-x1)*(xI-x1) + (yI-y1)*(yI-y1)); JOptionPane.showMessageDialog(null, "Given line: A="+d4.format(A)+" B="+d4.format(B)+" C="+d4.format(C)+ " m="+d4.format(m)+" b="+d4.format(b)+"\n"+ "Given point: ("+d4.format(x1)+","+d4.format(y1)+")"+"\n"+ "Perpendicular line: A="+d4.format(A2)+" B="+d4.format(B2)+" C="+d4.format(C2)+ " m="+d4.format(m2)+" b="+d4.format(b2)+"\n"+ "Intersection point: ("+d4.format(xI)+","+d4.format(yI)+")"+"\n"+ "distance between points="+d4.format(d)); } }