Search in sources :

Example 16 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class FootprintOverlapDetector method g.

/**
 * {@inheritDoc}
 * <p>
 * The g function value is the minimum offset among the region points
 * with respect to the Field Of View boundary. It is positive if all region
 * points are outside of the Field Of View, and negative if at least some
 * of the region points are inside of the Field Of View. The minimum is
 * computed by sampling the region, considering only the points for which
 * the spacecraft is above the horizon. The accuracy of the detection
 * depends on the linear sampling step set at detector construction. If
 * the spacecraft is below horizon for all region points, an arbitrary
 * positive value is returned.
 * </p>
 * <p>
 * As per the previous definition, when the region enters the Field Of
 * View, a decreasing event is generated, and when the region leaves
 * the Field Of View, an increasing event is generated.
 * </p>
 */
public double g(final SpacecraftState s) throws OrekitException {
    // initial arbitrary positive value
    double value = FastMath.PI;
    // get spacecraft position in body frame
    final Vector3D scBody = s.getPVCoordinates(body.getBodyFrame()).getPosition();
    // map the point to a sphere
    final GeodeticPoint gp = body.transform(scBody, body.getBodyFrame(), s.getDate());
    final S2Point s2p = new S2Point(gp.getLongitude(), 0.5 * FastMath.PI - gp.getLatitude());
    // for faster computation, we start using only the surrounding cap, to filter out
    // far away points (which correspond to most of the points if the zone is small)
    final Vector3D p = s2p.getVector();
    final double dot = Vector3D.dotProduct(p, capCenter);
    if (dot < capCos) {
        // the spacecraft is outside of the cap, look for the closest cap point
        final Vector3D t = p.subtract(dot, capCenter).normalize();
        final Vector3D close = new Vector3D(capCos, capCenter, capSin, t);
        if (Vector3D.dotProduct(p, close) < -0.01) {
            // we can return the arbitrary initial positive value without performing further computation
            return value;
        }
    }
    // the spacecraft may be visible from some points in the zone, check them all
    final Transform bodyToSc = new Transform(s.getDate(), body.getBodyFrame().getTransformTo(s.getFrame(), s.getDate()), s.toTransform());
    for (final SamplingPoint point : sampledZone) {
        final Vector3D lineOfSightBody = point.getPosition().subtract(scBody);
        if (Vector3D.dotProduct(lineOfSightBody, point.getZenith()) <= 0) {
            // spacecraft is above this sample point local horizon
            // get line of sight in spacecraft frame
            final double offset = fov.offsetFromBoundary(bodyToSc.transformVector(lineOfSightBody));
            value = FastMath.min(value, offset);
        }
    }
    return value;
}
Also used : S2Point(org.hipparchus.geometry.spherical.twod.S2Point) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Transform(org.orekit.frames.Transform)

Example 17 with Transform

use of org.orekit.frames.Transform 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 18 with Transform

