TargetProvider.java

  1. /* Copyright 2022-2025 Luc Maisonobe
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.attitudes;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.analysis.differentiation.FieldUnivariateDerivative2;
  20. import org.hipparchus.analysis.differentiation.UnivariateDerivative2;
  21. import org.hipparchus.analysis.differentiation.UnivariateDerivative2Field;
  22. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  23. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  24. import org.orekit.bodies.OneAxisEllipsoid;
  25. import org.orekit.frames.Frame;
  26. import org.orekit.time.FieldAbsoluteDate;
  27. import org.orekit.utils.ExtendedPositionProvider;
  28. import org.orekit.utils.FieldPVCoordinates;
  29. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  30. import org.orekit.utils.TimeStampedPVCoordinates;

  31. /**
  32.  * Provider for target vector.
  33.  * @author Luc Maisonobe
  34.  * @since 12.2
  35.  */
  36. public interface TargetProvider
  37. {

  38.     /**
  39.      * Get a target vector.
  40.      * @param sun   Sun model
  41.      * @param earth Earth model
  42.      * @param pv    spacecraft position and velocity
  43.      * @param frame inertial frame
  44.      * @return target direction in the spacecraft state frame, with second order time derivative
  45.      */
  46.     default FieldVector3D<UnivariateDerivative2> getDerivative2TargetDirection(ExtendedPositionProvider sun,
  47.                                                                                OneAxisEllipsoid earth,
  48.                                                                                TimeStampedPVCoordinates pv,
  49.                                                                                Frame frame) {
  50.         final FieldPVCoordinates<UnivariateDerivative2> ud2PV = pv.toUnivariateDerivative2PV();
  51.         final UnivariateDerivative2Field field = UnivariateDerivative2Field.getInstance();
  52.         final UnivariateDerivative2 dt = new UnivariateDerivative2(0., 1., 0.);
  53.         final FieldAbsoluteDate<UnivariateDerivative2> ud2Date = new FieldAbsoluteDate<>(field, pv.getDate()).shiftedBy(dt);
  54.         return getTargetDirection(sun, earth, new TimeStampedFieldPVCoordinates<>(ud2Date, ud2PV), frame);
  55.     }

  56.     /**
  57.      * Get a target vector.
  58.      * @param sun   Sun model
  59.      * @param earth Earth model
  60.      * @param pv    spacecraft position and velocity
  61.      * @param frame inertial frame
  62.      * @return target direction in the spacecraft state frame
  63.      */
  64.     default Vector3D getTargetDirection(ExtendedPositionProvider sun, OneAxisEllipsoid earth,
  65.                                         TimeStampedPVCoordinates pv, Frame frame) {
  66.         return getDerivative2TargetDirection(sun, earth, pv, frame).toVector3D();
  67.     }

  68.     /**
  69.      * Get a target vector.
  70.      * @param <T>   type of the field element
  71.      * @param sun   Sun model
  72.      * @param earth Earth model
  73.      * @param pv    spacecraft position and velocity
  74.      * @param frame inertial frame
  75.      * @return target direction in the spacecraft state frame, with second order time derivative
  76.      */
  77.     default <T extends CalculusFieldElement<T>> FieldVector3D<FieldUnivariateDerivative2<T>> getDerivative2TargetDirection(ExtendedPositionProvider sun,
  78.                                                                                                                            OneAxisEllipsoid earth,
  79.                                                                                                                            TimeStampedFieldPVCoordinates<T> pv,
  80.                                                                                                                            Frame frame) {
  81.         final FieldPVCoordinates<FieldUnivariateDerivative2<T>> ud2PV = pv.toUnivariateDerivative2PV();
  82.         final FieldAbsoluteDate<FieldUnivariateDerivative2<T>> ud2Date = pv.getDate().toFUD2Field();
  83.         return getTargetDirection(sun, earth, new TimeStampedFieldPVCoordinates<>(ud2Date, ud2PV), frame);
  84.     }

  85.     /**
  86.      * Get a target vector.
  87.      * @param <T>   type of the field element
  88.      * @param sun   Sun model
  89.      * @param earth Earth model
  90.      * @param pv    spacecraft position and velocity
  91.      * @param frame inertial frame
  92.      * @return target direction in the spacecraft state frame
  93.      */
  94.     <T extends CalculusFieldElement<T>> FieldVector3D<T> getTargetDirection(ExtendedPositionProvider sun,
  95.                                                                             OneAxisEllipsoid earth,
  96.                                                                             TimeStampedFieldPVCoordinates<T> pv,
  97.                                                                             Frame frame);
  98. }