Example usage for java.lang Double min

List of usage examples for java.lang Double min

Introduction

In this page you can find the example usage for java.lang Double min.

Prototype

public static double min(double a, double b) 

Source Link

Document

Returns the smaller of two double values as if by calling Math#min(double,double) Math.min .

Usage

From source file:carfuzzy.Operations.java

public double trapezoidalMembership(int input, double[] boundries) {
    double a, b, c, d;
    a = boundries[0];/*from  w w w . j  ava  2s  . c o m*/
    b = boundries[1];
    c = boundries[2];
    d = boundries[3];
    return Double.max(Double.min(Double.min((input - a) / (b - a), 1), (d - input) / (d - c)), 0);
}

From source file:carfuzzy.Operations.java

public double triangularMembership(double x, double[] boundries) {
    double a = boundries[0], b = boundries[1], c = boundries[2];
    if (x >= a && x <= c) { // acceptable range {
        double res;
        res = Double.max(Double.min(((x - a) / (b - a)), ((c - x) / (c - b))), 0);
        return res;
    } else {/*  w  w w.j  a  v  a  2 s  .co  m*/
        return 0;
    }
}

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

/**
 * Get the density probability from angle
 * @param angle must be in radians from in [0,2pi]
 * @return pdf function/*ww w.  j  a  v  a 2 s .  c  om*/
 */
public double getDensityProbability(double angle) {

    double density = 0;

    double tmp = Math.PI / 2.0;
    if (angle == tmp) {
        angle = tmp - 0.000001;
    }

    //angle = Math.PI/2.0 - angle; ??inversion des coefficients

    switch (type) {

    //warning : in wang paper there is an inversion between planophile, and erectophile
    case PLANOPHILE:
        density = (2.0 / Math.PI) * (1 + Math.cos(2 * angle));
        break;
    case ERECTOPHILE:
        density = (2.0 / Math.PI) * (1 - Math.cos(2 * angle));
        break;
    case PLAGIOPHILE:
        density = (2.0 / Math.PI) * (1 - Math.cos(4 * angle));
        break;
    case EXTREMOPHILE:
        density = (2.0 / Math.PI) * (1 + Math.cos(4 * angle));
        break;
    case SPHERIC:
        density = Math.sin(angle);
        break;
    case UNIFORM:
        density = 2.0 / Math.PI;
        break;
    case HORIZONTAL:
        break;
    case VERTICAL:
        break;
    case ELLIPTICAL:
        break;
    case ELLIPSOIDAL:

        double res;

        if (x == 1) {
            res = Math.sin(angle);
        } else {

            double eps, lambda = 0;

            if (x < 1) {
                eps = Math.sqrt(1 - (x * x));
                lambda = x + (Math.asin(eps) / eps);
            }
            if (x > 1) {
                eps = Math.sqrt(1 - Math.pow(x, -2));
                lambda = x + Math.log((1 + eps) / (1 + eps)) / (2 * eps * x);
            }

            res = (2 * Math.pow(x, 3) * Math.sin(angle)) / (lambda
                    * Math.pow((Math.pow(Math.cos(angle), 2)) + (x * x * Math.pow(Math.sin(angle), 2)), 2));
        }

        return res;

    case TWO_PARAMETER_BETA:

        //angle = Math.PI/2.0 - angle;
        double te = 2 * angle / Math.PI;
        te = Double.max(te, 1E-09);
        te = Double.min(te, 1 - 1E-09);

        density = distribution.density(te) / (Math.PI / 2.0);

        break;
    }

    return density;
}

From source file:carfuzzy.Operations.java

public double getImplication(double membership1, double membership2) {
    return Double.min(membership1, membership2);
}