TargetPointing.java

  1. /* Copyright 2002-2025 CS GROUP
  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.geometry.euclidean.threed.FieldVector3D;
  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.orekit.bodies.BodyShape;
  22. import org.orekit.bodies.GeodeticPoint;
  23. import org.orekit.frames.FieldStaticTransform;
  24. import org.orekit.frames.FieldTransform;
  25. import org.orekit.frames.Frame;
  26. import org.orekit.frames.StaticTransform;
  27. import org.orekit.frames.Transform;
  28. import org.orekit.time.AbsoluteDate;
  29. import org.orekit.time.FieldAbsoluteDate;
  30. import org.orekit.utils.FieldPVCoordinatesProvider;
  31. import org.orekit.utils.PVCoordinatesProvider;
  32. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  33. import org.orekit.utils.TimeStampedPVCoordinates;

  34. /**
  35.  * This class handles target pointing attitude provider.

  36.  * <p>
  37.  * This class represents the attitude provider where the satellite z axis is
  38.  * pointing to a ground point target.</p>
  39.  * <p>
  40.  * The target position is defined in a body frame specified by the user.
  41.  * It is important to make sure this frame is consistent.
  42.  * </p>
  43.  * <p>
  44.  * The object <code>TargetPointing</code> is guaranteed to be immutable.
  45.  * </p>
  46.  * @see     GroundPointing
  47.  * @author V&eacute;ronique Pommier-Maurussane
  48.  */
  49. public class TargetPointing extends GroundPointing {

  50.     /** Target in body frame. */
  51.     private final Vector3D target;

  52.     /** Creates a new instance from body frame and target expressed in Cartesian coordinates.
  53.      * @param inertialFrame frame in which orbital velocities are computed
  54.      * @param bodyFrame body frame.
  55.      * @param target target position in body frame
  56.      * @since 7.1
  57.      */
  58.     public TargetPointing(final Frame inertialFrame, final Frame bodyFrame, final Vector3D target) {
  59.         super(inertialFrame, bodyFrame);
  60.         this.target = target;
  61.     }

  62.     /** Creates a new instance from body shape and target expressed in geodetic coordinates.
  63.      * @param inertialFrame frame in which orbital velocities are computed
  64.      * @param targetGeo target defined as a geodetic point in body shape frame
  65.      * @param shape body shape
  66.      * @since 7.1
  67.      */
  68.     public TargetPointing(final Frame inertialFrame, final GeodeticPoint targetGeo, final BodyShape shape) {
  69.         super(inertialFrame, shape.getBodyFrame());
  70.         // Transform target from geodetic coordinates to Cartesian coordinates
  71.         target = shape.transform(targetGeo);
  72.     }

  73.     /** {@inheritDoc} */
  74.     @Override
  75.     public TimeStampedPVCoordinates getTargetPV(final PVCoordinatesProvider pvProv,
  76.                                                 final AbsoluteDate date, final Frame frame) {
  77.         final Transform t = getBodyFrame().getTransformTo(frame, date);
  78.         final TimeStampedPVCoordinates pv =
  79.                 new TimeStampedPVCoordinates(date, target, Vector3D.ZERO, Vector3D.ZERO);
  80.         return t.transformPVCoordinates(pv);
  81.     }

  82.     /** {@inheritDoc} */
  83.     @Override
  84.     protected Vector3D getTargetPosition(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) {
  85.         final StaticTransform staticTransform = getBodyFrame().getStaticTransformTo(frame, date);
  86.         return staticTransform.transformPosition(target);
  87.     }

  88.     /** {@inheritDoc} */
  89.     @Override
  90.     public <T extends CalculusFieldElement<T>> TimeStampedFieldPVCoordinates<T> getTargetPV(final FieldPVCoordinatesProvider<T> pvProv,
  91.                                                                                             final FieldAbsoluteDate<T> date, final Frame frame) {
  92.         final FieldTransform<T> t = getBodyFrame().getTransformTo(frame, date);
  93.         final FieldVector3D<T> zero = FieldVector3D.getZero(date.getField());
  94.         final TimeStampedFieldPVCoordinates<T> pv =
  95.                 new TimeStampedFieldPVCoordinates<>(date, new FieldVector3D<>(date.getField(), target), zero, zero);
  96.         return t.transformPVCoordinates(pv);
  97.     }

  98.     /** {@inheritDoc} */
  99.     @Override
  100.     protected <T extends CalculusFieldElement<T>> FieldVector3D<T> getTargetPosition(final FieldPVCoordinatesProvider<T> pvProv,
  101.                                                                                      final FieldAbsoluteDate<T> date,
  102.                                                                                      final Frame frame) {
  103.         final FieldStaticTransform<T> staticTransform = getBodyFrame().getStaticTransformTo(frame, date);
  104.         return staticTransform.transformPosition(target);
  105.     }
  106. }