use of org.orekit.frames.Transform 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 <T extends RealFieldElement<T>> FieldGeodeticPoint<T> getIntersectionPoint(final FieldLine<T> lineInFrame, final FieldVector3D<T> closeInFrame, final Frame frame, final FieldAbsoluteDate<T> date) throws OrekitException {
    final Field<T> field = date.getField();
    /*
         * 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 FieldTransform<T> frameToBody = frame.getTransformTo(bodyFrame, date);
    final FieldVector3D<T> close = frameToBody.transformPosition(closeInFrame);
    final FieldLine<T> lineInBodyFrame = frameToBody.transformLine(lineInFrame);
    // set the line's direction so the solved for value is always positive
    final FieldLine<T> line;
    if (lineInBodyFrame.getAbscissa(close).getReal() < 0) {
        line = lineInBodyFrame.revert();
    } else {
        line = lineInBodyFrame;
    }
    final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
    // calculate end points
    // distance from line to center of earth, squared
    final T d2 = line.pointAt(0.0).getNormSq();
    // the minimum abscissa, squared
    final double n = ellipsoid.getPolarRadius() + MIN_UNDULATION;
    final T minAbscissa2 = d2.negate().add(n * n);
    // smaller end point of the interval = 0.0 or intersection with
    // min_undulation sphere
    final T lowPoint = minAbscissa2.getReal() < 0 ? field.getZero() : minAbscissa2.sqrt();
    // the maximum abscissa, squared
    final double x = ellipsoid.getEquatorialRadius() + MAX_UNDULATION;
    final T maxAbscissa2 = d2.negate().add(x * x);
    // larger end point of the interval
    final T highPoint = maxAbscissa2.sqrt();
    // line search function
    final RealFieldUnivariateFunction<T> heightFunction = z -> {
        try {
            final FieldGeodeticPoint<T> geodetic = transform(line.pointAt(z), bodyFrame, date);
            return geodetic.getAltitude();
        } catch (OrekitException e) {
            // due to frame transform -> re-throw
            throw new RuntimeException(e);
        }
    };
    // compute answer
    if (maxAbscissa2.getReal() < 0) {
        // ray does not pierce bounding sphere -> no possible intersection
        return null;
    }
    // solve line search problem to find the intersection
    final FieldBracketingNthOrderBrentSolver<T> solver = new FieldBracketingNthOrderBrentSolver<>(field.getZero().add(1.0e-14), field.getZero().add(1.0e-6), field.getZero().add(1.0e-15), 5);
    try {
        final T abscissa = solver.solve(MAX_EVALUATIONS, heightFunction, lowPoint, highPoint, AllowedSolution.ANY_SIDE);
        // return intersection point
        return this.transform(line.pointAt(abscissa), bodyFrame, date);
    } catch (MathRuntimeException e) {
        // no intersection
        return null;
    }
}
Also used : AllowedSolution(org.hipparchus.analysis.solvers.AllowedSolution) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldGeodeticPoint(org.orekit.bodies.FieldGeodeticPoint) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) Frame(org.orekit.frames.Frame) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FastMath(org.hipparchus.util.FastMath) FieldBracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver) BracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) TideSystem(org.orekit.forces.gravity.potential.TideSystem) UnivariateSolver(org.hipparchus.analysis.solvers.UnivariateSolver) Line(org.hipparchus.geometry.euclidean.threed.Line) Field(org.hipparchus.Field) RealFieldUnivariateFunction(org.hipparchus.analysis.RealFieldUnivariateFunction) OrekitException(org.orekit.errors.OrekitException) RealFieldElement(org.hipparchus.RealFieldElement) FieldLine(org.hipparchus.geometry.euclidean.threed.FieldLine) Transform(org.orekit.frames.Transform) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) FieldTransform(org.orekit.frames.FieldTransform) AbsoluteDate(org.orekit.time.AbsoluteDate) Frame(org.orekit.frames.Frame) FieldGeodeticPoint(org.orekit.bodies.FieldGeodeticPoint) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) FieldBracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) OrekitException(org.orekit.errors.OrekitException)

Example 19 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class DSSTTesseral method initializeStep.

/**
 * {@inheritDoc}
 */
@Override
public void initializeStep(final AuxiliaryElements aux) throws OrekitException {
    // Equinoctial elements
    a = aux.getSma();
    k = aux.getK();
    h = aux.getH();
    q = aux.getQ();
    p = aux.getP();
    lm = aux.getLM();
    // Eccentricity
    ecc = aux.getEcc();
    e2 = ecc * ecc;
    // Equinoctial frame vectors
    f = aux.getVectorF();
    g = aux.getVectorG();
    // Central body rotation angle from equation 2.7.1-(3)(4).
    final Transform t = bodyFrame.getTransformTo(aux.getFrame(), aux.getDate());
    final Vector3D xB = t.transformVector(Vector3D.PLUS_I);
    final Vector3D yB = t.transformVector(Vector3D.PLUS_J);
    theta = FastMath.atan2(-f.dotProduct(yB) + I * g.dotProduct(xB), f.dotProduct(xB) + I * g.dotProduct(yB));
    // Direction cosines
    alpha = aux.getAlpha();
    beta = aux.getBeta();
    gamma = aux.getGamma();
    // Equinoctial coefficients
    // A = sqrt(μ * a)
    final double A = aux.getA();
    // B = sqrt(1 - h² - k²)
    final double B = aux.getB();
    // C = 1 + p² + q²
    final double C = aux.getC();
    // Common factors from equinoctial coefficients
    // 2 * a / A
    ax2oA = 2. * a / A;
    // B / A
    BoA = B / A;
    // 1 / AB
    ooAB = 1. / (A * B);
    // C / 2AB
    Co2AB = C * ooAB / 2.;
    // B / (A * (1 + B))
    BoABpo = BoA / (1. + B);
    // &mu / a
    moa = provider.getMu() / a;
    // R / a
    roa = provider.getAe() / a;
    // &Chi; = 1 / B
    chi = 1. / B;
    chi2 = chi * chi;
    // mean motion n
    meanMotion = aux.getMeanMotion();
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Transform(org.orekit.frames.Transform)

Example 20 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class ElevationExtremumDetector method g.

/**
 * Compute the value of the detection function.
 * <p>
 * The value is the spacecraft elevation first time derivative.
 * </p>
 * @param s the current state information: date, kinematics, attitude
 * @return spacecraft elevation first time derivative
 * @exception OrekitException if some specific error occurs
 */
public double g(final SpacecraftState s) throws OrekitException {
    // get position, velocity acceleration of spacecraft in topocentric frame
    final Transform inertToTopo = s.getFrame().getTransformTo(topo, s.getDate());
    final TimeStampedPVCoordinates pvTopo = inertToTopo.transformPVCoordinates(s.getPVCoordinates());
    // convert the coordinates to DerivativeStructure based vector
    // instead of having vector position, then vector velocity then vector acceleration
    // we get one vector and each coordinate is a DerivativeStructure containing
    // value, first time derivative (we don't need second time derivative here)
    final FieldVector3D<DerivativeStructure> pvDS = pvTopo.toDerivativeStructureVector(1);
    // compute elevation and its first time derivative
    final DerivativeStructure elevation = pvDS.getZ().divide(pvDS.getNorm()).asin();
    // return elevation first time derivative
    return elevation.getPartialDerivative(1);
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) Transform(org.orekit.frames.Transform) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates)

Aggregations

Transform (org.orekit.frames.Transform)75 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)56 AbsoluteDate (org.orekit.time.AbsoluteDate)33 Frame (org.orekit.frames.Frame)28 FieldTransform (org.orekit.frames.FieldTransform)26 SpacecraftState (org.orekit.propagation.SpacecraftState)26 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)25 PVCoordinates (org.orekit.utils.PVCoordinates)23 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)21 Test (org.junit.Test)20 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)18 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)17 GeodeticPoint (org.orekit.bodies.GeodeticPoint)13 TopocentricFrame (org.orekit.frames.TopocentricFrame)12 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)11 OrekitException (org.orekit.errors.OrekitException)11 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)10 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)10 FieldRotation (org.hipparchus.geometry.euclidean.threed.FieldRotation)8 CircularOrbit (org.orekit.orbits.CircularOrbit)8