예제 #1
0
  /**
   * Get the lightning ratio ([0-1]).
   *
   * @param position the satellite's position in the selected frame.
   * @param frame in which is defined the position
   * @param date the date
   * @return lightning ratio
   * @exception OrekitException if the trajectory is inside the Earth
   */
  public double getLightningRatio(
      final Vector3D position, final Frame frame, final AbsoluteDate date) throws OrekitException {

    // Compute useful angles
    final double[] angle = getEclipseAngles(position, frame, date);

    // Sat-Sun / Sat-CentralBody angle
    final double sunEarthAngle = angle[0];

    // Central Body apparent radius
    final double alphaCentral = angle[1];

    // Sun apparent radius
    final double alphaSun = angle[2];

    double result = 1.0;

    // Is the satellite in complete umbra ?
    if (sunEarthAngle - alphaCentral + alphaSun <= 0.0) {
      result = 0.0;
    } else if (sunEarthAngle - alphaCentral - alphaSun < 0.0) {
      // Compute a lightning ratio in penumbra
      final double sEA2 = sunEarthAngle * sunEarthAngle;
      final double oo2sEA = 1.0 / (2. * sunEarthAngle);
      final double aS2 = alphaSun * alphaSun;
      final double aE2 = alphaCentral * alphaCentral;
      final double aE2maS2 = aE2 - aS2;

      final double alpha1 = (sEA2 - aE2maS2) * oo2sEA;
      final double alpha2 = (sEA2 + aE2maS2) * oo2sEA;

      // Protection against numerical inaccuracy at boundaries
      final double a1oaS = FastMath.min(1.0, FastMath.max(-1.0, alpha1 / alphaSun));
      final double aS2ma12 = FastMath.max(0.0, aS2 - alpha1 * alpha1);
      final double a2oaE = FastMath.min(1.0, FastMath.max(-1.0, alpha2 / alphaCentral));
      final double aE2ma22 = FastMath.max(0.0, aE2 - alpha2 * alpha2);

      final double P1 = aS2 * FastMath.acos(a1oaS) - alpha1 * FastMath.sqrt(aS2ma12);
      final double P2 = aE2 * FastMath.acos(a2oaE) - alpha2 * FastMath.sqrt(aE2ma22);

      result = 1. - (P1 + P2) / (FastMath.PI * aS2);
    }

    return result;
  }
예제 #2
0
  public double execute(double in) throws DMLRuntimeException {
    switch (bFunc) {
      case SIN:
        return FASTMATH ? FastMath.sin(in) : Math.sin(in);
      case COS:
        return FASTMATH ? FastMath.cos(in) : Math.cos(in);
      case TAN:
        return FASTMATH ? FastMath.tan(in) : Math.tan(in);
      case ASIN:
        return FASTMATH ? FastMath.asin(in) : Math.asin(in);
      case ACOS:
        return FASTMATH ? FastMath.acos(in) : Math.acos(in);
      case ATAN:
        return Math.atan(in); // faster in Math
      case CEIL:
        return FASTMATH ? FastMath.ceil(in) : Math.ceil(in);
      case FLOOR:
        return FASTMATH ? FastMath.floor(in) : Math.floor(in);
      case LOG:
        return FASTMATH ? FastMath.log(in) : Math.log(in);
      case LOG_NZ:
        return (in == 0) ? 0 : FASTMATH ? FastMath.log(in) : Math.log(in);
      case ABS:
        return Math.abs(in); // no need for FastMath	
      case SIGN:
        return FASTMATH ? FastMath.signum(in) : Math.signum(in);
      case SQRT:
        return Math.sqrt(in); // faster in Math
      case EXP:
        return FASTMATH ? FastMath.exp(in) : Math.exp(in);
      case ROUND:
        return Math.round(in); // no need for FastMath

      case PLOGP:
        if (in == 0.0) return 0.0;
        else if (in < 0) return Double.NaN;
        else return (in * (FASTMATH ? FastMath.log(in) : Math.log(in)));

      case SPROP:
        // sample proportion: P*(1-P)
        return in * (1 - in);

      case SIGMOID:
        // sigmoid: 1/(1+exp(-x))
        return FASTMATH ? 1 / (1 + FastMath.exp(-in)) : 1 / (1 + Math.exp(-in));

      case SELP:
        // select positive: x*(x>0)
        return (in > 0) ? in : 0;

      default:
        throw new DMLRuntimeException("Builtin.execute(): Unknown operation: " + bFunc);
    }
  }
예제 #3
0
  @Override
  public double getPartialSimilarity(double[] a, double[] b) {
    final double lp = toHilbertPSpace(a, b);

    // Per corner case condition
    if (lp >= getSigma()) return 0.0;

    final double twoOverPi = (2d / FastMath.PI);
    final double lpOverSig = lp / getSigma();

    /* Front segment */
    final double front = twoOverPi * FastMath.acos(-lpOverSig);

    /* Back segment */
    final double first = twoOverPi * lpOverSig;
    final double second = FastMath.sqrt(1.0 - FastMath.pow(lpOverSig, 2));
    final double back = first * second;
    final double answer = front - back;

    return Double.isNaN(answer) ? Double.NEGATIVE_INFINITY : answer;
  }