List of usage examples for java.lang Math PI
double PI
To view the source code for java.lang Math PI.
Click Source Link
From source file:Main.java
public static void main(String[] args) { // get a variable x which is equal to PI/2 double x = Math.PI / 2; // get a variable y which is equal to PI/3 double y = Math.PI / 3; // convert x and y to degrees x = Math.toDegrees(x);/*w ww . ja v a 2 s. c o m*/ y = Math.toDegrees(y); // get the polar coordinates System.out.println("Math.atan2(" + x + "," + y + ")=" + Math.atan2(x, y)); }
From source file:MainClass.java
public static void main(String args[]) { double radians = 0.45 * Math.PI / 180; System.out.println("cos = " + Math.cos(radians)); }
From source file:MainClass.java
public static void main(String args[]) { double radians = 0.45 * Math.PI / 180; System.out.println("sin = " + Math.sin(radians)); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { System.out.printf("num is %.2f\n", Math.PI); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { System.out.printf("num is %f\n", Math.PI); }
From source file:CircleAreaApp.java
public static void main(String[] args) { System.out.print("Enter the radius of your circle: "); double r = sc.nextDouble(); double area = Math.PI * (r * r); System.out.println("The area is " + area); }
From source file:Main.java
public static void main(String[] args) throws Exception { Hashtable h = new Hashtable(); h.put("string", "AAA"); h.put("int", new Integer(26)); h.put("double", new Double(Math.PI)); FileOutputStream fileOut = new FileOutputStream("hashtable.ser"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(h);//from w w w. j av a2 s. c o m FileInputStream fileIn = new FileInputStream("h.ser"); ObjectInputStream in = new ObjectInputStream(fileIn); Hashtable h = (Hashtable) in.readObject(); System.out.println(h.toString()); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();/*from www. j a va 2s . c o m*/ Image jpg1 = Image.getInstance("dog.jpg"); jpg1.scalePercent(80); jpg1.setRotation((float) Math.PI / 6); document.add(new Paragraph("rotate 30 degrees")); document.add(jpg1); document.add(new Paragraph("Original width: " + jpg1.width() + "; original height: " + jpg1.height())); document.close(); }
From source file:ImageRotatingPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w . j a v a 2 s .c om PdfWriter.getInstance(document, new FileOutputStream("ImageRotatingPDF.pdf")); document.open(); Image jpg = Image.getInstance("logo.png"); jpg.setAlignment(Image.MIDDLE); jpg.setRotation((float) Math.PI / 6); document.add(new Paragraph("rotate 30 degrees")); document.add(jpg); document.newPage(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { BufferedImage original = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); BufferedImage rotated1 = create(original, -Math.PI / 2, gc); BufferedImage rotated2 = create(original, +Math.PI / 4, gc); BufferedImage rotated3 = create(original, Math.PI, gc); JPanel cp = new JPanel(); cp.add(new JLabel(new ImageIcon(original))); cp.add(new JLabel(new ImageIcon(rotated1))); cp.add(new JLabel(new ImageIcon(rotated2))); cp.add(new JLabel(new ImageIcon(rotated3))); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(cp);// www .j av a 2 s .com f.pack(); f.setVisible(true); }