List of usage examples for java.lang Math tan
@HotSpotIntrinsicCandidate public static double tan(double a)
From source file:gbt.ubt.tool.Orthorectifier.java
public static double vincentyFormulae(double lat1, double long1, double lat2, double long2) { double latitude1 = deg2rad(lat1); double longitude1 = deg2rad(long1); double latitude2 = deg2rad(lat2); double longitude2 = deg2rad(long2); double a = 6378137.0; double f = 1.0 / 298.257223563; double b = (1.0 - f) * a; double u1 = Math.atan((1.0 - f) * Math.tan(latitude1)); double u2 = Math.atan((1.0 - f) * Math.tan(latitude2)); double L = longitude2 - longitude1; double lambda = L; double diff = 1.0; double tol = 10.0e-8; double cos2Alpha = 0.0; double sinOmega = 0.0; double cos2OmegaM = 0.0; double cosOmega = 0.0; double omega = 0.0; while (diff > tol) { sinOmega = Math.sqrt(Math.pow((Math.cos(u2) * Math.sin(lambda)), 2) + (Math .pow(((Math.cos(u1) * Math.sin(u2)) - (Math.sin(u1) * Math.cos(u2) * Math.cos(lambda))), 2))); cosOmega = (Math.sin(u1) * Math.sin(u2)) + (Math.cos(u1) * Math.cos(u2) * Math.cos(lambda)); omega = Math.atan(sinOmega / cosOmega); double sinAlpha = (Math.cos(u1) * Math.cos(u2) * Math.sin(lambda)) / Math.sin(omega); cos2Alpha = 1 - (Math.pow(sinAlpha, 2)); cos2OmegaM = cosOmega - ((2 * Math.sin(u1) * Math.sin(u2)) / cos2Alpha); double C = (f / 16.0) * cos2Alpha * (4 + (f * (4 - (3 * cos2Alpha)))); double lambdaNew = L + ((1 - C) * f * sinAlpha * (omega + (C * sinOmega * (cos2OmegaM + (C * cosOmega * (-1 + (2 * Math.pow(cos2OmegaM, 2)))))))); diff = Math.abs(lambdaNew - lambda); lambda = lambdaNew;/*from w ww. j a v a 2s .c o m*/ } double uSquared = cos2Alpha * ((Math.pow(a, 2) - Math.pow(b, 2)) / Math.pow(b, 2)); double A = 1 + ((uSquared / 16384.0) * (4096.0 + (uSquared * (-768.0 + (uSquared * (320.0 - (175.0 * uSquared))))))); double B = (uSquared / 1024.0) * (256.0 + (uSquared * (-128.0 + (uSquared * (74.0 - (47.0 * uSquared)))))); double deltaOmega = B * sinOmega * (cos2OmegaM + (0.25 * B * ((cosOmega * (-1 + (2 * Math.pow(cos2OmegaM, 2)))) - ((1.0 / 6.0) * B * cos2OmegaM * (-3.0 + (4.0 * Math.pow(sinOmega, 2))) * (-3.0 + (4.0 * Math.pow(cos2OmegaM, 2))))))); double s = b * A * (omega - deltaOmega); return s; }
From source file:org.esa.nest.gpf.oceantools.WindFieldEstimationOp.java
/** * Compute normalized radar cross section for given pixel. * * @param sourceTile The source tile. * @param bandUnit The source band unit. * @param x The X coordinate for the given pixel. * @param y The Y coordinate for the given pixel. * @param normalizeSigma if mission.contains("ENVISAT") && pol.contains("hh") * @param theta The incidence angle in degree. * @return The normalized radar cross section. *///ww w . j a va 2 s .co m private static double getNormalizedRadarCrossSection(final Tile sourceTile, final Unit.UnitType bandUnit, final int x, final int y, final boolean normalizeSigma, final double theta) { double sigma = sourceTile.getDataBuffer().getElemDoubleAt(sourceTile.getDataBufferIndex(x, y)); if (bandUnit == Unit.UnitType.INTENSITY_DB) { sigma = Math.pow(10.0, sigma / 10); } if (normalizeSigma) { final double alpha = 1.0; // in range [0.4, 1.0] final double tanTheta = Math.tan(theta * org.esa.beam.util.math.MathUtils.DTOR); sigma *= Math.pow((1 + 2.0 * tanTheta * tanTheta) / (1 + alpha * tanTheta * tanTheta), 2.0); } return sigma; }
From source file:msi.gaml.operators.Maths.java
@operator(value = "tan_rad", can_be_const = true, category = { IOperatorCategory.ARITHMETIC }) @doc(value = "Returns the value (in [-1,1]) of the trigonometric tangent of the operand (in decimal degrees). The argument is casted to an int before being evaluated.", masterDoc = true, usages = { @usage(value = "Operand values out of the range [0-359] are normalized. Notice that tan(360) does not return 0.0 but -2.4492935982947064E-16"), @usage(value = "The tangent is only defined for any real number except 90 + k `*` 180 (k an positive or negative integer). Nevertheless notice that tan(90) returns 1.633123935319537E16 (whereas we could except infinity).") }, see = { "cos", "sin" }) public static Double tan_rad(final Double v) { return Math.tan(v); }
From source file:abfab3d.io.output.GridSaver.java
/** retuns good viewpoint for given box//from ww w. j a v a2s .co m */ public static double getViewDistance(Grid grid) { double bounds[] = new double[6]; grid.getGridBounds(bounds); double sizex = bounds[1] - bounds[0]; double sizey = bounds[3] - bounds[2]; double sizez = bounds[5] - bounds[4]; double max = sizex; if (sizey > max) max = sizey; if (sizez > max) max = sizez; double z = 2 * max / Math.tan(Math.PI / 4); return z; }
From source file:net.team2xh.crt.language.compiler.Compiler.java
@Override public Object visitCall(CallContext ctx) { Object left = ctx.expression().accept(this); List<Object> arguments = visitExpressionList(ctx.expressionList()); if (left.getClass() != Identifier.class) throw new CompilerException(ctx, code, "'" + left + "' muts be an identifier"); Identifier name = (Identifier) left; double[] args; switch (name.getName()) { case RGB://from w w w.j av a 2s .c o m args = checkArguments(arguments, RGB, 3, ctx); return new Pigment(args[0], args[1], args[2]); case RGBA: args = checkArguments(arguments, RGBA, 4, ctx); return new Pigment(args[0], args[1], args[2], args[3]); case VEC3: args = checkArguments(arguments, VEC3, 3, ctx); return new Vector3(args[0], args[1], args[2]); case SIN: args = checkArguments(arguments, SIN, 1, ctx); return Math.sin(args[0]); case COS: args = checkArguments(arguments, COS, 1, ctx); return Math.cos(args[0]); case TAN: args = checkArguments(arguments, TAN, 1, ctx); return Math.tan(args[0]); case RAND: args = checkArguments(arguments, RAND, 2, ctx); Double r = rand.nextDouble() * Math.abs(args[0] - args[1]) + Math.min(args[0], args[1]); return r; default: // TODO: macro call return null; } }
From source file:org.eclipse.birt.chart.device.g2d.G2dRendererBase.java
@Override public void fillRectangle(RectangleRenderEvent rre) throws ChartException { if (iv != null) { iv.modifyEvent(rre);//from w ww .j a va2 s. c o m } final Fill flBackground = validateMultipleFill(rre.getBackground()); if (isFullTransparent(flBackground)) { return; } final Bounds bo = normalizeBounds(rre.getBounds()); final Rectangle2D.Double r2d = new Rectangle2D.Double(bo.getLeft(), bo.getTop(), bo.getWidth(), bo.getHeight()); if (flBackground instanceof ColorDefinition) { final ColorDefinition cd = (ColorDefinition) flBackground; _g2d.setColor((Color) _ids.getColor(cd)); _g2d.fill(r2d); } else if (flBackground instanceof Gradient) { final Gradient g = (Gradient) flBackground; final ColorDefinition cdStart = g.getStartColor(); final ColorDefinition cdEnd = g.getEndColor(); // boolean bCyclic = g.isCyclic(); double dAngleInDegrees = g.getDirection(); final double dAngleInRadians = ((-dAngleInDegrees * Math.PI) / 180.0); // int iAlpha = g.getTransparency(); if (dAngleInDegrees < -90 || dAngleInDegrees > 90) { throw new ChartException(ChartDeviceExtensionPlugin.ID, ChartException.RENDERING, "SwingRendererImpl.exception.gradient.angle", //$NON-NLS-1$ new Object[] { new Double(dAngleInDegrees) }, Messages.getResourceBundle(getULocale())); } Point2D.Double p2dStart, p2dEnd; if (dAngleInDegrees == 90) { p2dStart = new Point2D.Double(bo.getLeft(), bo.getTop() + bo.getHeight()); p2dEnd = new Point2D.Double(bo.getLeft(), bo.getTop()); } else if (dAngleInDegrees == -90) { p2dEnd = new Point2D.Double(bo.getLeft(), bo.getTop() + bo.getHeight()); p2dStart = new Point2D.Double(bo.getLeft(), bo.getTop()); } else if (dAngleInDegrees > 0) { p2dStart = new Point2D.Double(bo.getLeft(), bo.getTop() + bo.getHeight()); p2dEnd = new Point2D.Double(bo.getLeft() + bo.getWidth(), bo.getTop() + bo.getHeight() - bo.getWidth() * Math.abs(Math.tan(dAngleInRadians))); } else if (dAngleInDegrees < 0) { p2dStart = new Point2D.Double(bo.getLeft(), bo.getTop()); p2dEnd = new Point2D.Double(bo.getLeft() + bo.getWidth(), bo.getTop() + bo.getWidth() * Math.abs(Math.tan(dAngleInRadians))); } else { p2dStart = new Point2D.Double(bo.getLeft(), bo.getTop()); p2dEnd = new Point2D.Double(bo.getLeft() + bo.getWidth(), bo.getTop()); } _g2d.setPaint(new GradientPaint(p2dStart, (Color) _ids.getColor(cdStart), p2dEnd, (Color) _ids.getColor(cdEnd))); _g2d.fill(r2d); } else if (flBackground instanceof org.eclipse.birt.chart.model.attribute.Image) { if (flBackground instanceof PatternImage) { fillWithPatternImage(new Area(r2d), flBackground); return; } java.awt.Image img = createImageFromModel(flBackground); if (img != null) { final Shape shClip = _g2d.getClip(); Area ar2 = new Area(r2d); if (shClip != null) { Area ar1 = new Area(shClip); ar2.intersect(ar1); } _g2d.setClip(ar2); img = scaleImage(img); final Size szImage = _ids.getSize(img); int iXRepeat = (int) (Math.ceil(r2d.width / szImage.getWidth())); int iYRepeat = (int) (Math.ceil(r2d.height / szImage.getHeight())); ImageObserver io = (ImageObserver) _ids.getObserver(); for (int i = 0; i < iXRepeat; i++) { for (int j = 0; j < iYRepeat; j++) { _g2d.drawImage(img, (int) (r2d.x + i * szImage.getWidth()), (int) (r2d.y + j * szImage.getHeight()), io); } } _g2d.setClip(shClip); // RESTORE } } }
From source file:Matrix.java
public static float[] matrixPerspective(float fovy, float aspect, float znear, float zfar) { // this code is adapted from Mesa :) float xmax, ymax; ymax = znear * (float) Math.tan(Math.toRadians(fovy / 2f)); xmax = aspect * ymax;// w ww . j av a2 s.c om return matrixFrustum(-xmax, xmax, -ymax, ymax, znear, zfar); }
From source file:org.moeaframework.util.tree.NodeTest.java
@Test public void testTan() { Node node = new Tan().setArgument(0, new Constant(Math.PI / 4.0)); Assert.assertTrue(/*from w w w .j a va 2 s . c om*/ NumberArithmetic.equals(Math.tan(Math.PI / 4.0), (Number) node.evaluate(new Environment()))); }
From source file:msi.gaml.operators.Maths.java
@operator(value = "tan", can_be_const = true, category = { IOperatorCategory.ARITHMETIC }) @doc(value = "Returns the value (in [-1,1]) of the trigonometric tangent of the operand (in decimal degrees). The argument is casted to an int before being evaluated.", masterDoc = true, usages = { @usage(value = "Operand values out of the range [0-359] are normalized. Notice that tan(360) does not return 0.0 but -2.4492935982947064E-16"), @usage(value = "The tangent is only defined for any real number except 90 + k `*` 180 (k an positive or negative integer). Nevertheless notice that tan(90) returns 1.633123935319537E16 (whereas we could except infinity).") }, see = { "cos", "sin" }) public static Double tan(final Double v) { double rad = toRad * v; return Math.tan(rad); }
From source file:msi.gaml.operators.Maths.java
@operator(value = "tan", can_be_const = true, category = { IOperatorCategory.ARITHMETIC }) @doc(value = "Returns the value (in [-1,1]) of the trigonometric tangent of the operand (in decimal degrees). The argument is casted to an int before being evaluated.", examples = { @example(value = "tan (0)", equals = "0.0"), @example(value = "tan(90)", equals = "1.633123935319537E16") }) public static Double tan(final Integer v) { double rad = toRad * v; return Math.tan(rad); }