Search in sources :

Example 26 with GeodeticPoint

use of org.orekit.bodies.GeodeticPoint in project Orekit by CS-SI.

the class Geoid method getIntersectionPoint.

/**
 * {@inheritDoc}
 *
 * <p> The intersection point is computed using a line search along the
 * specified line. This is accurate when the geoid is slowly varying.
 */
@Override
public GeodeticPoint getIntersectionPoint(final Line lineInFrame, final Vector3D closeInFrame, final Frame frame, final AbsoluteDate date) throws OrekitException {
    /*
         * It is assumed that the geoid is slowly varying over it's entire
         * surface. Therefore there will one local intersection.
         */
    // transform to body frame
    final Frame bodyFrame = this.getBodyFrame();
    final Transform frameToBody = frame.getTransformTo(bodyFrame, date);
    final Vector3D close = frameToBody.transformPosition(closeInFrame);
    final Line lineInBodyFrame = frameToBody.transformLine(lineInFrame);
    // set the line's direction so the solved for value is always positive
    final Line line;
    if (lineInBodyFrame.getAbscissa(close) < 0) {
        line = lineInBodyFrame.revert();
    } else {
        line = lineInBodyFrame;
    }
    final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
    // calculate end points
    // distance from line to center of earth, squared
    final double d2 = line.pointAt(0.0).getNormSq();
    // the minimum abscissa, squared
    final double n = ellipsoid.getPolarRadius() + MIN_UNDULATION;
    final double minAbscissa2 = n * n - d2;
    // smaller end point of the interval = 0.0 or intersection with
    // min_undulation sphere
    final double lowPoint = FastMath.sqrt(FastMath.max(minAbscissa2, 0.0));
    // the maximum abscissa, squared
    final double x = ellipsoid.getEquatorialRadius() + MAX_UNDULATION;
    final double maxAbscissa2 = x * x - d2;
    // larger end point of the interval
    final double highPoint = FastMath.sqrt(maxAbscissa2);
    // line search function
    final UnivariateFunction heightFunction = new UnivariateFunction() {

        @Override
        public double value(final double x) {
            try {
                final GeodeticPoint geodetic = transform(line.pointAt(x), bodyFrame, date);
                return geodetic.getAltitude();
            } catch (OrekitException e) {
                // due to frame transform -> re-throw
                throw new RuntimeException(e);
            }
        }
    };
    // compute answer
    if (maxAbscissa2 < 0) {
        // ray does not pierce bounding sphere -> no possible intersection
        return null;
    }
    // solve line search problem to find the intersection
    final UnivariateSolver solver = new BracketingNthOrderBrentSolver();
    try {
        final double abscissa = solver.solve(MAX_EVALUATIONS, heightFunction, lowPoint, highPoint);
        // return intersection point
        return this.transform(line.pointAt(abscissa), bodyFrame, date);
    } catch (MathRuntimeException e) {
        // no intersection
        return null;
    }
}
Also used : Frame(org.orekit.frames.Frame) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) RealFieldUnivariateFunction(org.hipparchus.analysis.RealFieldUnivariateFunction) UnivariateSolver(org.hipparchus.analysis.solvers.UnivariateSolver) FieldBracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver) BracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver) Line(org.hipparchus.geometry.euclidean.threed.Line) FieldLine(org.hipparchus.geometry.euclidean.threed.FieldLine) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) OrekitException(org.orekit.errors.OrekitException) Transform(org.orekit.frames.Transform) FieldTransform(org.orekit.frames.FieldTransform) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldGeodeticPoint(org.orekit.bodies.FieldGeodeticPoint)

Example 27 with GeodeticPoint

use of org.orekit.bodies.GeodeticPoint in project Orekit by CS-SI.

the class Geoid method getUndulation.

/**
 * Gets the Undulation of the Geoid, N at the given position. N is the
 * distance between the {@link #getEllipsoid() reference ellipsoid} and the
 * geoid. The latitude and longitude parameters are both defined with
 * respect to the reference ellipsoid. For EGM96 and the WGS84 ellipsoid the
 * undulation is between -107m and +86m.
 *
 * <p> NOTE: Restrictions are not put on the range of the arguments {@code
 * geodeticLatitude} and {@code longitude}.
 *
 * @param geodeticLatitude geodetic latitude (angle between the local normal
 *                         and the equatorial plane on the reference
 *                         ellipsoid), in radians.
 * @param longitude        on the reference ellipsoid, in radians.
 * @param date             of evaluation. Used for time varying geopotential
 *                         fields.
 * @return the undulation in m, positive means the geoid is higher than the
 * ellipsoid.
 * @throws OrekitException if an error occurs converting latitude and
 *                         longitude
 * @see Geoid
 * @see <a href="http://en.wikipedia.org/wiki/Geoid">Geoid on Wikipedia</a>
 */
