Java tutorial
//package com.java2s; public class Main { public static double[] findClosePointsForDrawingArc(int x1, int x2, int y1, int y2) { double[] xy = new double[2]; double d = 5; double angle = 0; // if ((x1 - x2) != 0) { // tan a = y2-y1/x2-x1 // System.out.println(" x1 = " + x1 + " y1 = " + y1 + " | x2 = " + x2 + " | y2 = " + y2); // angle = Math.toDegrees(Math.atan2(Math.abs(y1 - y2), Math.abs(x1 - x2))); // xy[0] = (Math.cos(angle) * d) + x2; // xy[1] = (Math.sin(angle) * d) + y2; // System.out.println("xt " + xy[0] + " yt " + xy[1] + " angel would be : " + angle + " and Different number : " + d); angle = Math.toDegrees(Math.atan2(Math.abs(y1 - y2), Math.abs(x1 - x2))); System.out.println("----------------------------------vvvvv----------------------------------------"); System.out.println(" "); System.out.println("x1 " + x1 + " y1 " + y1 + " | x2 " + x2 + " y2 " + y2); System.out.println("Math.abs(x1-x2)" + Math.abs(x1 - x2) + " | Math.abs(y1-y2) " + Math.abs(y1 - y2) + " | angel would be Math.toDegrees(Math.atan2(Math.abs(y1 - y2), Math.abs(x1 - x2))) : " + angle + " | Different number : " + d); if (x1 > x2) { if (y1 > y2) { System.out.println( "x1>x2 && y1>y2 | x2= " + x2 + " | cos(angle) = " + Math.cos(angle) + " | d = " + d); xy[0] = x2 + (Math.abs(Math.cos(angle)) * d); System.out.println( "x1>x2 && y1>y2 | x2= " + x2 + " | sin(angle) = " + Math.sin(angle) + " | d = " + d); xy[1] = y2 + (Math.abs(Math.sin(angle)) * d); } else if (y1 < y2) { System.out.println( "x1>x2 && y1< y2 | x2= " + x2 + " | cos(angle) = " + Math.cos(angle) + " | d = " + d); xy[0] = x2 + (Math.abs(Math.cos(angle)) * d); System.out.println( "x1>x2 && y1< y2 | x2= " + x2 + " | sin(angle) = " + Math.sin(angle) + " | d = " + d); xy[1] = y2 - (Math.abs(Math.sin(angle)) * d); } else { System.out.println( "x1>x2 && y1 = y2 | x2= " + x2 + " | cos(angle) = " + Math.cos(angle) + " | d = " + d); xy[0] = x2 + (Math.abs(Math.cos(angle)) * d); System.out.println( "x1>x2 && y1 = y2 | x2= " + x2 + " | sin(angle) = " + Math.sin(angle) + " | d = " + d); xy[1] = y2; } } else if (x1 < x2) { if (y1 > y2) { System.out.println( "x1<x2 && y1>y2 | x2= " + x2 + " | cos(angle) = " + Math.cos(angle) + " | d = " + d); xy[0] = x2 - (Math.abs(Math.cos(angle)) * d); System.out.println( "x1<x2 && y1>y2 | x2= " + x2 + " | sin(angle) = " + Math.sin(angle) + " | d = " + d); xy[1] = y2 + (Math.abs(Math.sin(angle)) * d); } else if (y1 < y2) { System.out.println( "x1<x2 && y1< y2 | x2= " + x2 + " | cos(angle) = " + Math.cos(angle) + " | d = " + d); xy[0] = x2 - (Math.abs(Math.cos(angle)) * d); System.out.println( "x1<x2 && y1< y2 | x2= " + x2 + " | sin(angle) = " + Math.sin(angle) + " | d = " + d); xy[1] = y2 - (Math.abs(Math.sin(angle)) * d); } else { System.out.println( "x1<x2 && y1 =y2 | x2= " + x2 + " | cos(angle) = " + Math.cos(angle) + " | d = " + d); xy[0] = x2 - (Math.abs(Math.cos(angle)) * d); System.out.println( "x1<x2 && y1 =y2 | x2= " + x2 + " | sin(angle) = " + Math.sin(angle) + " | d = " + d); xy[1] = y2; } } else { if (y1 > y2) { System.out.println( "x1=x2 && y1>y2 | x2= " + x2 + " | cos(angle) = " + Math.cos(angle) + " | d = " + d); xy[0] = x2; System.out.println( "x1=x2 && y1>y2 | x2= " + x2 + " | sin(angle) = " + Math.sin(angle) + " | d = " + d); xy[1] = y2 + (Math.abs(Math.sin(angle) * d)); } else if (y1 < y2) { System.out.println( "x1=x2 && y1< y2 | x2= " + x2 + " | cos(angle) = " + Math.cos(angle) + " | d = " + d); xy[0] = x2; System.out.println( "x1=x2 && y1< y2 | x2= " + x2 + " | sin(angle) = " + Math.sin(angle) + " | d = " + d); xy[1] = y2 - (Math.abs(Math.sin(angle)) * d); } else { System.out.println( "x1=x2 && y1 =y2 | x2= " + x2 + " | cos(angle) = " + Math.cos(angle) + " | d = " + d); xy[0] = x2; System.out.println( "x1=x2 && y1 =y2 | x2= " + x2 + " | sin(angle) = " + Math.sin(angle) + " | d = " + d); xy[1] = y2; } } System.out.println(" X1 = " + x1 + " | X2 = " + x2 + " | Y1 = " + y1 + " | Y2 = " + y2 + " | X target = " + xy[0] + " | Y target = " + xy[1]); System.out.println(" "); System.out.println("--------------------------------^^^^----------------------------------------"); // } else { // if (y2 > y1) { // System.out.println("(x1 - x2) == 0 | X1 = " + x1 + " | X2 = " + x2 + " | Y1 = " + y1 + " | Y2 = " + y2 + " | X target = " + x1 + " | Y target = " + (y2 + ((y2 - y1) / 12))); // xy[0] = (x2); // xy[1] = y2 + ((y2 - y1) / 12); // } else { // System.out.println("(x1 - x2) == 0 | X1 = " + x1 + " | X2 = " + x2 + " | Y1 = " + y1 + " | Y2 = " + y2 + " | X target = " + x1 + " | Y target = " + (y2 - ((y2 - y1) / 12))); // xy[0] = (x2); // xy[1] = y2 - ((y2 - y1 )/ 12); // } // } return xy; } }