Example usage for java.lang Math tan

List of usage examples for java.lang Math tan

Introduction

In this page you can find the example usage for java.lang Math tan.

Prototype

@HotSpotIntrinsicCandidate
public static double tan(double a) 

Source Link

Document

Returns the trigonometric tangent of an angle.

Usage

From source file:org.renjin.primitives.MathGroup.java

@Deferrable
@Builtin//from  w w w.j a  v  a2  s. c o  m
@DataParallel(value = PreserveAttributeStyle.ALL, passNA = true)
public static double tan(double x) {
    return Math.tan(x);
}

From source file:abfab3d.io.output.STSWriter.java

/**
 * Writes a grid out to an svx file// w w  w  . j  av  a 2  s  . co  m
 * @param grid
 * @param os
 */
public void write(AttributeGrid grid, MaterialMaker[] makers, String[] finish, ZipOutputStream os) {
    try {

        ZipEntry zentry = new ZipEntry("manifest.xml");
        os.putNextEntry(zentry);
        writeManifest(grid, makers, finish, os);
        os.closeEntry();

        double maxDecimationError = errorFactor * grid.getVoxelSize() * grid.getVoxelSize();

        int len = makers.length;

        for (int i = 0; i < len; i++) {
            ZipEntry ze = new ZipEntry("part" + i + "." + format);
            ((ZipOutputStream) os).putNextEntry(ze);

            MeshMakerMT meshmaker = new MeshMakerMT();
            meshmaker.setBlockSize(30);
            meshmaker.setThreadCount(threadCount);
            meshmaker.setSmoothingWidth(smoothingWidth);
            meshmaker.setMaxDecimationError(maxDecimationError);
            meshmaker.setMaxDecimationCount(10);
            meshmaker.setMaxAttributeValue(255);
            meshmaker.setDensityMaker(makers[i].getDensityMaker());

            IndexedTriangleSetBuilder its = new IndexedTriangleSetBuilder(160000);
            meshmaker.makeMesh(grid, its);

            System.out.println("Vertices: " + its.getVertexCount() + " faces: " + its.getFaceCount());

            WingedEdgeTriangleMesh mesh = new WingedEdgeTriangleMesh(its.getVertices(), its.getFaces());

            if (minPartVolume > 0 || maxPartsCount < Integer.MAX_VALUE) {
                ShellResults sr = GridSaver.getLargestShells(mesh, maxPartsCount, minPartVolume);
                mesh = sr.getLargestShell();
                int regions_removed = sr.getShellsRemoved();
                System.out.println("Regions removed: " + regions_removed);
            }

            if (format.equals("x3d") || format.equals("x3dv") || format.equals("x3db")) {

                double[] bounds_min = new double[3];
                double[] bounds_max = new double[3];

                grid.getGridBounds(bounds_min, bounds_max);
                double max_axis = Math.max(bounds_max[0] - bounds_min[0], bounds_max[1] - bounds_min[1]);
                max_axis = Math.max(max_axis, bounds_max[2] - bounds_min[2]);

                double z = 2 * max_axis / Math.tan(Math.PI / 4);
                float[] pos = new float[] { 0, 0, (float) z };

                BinaryContentHandler x3dWriter = createX3DWriter(os);

                HashMap<String, Object> x3dParams = new HashMap<String, Object>();
                GridSaver.writeMesh(mesh, 10, x3dWriter, x3dParams, true);
                x3dWriter.endDocument();
            } else if (format.equals("stl")) {
                STLWriter stl = new STLWriter(os, mesh.getTriangleCount());
                mesh.getTriangles(stl);
            }

            ((ZipOutputStream) os).closeEntry();
        }
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}

From source file:utils.RandomVariable.java

/**
 * Generate a random number from a Cauchy random variable (Mean = Inf, and
 * Variance = Inf)./*from  ww w . j  a  v a2  s .  c om*/
 *
 * @param mu median of the Weibull random variable
 * @param sigma second parameter of the Cauchy random variable.
 * @return a double.
 */
public static double cauchy(double mu, double sigma) {
    double x = sigma * Math.tan(Math.PI * (rand() - 0.5)) + mu;
    return x;
}

From source file:org.cirdles.geoapp.LatLongToUTM.java

private static BigDecimal calcConformalLatitude(BigDecimal eccentricity, BigDecimal latitudeRadians) {

    BigDecimal conformalLatitude;

    double latRadDouble = latitudeRadians.doubleValue();
    double eccDouble = eccentricity.doubleValue();
    double confLatDouble;

    Atanh atanh = new Atanh();
    Asinh asinh = new Asinh();

    confLatDouble = Math.atan(Math.sinh(
            asinh.value(Math.tan(latRadDouble)) - eccDouble * atanh.value(eccDouble * Math.sin(latRadDouble))));

    conformalLatitude = new BigDecimal(confLatDouble);

    return conformalLatitude;

}

From source file:org.lightjason.agentspeak.action.builtin.TestCActionMath.java

/**
 * data provider generator for single-value tests
 * @return data/*from   w  w  w  . ja va2  s  .  c  o  m*/
 */
@DataProvider
public static Object[] singlevaluegenerate() {
    return Stream.concat(

            singlevaluetestcase(

                    Stream.of(2.5, 9.1, 111.7, 889.9),

                    Stream.of(CNextPrime.class),

                    (i) -> (double) Primes.nextPrime(i.intValue())),

            singlevaluetestcase(

                    Stream.of(-2, -6, 4, -1, -5, 3, 49, 30, 6, 5, 1.3, 2.8, 9.7, 1, 8, 180, Math.PI),

                    Stream.of(CAbs.class, CACos.class, CASin.class, CATan.class, CCeil.class, CCos.class,
                            CCosh.class, CDegrees.class, CExp.class, CIsPrime.class, CLog.class, CLog10.class,
                            CFloor.class, CRadians.class, CRound.class, CSignum.class, CSin.class, CSinh.class,
                            CSqrt.class, CTan.class, CTanh.class),

                    (i) -> Math.abs(i.doubleValue()), (i) -> Math.acos(i.doubleValue()),
                    (i) -> Math.asin(i.doubleValue()), (i) -> Math.atan(i.doubleValue()),
                    (i) -> Math.ceil(i.doubleValue()), (i) -> Math.cos(i.doubleValue()),
                    (i) -> Math.cosh(i.doubleValue()), (i) -> Math.toDegrees(i.doubleValue()),
                    (i) -> Math.exp(i.doubleValue()), (i) -> Primes.isPrime(i.intValue()),
                    (i) -> Math.log(i.doubleValue()), (i) -> Math.log10(i.doubleValue()),
                    (i) -> Math.floor(i.doubleValue()), (i) -> Math.toRadians(i.doubleValue()),
                    (i) -> Math.round(i.doubleValue()), (i) -> Math.signum(i.doubleValue()),
                    (i) -> Math.sin(i.doubleValue()), (i) -> Math.sinh(i.doubleValue()),
                    (i) -> Math.sqrt(i.doubleValue()), (i) -> Math.tan(i.doubleValue()),
                    (i) -> Math.tanh(i.doubleValue()))

    ).toArray();
}

From source file:de.thkwalter.et.schlupfbezifferung.Schlupfresiduum.java

/**
 * Diese Methode berechnet die x-Komponenten der Schnittpunkte der Schlupfgeraden mit den Strahlen vom Inversionszentrum 
 * zu den Betriebspunkten.//from w ww. j ava  2s .  c om
 * 
 * @param phi Der Steigungswinkel der Schlupfgeraden
 * 
 * @return Die x-Komponenten der Schnittpunkte der Schlupfgeraden mit den Strahlen vom Inversionszentrum zu den 
 * Betriebspunkten.
 */
private double[] xKomponentenSchnittpunktBerechnen(double phi) {
    // Das Feld fr die x-Komponenten der Schnittpunkte der Schlupfgeraden mit den Strahlen vom Inversionszentrum zu den 
    // Betriebspunkten wird deklariert.
    double[] xKomponentenSchnittpunkt = new double[3];

    // Die x-Komponente des Drehpunkts der Schlupfgeraden wird gelesen.
    double xDrehpunktSchlupfgerade = this.drehpunktSchlupfgerade.getX();

    // Falls der Steigungswinkel der Schlupfgeraden nahe bei pi liegt, wird die Steigung der Schlupfgeraden unendlich 
    // gro.
    if (Math.abs((phi - Math.PI) / Math.PI) < 1E-6) {
        // Die x-Komponente der Schnittpunkte ist mit der x-Komponente des Drehpunkts identisch.
        xKomponentenSchnittpunkt[0] = xDrehpunktSchlupfgerade;
        xKomponentenSchnittpunkt[1] = xDrehpunktSchlupfgerade;
        xKomponentenSchnittpunkt[2] = xDrehpunktSchlupfgerade;
    }

    // Falls der Steigungswinkel endlich ist, ...
    else {
        // Eine Hilfsgre wird berechnet.
        double hilf = this.drehpunktSchlupfgerade.getY() - Math.tan(phi) * xDrehpunktSchlupfgerade
                - this.inversionszentrum.getY();

        // In der folgenden Schleife werden die Schnittpunkte der Schlupfgeraden mit den Strahlen vom Inversionszentrum zu 
        // den Betriebspunkten berechnet.
        for (int i = 0; i < this.steigungen.length; i++) {
            xKomponentenSchnittpunkt[i] = (hilf + this.steigungen[i] * this.inversionszentrum.getX())
                    / (this.steigungen[i] - Math.tan(phi));
        }
    }

    // Die x-Komponenten der Schnittpunkte der Schlupfgeraden mit den Strahlen vom Inversionszentrum zu den 
    // Betriebspunkten wird zurckgegeben.
    return xKomponentenSchnittpunkt;
}

From source file:dk.dma.msinm.web.OsmStaticMap.java

private double latToTile(double lat, int zoom) {
    return (1.0 - Math.log(Math.tan(lat * Math.PI / 180.0) + 1.0 / Math.cos(lat * Math.PI / 180.0)) / Math.PI)
            / 2.0 * Math.pow(2.0, zoom);
}

From source file:org.cirdles.ambapo.LatLongToUTM.java

/**
 * Eccentricity helps define the shape of the ellipsoidal representation of
 * the earth/*from   w  w w  .j  a v a  2s. co  m*/
 * 
 * Conformal latitude gives an angle-preserving (conformal) transformation 
 * to the sphere
 * 
 * It defines a transformation from the ellipsoid to a sphere 
 * of arbitrary radius such that the angle of intersection between any two 
 * lines on the ellipsoid is the same as the corresponding angle on the sphere.
 * 
 * @param eccentricity
 * @param latitudeRadians
 * @return BigDecimal conformal latitude
 * 
         
 */
private static BigDecimal calcConformalLatitude(BigDecimal eccentricity, BigDecimal latitudeRadians) {

    BigDecimal conformalLatitude;

    double latRadDouble = latitudeRadians.doubleValue();
    double eccDouble = eccentricity.doubleValue();
    double confLatDouble;

    Atanh atanh = new Atanh();
    Asinh asinh = new Asinh();

    confLatDouble = Math.atan(Math.sinh(
            asinh.value(Math.tan(latRadDouble)) - eccDouble * atanh.value(eccDouble * Math.sin(latRadDouble))));

    conformalLatitude = new BigDecimal(confLatDouble);

    return conformalLatitude;

}

From source file:android.support.transition.ArcMotion.java

private static float toTangent(float arcInDegrees) {
    if (arcInDegrees < 0 || arcInDegrees > 90) {
        throw new IllegalArgumentException("Arc must be between 0 and 90 degrees");
    }/* w  w w. j  ava 2 s.co m*/
    return (float) Math.tan(Math.toRadians(arcInDegrees / 2));
}

From source file:fr.amap.lidar.amapvox.commons.GTheta.java

/**
 * <p>Get the transmittance from the specified angle (radians or degrees) and the specified Leaf Angle Distribution.</p>
 * 0 is vertical, 90 is horizontal (zenithal angle, measured from vertical).
 * @param theta Angle//w  w  w  .j a v  a  2 s  . co  m
 * @param degrees true if the given angle is in degrees, false otherwise
 * @return directional transmittance (GTheta)
 */
public double getGThetaFromAngle(double theta, boolean degrees) {

    if (degrees) {
        if (theta > 90) { //get an angle between 0 and 90
            theta = 180 - theta;
        }
    } else {
        if (theta > (Math.PI / 2.0)) { //get an angle between 0 and pi/2
            theta = Math.PI - theta;
        }
    }

    if (transmittanceFunctions != null && !isBuildingTable) { //a table was built

        int indice = 0;
        if (degrees) {
            indice = (int) (theta / res);
        } else {
            indice = (int) (Math.toDegrees(theta) / res);
        }

        if (indice >= transmittanceFunctions.length) {
            indice = transmittanceFunctions.length - 1;
        } else if (indice < 0) {
            indice = 0;
        }

        return transmittanceFunctions[indice];

    } else { //no table was built, get transmittance on the fly

        if (pdfArray == null) {
            setupDensityProbabilityArray(DEFAULT_STEP_NUMBER);
        }
        if (distribution.getType() == SPHERIC) {

            return 0.5; //the result for spherical distribution is always 0.5, saving processing time

        } else {

            if (degrees) {
                theta = Math.toRadians(theta);
            }

            if (theta == 0) {
                theta = Double.MIN_VALUE;
            }

            if (theta >= Math.PI / 2.0) {
                theta = (Math.PI / 2.0) - 0.00001;
            }

            UnivariateFunction function1 = new CustomFunction1(theta);
            UnivariateFunction function2 = new CustomFunction2(theta);

            TrapezoidIntegrator integrator = new TrapezoidIntegrator();

            double sum = 0;
            for (int j = 0; j < nbIntervals; j++) {

                double thetaL = (serie_angulaire[j] + serie_angulaire[j + 1]) / 2.0d;
                double Fi = (pdfArray[j]) / SOM;

                double cotcot = Math.abs(1 / (Math.tan(theta) * Math.tan(thetaL)));

                double Hi;

                if (cotcot > 1 || Double.isInfinite(cotcot)) {
                    Hi = integrator.integrate(10000, function1, serie_angulaire[j], serie_angulaire[j + 1]);
                } else {
                    Hi = integrator.integrate(10000, function2, serie_angulaire[j], serie_angulaire[j + 1]);
                    //System.out.println("nb evaluations: " + integrator.getEvaluations());
                }

                double Gi = Fi * Hi / ((Math.PI / 2) / (double) serie_angulaire.length); //because we need the average value not the actual integral value!!!!
                sum += Gi;
            }

            return sum;
        }
    }

}