public double getUndulation(final double geodeticLatitude, final double longitude, final AbsoluteDate date) throws OrekitException {
    /*
             * equations references are to the algorithm printed in the geoid
             * cookbook[2]. See comment for Geoid.
             */
    // reference ellipsoid
    final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
    // position in geodetic coordinates
    final GeodeticPoint gp = new GeodeticPoint(geodeticLatitude, longitude, 0);
    // position in Cartesian coordinates, is converted to geocentric lat and
    // lon in the Holmes and Featherstone class
    final Vector3D position = ellipsoid.transform(gp);
    // get normal gravity from ellipsoid, eq 15
    final double normalGravity = ellipsoid.getNormalGravity(geodeticLatitude);
    // calculate disturbing potential, T, eq 30.
    final double mu = this.harmonics.getMu();
    final double T = this.harmonics.nonCentralPart(date, position, mu);
    // calculate undulation, eq 30
    return T / normalGravity;
}
Also used : FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldGeodeticPoint(org.orekit.bodies.FieldGeodeticPoint)

Example 28 with GeodeticPoint

use of org.orekit.bodies.GeodeticPoint in project Orekit by CS-SI.

the class AltitudeDetector method g.

/**
 * Compute the value of the switching function.
 * This function measures the difference between the current altitude
 * and the threshold altitude.
 * @param s the current state information: date, kinematics, attitude
 * @return value of the switching function
 * @exception OrekitException if some specific error occurs
 */
public double g(final SpacecraftState s) throws OrekitException {
    final Frame bodyFrame = bodyShape.getBodyFrame();
    final PVCoordinates pvBody = s.getPVCoordinates(bodyFrame);
    final GeodeticPoint point = bodyShape.transform(pvBody.getPosition(), bodyFrame, s.getDate());
    return point.getAltitude() - altitude;
}
Also used : Frame(org.orekit.frames.Frame) PVCoordinates(org.orekit.utils.PVCoordinates) GeodeticPoint(org.orekit.bodies.GeodeticPoint)

Example 29 with GeodeticPoint

use of org.orekit.bodies.GeodeticPoint in project Orekit by CS-SI.

the class NadirPointing method nadirRef.

/**
 * Compute ground point in nadir direction, in reference frame.
 * @param scRef spacecraft coordinates in reference frame
 * @param refToBody transform from reference frame to body frame
 * @return intersection point in body frame (only the position is set!)
 * @exception OrekitException if line of sight does not intersect body
 */
private TimeStampedPVCoordinates nadirRef(final TimeStampedPVCoordinates scRef, final Transform refToBody) throws OrekitException {
    final Vector3D satInBodyFrame = refToBody.transformPosition(scRef.getPosition());
    // satellite position in geodetic coordinates
    final GeodeticPoint gpSat = shape.transform(satInBodyFrame, getBodyFrame(), scRef.getDate());
    // nadir position in geodetic coordinates
    final GeodeticPoint gpNadir = new GeodeticPoint(gpSat.getLatitude(), gpSat.getLongitude(), 0.0);
    // nadir point position in body frame
    final Vector3D pNadirBody = shape.transform(gpNadir);
    // nadir point position in reference frame
    final Vector3D pNadirRef = refToBody.getInverse().transformPosition(pNadirBody);
    return new TimeStampedPVCoordinates(scRef.getDate(), pNadirRef, Vector3D.ZERO, Vector3D.ZERO);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldGeodeticPoint(org.orekit.bodies.FieldGeodeticPoint) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates)

Example 30 with GeodeticPoint

use of org.orekit.bodies.GeodeticPoint in project Orekit by CS-SI.

the class TopocentricFrameTest method testIssue145.

@Test
public void testIssue145() throws OrekitException {
    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf);
    TopocentricFrame staFrame = new TopocentricFrame(earth, new GeodeticPoint(0.0, 0.0, 0.0), "test");
    GeodeticPoint gp = staFrame.computeLimitVisibilityPoint(Constants.WGS84_EARTH_EQUATORIAL_RADIUS + 600000, 0.0, FastMath.toRadians(5.0));
    Assert.assertEquals(0.0, gp.getLongitude(), 1.0e-15);
    Assert.assertTrue(gp.getLatitude() > 0);
    Assert.assertEquals(0.0, staFrame.getNorth().distance(Vector3D.PLUS_K), 1.0e-15);
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) GeodeticPoint(org.orekit.bodies.GeodeticPoint) BodyShape(org.orekit.bodies.BodyShape) Test(org.junit.Test)

Aggregations

GeodeticPoint (org.orekit.bodies.GeodeticPoint)133 Test (org.junit.Test)78 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)67 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)61 AbsoluteDate (org.orekit.time.AbsoluteDate)45 TopocentricFrame (org.orekit.frames.TopocentricFrame)35 Frame (org.orekit.frames.Frame)34 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)27 SpacecraftState (org.orekit.propagation.SpacecraftState)26 Propagator (org.orekit.propagation.Propagator)24 OrekitException (org.orekit.errors.OrekitException)23 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)23 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)22 PVCoordinates (org.orekit.utils.PVCoordinates)20 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)19 BodyShape (org.orekit.bodies.BodyShape)17 Orbit (org.orekit.orbits.Orbit)15 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)13 ArrayList (java.util.ArrayList)12 FieldGeodeticPoint (org.orekit.bodies.FieldGeodeticPoint)12