import java.io.*; class qbezier { public static void main(String[] args) { if(args.length != 6) { System.out.println("Gebrauch: java qbezier x1 y1 m1 x2 y2 m2"); return; } File outfile = new File("qbezier.tex"); try { double x1 = Double.parseDouble(args[0]); double y1 = Double.parseDouble(args[1]); double m1 = Double.parseDouble(args[2]); double x2 = Double.parseDouble(args[3]); double y2 = Double.parseDouble(args[4]); double m2 = Double.parseDouble(args[5]); if(m1 == m2) { System.out.println("Keine Auswertung möglich:"); System.out.println("m1 und m2 müssen verschieden sein"); return; } String outstring = "% qbezier P1=("+x1+"/"+y1+") m1="+m1+" P2=("+x2+"/"+y2+") m2="+m2; outstring += "\n\\qbezier"; double x = (m2*x2-m1*x1+y1-y2) / (m2-m1); double u = y1+m1*(x-x1); double v = y2+m2*(x-x2); double y = 0.5*(u+v); outstring += "(" + runde(x1) + ", " + runde(y1) + ")"; outstring += "(" + runde(x) + ", " + runde(y) + ")"; outstring += "(" + runde(x2) + ", " + runde(y2) + ")"; FileWriter out = new FileWriter(outfile.getPath(), false); out.write(outstring); out.close(); } catch(NumberFormatException e) { System.out.println("Eingabe nicht korrekt"); System.out.println("Korrekte Eingabe: x1 y1 m1 x2 y2 m2"); } catch(IOException e) { } } public static String runde(double t) { String s = ""; int T = (int)(Math.round(10000 * t)); double d = T/10000.0; s = String.valueOf(d); return s; } }