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:Licht.java
/** * Erstellt den Szenegraphen/*from w w w . j ava2s .c om*/ * * @return BranchGroup */ public BranchGroup macheSzene() { BranchGroup objWurzel = new BranchGroup(); // Transformation, 2 Rotationen: Transform3D drehung = new Transform3D(); Transform3D drehung2 = new Transform3D(); drehung.rotX(Math.PI / 4.0d); drehung2.rotY(Math.PI / 5.0d); drehung.mul(drehung2); TransformGroup objDreh = new TransformGroup(drehung); Sphere kugel = new Sphere(0.5f, Sphere.GENERATE_NORMALS, 50, makeAppearance()); objWurzel.addChild(kugel); objWurzel.addChild(objDreh); //directes Licht DirectionalLight d_Licht = new DirectionalLight(); d_Licht.setInfluencingBounds(new BoundingSphere(new Point3d(0.0d, 0.0d, 0.0d), Double.MAX_VALUE)); d_Licht.setColor(new Color3f(1.0f, 0.0f, 0.0f)); Vector3f dir = new Vector3f(1.0f, 2.0f, -1.0f); dir.normalize(); d_Licht.setDirection(dir); objWurzel.addChild(d_Licht); // ambient Licht AmbientLight a_licht = new AmbientLight(); a_licht.setInfluencingBounds(new BoundingSphere(new Point3d(0.0f, 0.0f, 0.0f), Double.MAX_VALUE)); a_licht.setColor(new Color3f(1.0f, 0.0f, 0.0f)); objWurzel.addChild(a_licht); return objWurzel; }
From source file:D20140128.ApacheXMLGraphicsTest.EPSExample1.java
/** * Creates an EPS file. The contents are painted using a Graphics2D * implementation that generates an EPS file. * * @param outputFile the target file//from w ww .jav a 2 s . com * @throws IOException In case of an I/O error */ public static void generateEPSusingJava2D(File outputFile) throws IOException { OutputStream out = new java.io.FileOutputStream(outputFile); out = new java.io.BufferedOutputStream(out); try { //Instantiate the EPSDocumentGraphics2D instance EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false); g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); //Set up the document size g2d.setupDocument(out, 400, 200); //400pt x 200pt //Paint a bounding box g2d.drawRect(0, 0, 400, 200); //A few rectangles rotated and with different color Graphics2D copy = (Graphics2D) g2d.create(); int c = 12; for (int i = 0; i < c; i++) { float f = ((i + 1) / (float) c); Color col = new Color(0.0f, 1 - f, 0.0f); copy.setColor(col); copy.fillRect(70, 90, 50, 50); copy.rotate(-2 * Math.PI / (double) c, 70, 90); } copy.dispose(); //Some text g2d.rotate(-0.25); g2d.setColor(Color.RED); g2d.setFont(new Font("sans-serif", Font.PLAIN, 36)); g2d.drawString("Hello world!", 140, 140); g2d.setColor(Color.RED.darker()); g2d.setFont(new Font("serif", Font.PLAIN, 36)); g2d.drawString("Hello world!", 140, 180); //Cleanup g2d.finish(); } finally { IOUtils.closeQuietly(out); } }
From source file:Float11.java
static public double asin(double x) { if (x < -1. || x > 1.) return Double.NaN; if (x == -1.) return -Math.PI / 2; if (x == 1)/* w w w. j av a 2s.c om*/ return Math.PI / 2; return atan(x / Math.sqrt(1 - x * x)); }
From source file:RotateImage45Degrees.java
public RotateImage45Degrees(String imageFile) { addNotify();// w w w . j av a2s .c o m frameInsets = getInsets(); inputImage = Toolkit.getDefaultToolkit().getImage(imageFile); MediaTracker mt = new MediaTracker(this); mt.addImage(inputImage, 0); try { mt.waitForID(0); } catch (InterruptedException ie) { } sourceBI = new BufferedImage(inputImage.getWidth(null), inputImage.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D g = (Graphics2D) sourceBI.getGraphics(); g.drawImage(inputImage, 0, 0, null); AffineTransform at = new AffineTransform(); // scale image at.scale(2.0, 2.0); // rotate 45 degrees around image center at.rotate(45.0 * Math.PI / 180.0, sourceBI.getWidth() / 2.0, sourceBI.getHeight() / 2.0); /* * translate to make sure the rotation doesn't cut off any image data */ AffineTransform translationTransform; translationTransform = findTranslation(at, sourceBI); at.preConcatenate(translationTransform); // instantiate and apply affine transformation filter BufferedImageOp bio; bio = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); destinationBI = bio.filter(sourceBI, null); int frameInsetsHorizontal = frameInsets.right + frameInsets.left; int frameInsetsVertical = frameInsets.top + frameInsets.bottom; setSize(destinationBI.getWidth() + frameInsetsHorizontal, destinationBI.getHeight() + frameInsetsVertical); show(); }
From source file:TextureMapping.java
/** * Erstellt den Szenegraphen/*from w w w . j ava2s .c o m*/ * * @return BranchGroup */ public BranchGroup macheSzene() { BranchGroup objWurzel = new BranchGroup(); // Transformation, 2 Rotationen: Transform3D drehung = new Transform3D(); Transform3D drehung2 = new Transform3D(); drehung.rotX(Math.PI / 4.0d); drehung2.rotY(Math.PI / 5.0d); drehung.mul(drehung2); TransformGroup objDreh = new TransformGroup(drehung); objDreh.addChild(new Box(0.5f, 0.5f, 0.5f, Box.GENERATE_TEXTURE_COORDS, makeAppearance())); objWurzel.addChild(objDreh); return objWurzel; }
From source file:Main.java
private static float transformAngle(Matrix m, float angleRadians) { // Construct and transform a vector oriented at the specified clockwise // angle from vertical. Coordinate system: down is increasing Y, right is // increasing X. float[] v = new float[2]; v[0] = (float) Math.sin(angleRadians); v[1] = (float) -Math.cos(angleRadians); m.mapVectors(v);// w w w .jav a2 s .c o m // Derive the transformed vector's clockwise angle from vertical. float result = (float) Math.atan2(v[0], -v[1]); if (result < -Math.PI / 2) { result += Math.PI; } else if (result > Math.PI / 2) { result -= Math.PI; } return result; }
From source file:MathUtil.java
/** Arcus sin */ static public double asin(double x) { if (x < -1. || x > 1.) { return Double.NaN; }/*from www .jav a 2s .co m*/ if (x == -1.) { return -Math.PI / 2; } if (x == 1) { return Math.PI / 2; } return atan(x / Math.sqrt(1 - x * x)); }
From source file:fsm.series.Series_SS.java
@Override public double getSecondDerivativeValue(double y, int m) { return -Math.sin(m * Math.PI * y / a) * (m * Math.PI / a) * (m * Math.PI / a); }
From source file:com.cloudmade.api.Utils.java
/** * Convert tile coordinates pair to latitude, longitude * // w w w. ja v a2s .co m * @param xtile * @param ytile * @param zoom * @return Latitude, longitude pair */ public static final double[] tilenums2latlon(int xtile, int ytile, int zoom) { double factor = 1 << zoom; double latitude = Math.atan(Math.sinh(Math.PI * (1 - 2 * ytile / factor))); double longitude = (xtile * 360.0 / factor) - 180.0; return new double[] { Math.toDegrees(latitude), longitude }; }
From source file:com.google.location.lbs.gnss.gps.pseudorange.EcefToTopocentricConverter.java
/** * Transformation of {@code inputVectorMeters} with origin at {@code originECEFMeters} into * topocentric coordinate system. The result is {@code TopocentricAEDValues} containing azimuth * from north +ve clockwise, radians; elevation angle, radians; distance, vector length meters * * <p>Source: http://www.navipedia.net/index.php/Transformations_between_ECEF_and_ENU_coordinates * http://kom.aau.dk/~borre/life-l99/topocent.m * *///from ww w . jav a2s . com public static TopocentricAEDValues convertCartesianToTopocentericRadMeters(final double[] originECEFMeters, final double[] inputVectorMeters) { GeodeticLlaValues latLngAlt = Ecef2LlaConverter.convertECEFToLLACloseForm(originECEFMeters[0], originECEFMeters[1], originECEFMeters[2]); RealMatrix rotationMatrix = Ecef2EnuConverter .getRotationMatrix(latLngAlt.latitudeRadians, latLngAlt.longitudeRadians).transpose(); double[] eastNorthUpVectorMeters = GpsMathOperations .matrixByColVectMultiplication(rotationMatrix.transpose().getData(), inputVectorMeters); double eastMeters = eastNorthUpVectorMeters[EAST_IDX]; double northMeters = eastNorthUpVectorMeters[NORTH_IDX]; double upMeters = eastNorthUpVectorMeters[UP_IDX]; // calculate azimuth, elevation and height from the ENU values double horizontalDistanceMeters = Math.hypot(eastMeters, northMeters); double azimuthRadians; double elevationRadians; if (horizontalDistanceMeters < MIN_DISTANCE_MAGNITUDE_METERS) { elevationRadians = Math.PI / 2.0; azimuthRadians = 0; } else { elevationRadians = Math.atan2(upMeters, horizontalDistanceMeters); azimuthRadians = Math.atan2(eastMeters, northMeters); } if (azimuthRadians < 0) { azimuthRadians += 2 * Math.PI; } double distanceMeters = Math.sqrt(Math.pow(inputVectorMeters[0], 2) + Math.pow(inputVectorMeters[1], 2) + Math.pow(inputVectorMeters[2], 2)); return new TopocentricAEDValues(elevationRadians, azimuthRadians, distanceMeters); }