TargetPointing.java

  1. /* Copyright 2002-2019 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.RealFieldElement;
  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.FieldTransform;
  24. import org.orekit.frames.Frame;
  25. import org.orekit.frames.Transform;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.time.FieldAbsoluteDate;
  28. import org.orekit.utils.FieldPVCoordinatesProvider;
  29. import org.orekit.utils.PVCoordinatesProvider;
  30. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  31. import org.orekit.utils.TimeStampedPVCoordinates;

  32. /**
  33.  * This class handles target pointing attitude provider.

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

  48.     /** Serializable UID. */
  49.     private static final long serialVersionUID = 20150529L;

  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.     public <T extends RealFieldElement<T>> TimeStampedFieldPVCoordinates<T> getTargetPV(final FieldPVCoordinatesProvider<T> pvProv,
  85.                                                                                         final FieldAbsoluteDate<T> date, final Frame frame) {
  86.         final FieldTransform<T> t = getBodyFrame().getTransformTo(frame, date);
  87.         final FieldVector3D<T> zero = FieldVector3D.getZero(date.getField());
  88.         final TimeStampedFieldPVCoordinates<T> pv =
  89.                 new TimeStampedFieldPVCoordinates<>(date, new FieldVector3D<>(date.getField(), target), zero, zero);
  90.         return t.transformPVCoordinates(pv);
  91.     }

  92. }