Compilation Environment:
Operating system: Win8.1 64-bit
IDE platform: Visual Studio Ultimate
First, the principle
Second, the Code implementation
Angle behind the intersection. Java
Package Text;import Java.awt.*;import Java.awt.event.*;import java.math.*;import javax.swing.*;import Javax.swing.border.border;public class angle rear intersection extends jframe{ public static final int textarea_rows = 20;&nbs p; public static final int textarea_columns = 40; Public angle rear intersection () { final JTextField a_x = new JTextField ("37477") ; final JTextField a_y = new JTextField ("16307"); final JTextField b_x = new JTextField ("37327"); final JTextField b_y = new JTextField ("16078"); nbsp; final JTextField c_x = new JTextField ("37163"); final JTextField c_y = new JTextField ("16046"); final jtextfieldα_1 = new Jtex Tfield ("40°41"); final jtextfieldβ_1 = new JTextField ("75°19"); finAl jtextfieldγ_1 = new JTextField ("58°11"); final JTextField r_a = new JTextField ("200"); final JTextField r_b = new JTextField ("$"); final JTextField r_c = new JTextField ("$"); JPanel Northpanel = new JPanel (); JPanel Westpanel = new JPanel (); JLabel pic= New JLabel (); Pic.seticon (New ImageIcon ("g:/workplace/angle rear intersection/3.png")); Westpanel.add (pic); Getcontentpane (). Add (Westpanel, borderlayout.west);//Angle forward intersection northpanel.setlayout (New GridLayout (2, 6)); Northpanel.add (New JLabel ("a_x:", Swingconstants.center)); Northpanel.add (A_X); Northpanel.add (New JLabel ("A_y:", Swingconstants.center)); Northpanel.add (a_y); Northpanel.add (New JLabel ("B_x:", Swingconstants.center)); Northpanel.add (b_x); Northpanel.add (New JLabel ("B_y:", Swingconstants.center)); Northpanel.add (B_Y); Northpanel.add (New JLabel ("c_x:", Swingconstants.center)); Northpanel.add (c_x); Northpanel.add (New JLabel ("C_y:", Swingconstants.center) ); Northpanel.add (c_y); NorthPanel.add (New JLabel ("Alpha: ", Swingconstants.center)); Northpanel.add (α_1); Northpanel.add (New JLabel ("Beta:", swingconstants.center)); Northpanel.add (β_1); Northpanel.add (New JLabel ("Gamma:", Swingconstants.center)); Northpanel.add (γ_1); Northpanel.add (New JLabel ("RA:", Swingconstants.center)); Northpanel.add (r_a); Northpanel.add (New JLabel ("RB:" , Swingconstants.center)); Northpanel.add (r_b); Northpanel.add (New JLabel ("RC:", Swingconstants.center)); Northpanel.add (R_C); Border etched = Borderfactory.createetchedborder (); Border titled = Borderfactory.createtitledborder (Etched, "angle-behind intersection"); Northpanel.setborder (titled); Getcontentpane (). Add (Northpanel, BorderLayout.NORTH) ; final JTextArea textArea = new JTextArea (20,40); JScrollPane ScrollPane = new JScrollPane (TextArea); GetcontentpanE (). Add (ScrollPane, Borderlayout.center); //Add button to append text into the text area&n bsp; JPanel Southpanel = new JPanel (); JButton Insertbutton = new JButton ("Calculate p-point coordinates"); Insertbutton.addactionlistener (New ActionListener () { Public void actionperformed (ActionEvent event) { //Coordinate initialization double x1=double.valueof (A_x.gettext ()). Doublevalue (); double y1=double.valueof (A_y.gettext ()). Doublevalue (); Double x2=double.valueof (B_x.gettext ()). Doublevalue (); double y2=double.valueof (B_y.gettext ()). Doublevalue (); double x3=double.valueof (C_x.gettext ()). Doublevalue (); double y3=double.valueof (C_y.gettext ()). Doublevalue (); doubleα=convert (Α_1.gettext ()); doubleβ=convert (Β_1.gettext ()); doubleγ=convert (Γ_1.gettext ()); Double ra=double.valueof (R_a.gettext ()). Doublevalue (); double rb=double.valueof (R_b.gettext ()). Doublevalue (); double rc=double.valueof (R_c.gettext ()). Doublevalue (); //a, B, P double d_ab=math.sqrt (Math.pow (X1-X2), 2) + Math.pow ((Y1-y2), 2)); Doubleα_ab=math.atan (Math.Abs (y1-y2)/math.abs (x1-x2)); doubleα_21=math.asin (Ra*math.sin (α)/d_ab); Doubleα_11=α_AB-α_21; double Xp1=x3+rc*math.cos (α_11); double yp1=y3+rc*math.sin (α_11); //b, C, P double d_bc=math.sqrt ( Math.pow ((X3-X2), 2) +math.pow ((Y3-y2), 2); doubleα_bc=math.atan (Math.Abs (y2-y3)/math.abs (x2-x3)); doubleα_22=math.asin (Rb*math.sin (α)/D_BC); Doubleα_12=α_BC-α_22; double Xp2=x3+rc*math.cos (Α_12); double yp2=y3+rc*math.sin (Α_12); textarea.append ("===== angle" + "\ n" + "reference value 1:" + "(" +xp1+ "," +yp1 + ")" + "\ n" + "reference value 2:" + "(" +xp2+ "," +yp2+ ")" + "\ n" + "error distance approx:" +math.round (Miss (XP1,YP1,XP2,YP2)) + "M"); } public double Miss (double Xp1,double yp1,double xp2,double YP2) { &Nbsp;return math.sqrt (Math.pow (XP1-XP2), 2) +math.pow ((YP1-YP2), 2)); } public Double Convert (String input) { double a=double.valueof ( Input.split ("°") [0]). Doublevalue (); double b=double.valueof (Input.split ("°") [1].split ("'") [0]). Doublevalue (); return a+b/60; } }); Add ( Insertbutton, Borderlayout.south); pack (); }}
test.java
Package Text;import Java.awt.*;import javax.swing.*;p ublic class test{ public static void Main (string[] args ) { Eventqueue.invokelater (New Runnable () { public void run () { JFrame frame = new angle rear intersection (); Frame.settitle ("angled rear intersection"); frame.setdefaultcloseoperation (jframe.exit_on_close); frame.setvisible (True); } }); }}
Iii. Results of operation
Download: Angle intersection algorithm Java Project package
JAVA: Angle-of-intersection algorithm GUI implementation