Example usage for org.apache.commons.math3.analysis.solvers BracketingNthOrderBrentSolver BracketingNthOrderBrentSolver

List of usage examples for org.apache.commons.math3.analysis.solvers BracketingNthOrderBrentSolver BracketingNthOrderBrentSolver

Introduction

In this page you can find the example usage for org.apache.commons.math3.analysis.solvers BracketingNthOrderBrentSolver BracketingNthOrderBrentSolver.

Prototype

public BracketingNthOrderBrentSolver(final double relativeAccuracy, final double absoluteAccuracy,
        final double functionValueAccuracy, final int maximalOrder) throws NumberIsTooSmallException 

Source Link

Document

Construct a solver.

Usage

From source file:org.orekit.frames.TopocentricFrame.java

/**
 * Compute the limit visibility point for a satellite in a given direction.
 * <p>/*from ww w  . jav a2s .  c  om*/
 * This method can be used to compute visibility circles around ground stations
 * for example, using a simple loop on azimuth, with either a fixed elevation
 * or an elevation that depends on azimuth to take ground masks into account.
 * </p>
 * @param radius satellite distance to Earth center
 * @param azimuth pointing azimuth from station
 * @param elevation pointing elevation from station
 * @return limit visibility point for the satellite
 * @throws OrekitException if point cannot be found
 */
public GeodeticPoint computeLimitVisibilityPoint(final double radius, final double azimuth,
        final double elevation) throws OrekitException {
    try {
        // convergence threshold on point position: 1mm
        final double deltaP = 0.001;
        final UnivariateSolver solver = new BracketingNthOrderBrentSolver(
                deltaP / Constants.WGS84_EARTH_EQUATORIAL_RADIUS, deltaP, deltaP, 5);

        // find the distance such that a point in the specified direction and at the solved-for
        // distance is exactly at the specified radius
        final double distance = solver.solve(1000, new UnivariateFunction() {
            /** {@inheritDoc} */
            public double value(final double x) {
                try {
                    final GeodeticPoint gp = pointAtDistance(azimuth, elevation, x);
                    return parentShape.transform(gp).getNorm() - radius;
                } catch (OrekitException oe) {
                    throw new OrekitExceptionWrapper(oe);
                }
            }
        }, 0, 2 * radius);

        // return the limit point
        return pointAtDistance(azimuth, elevation, distance);

    } catch (TooManyEvaluationsException tmee) {
        throw new OrekitException(tmee);
    } catch (OrekitExceptionWrapper lwe) {
        throw lwe.getException();
    }
}