TargetPointing.java

  1. /* Copyright 2002-2018 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.errors.OrekitException;
  24. import org.orekit.frames.FieldTransform;
  25. import org.orekit.frames.Frame;
  26. import org.orekit.frames.Transform;
  27. import org.orekit.time.AbsoluteDate;
  28. import org.orekit.time.FieldAbsoluteDate;
  29. import org.orekit.utils.FieldPVCoordinatesProvider;
  30. import org.orekit.utils.PVCoordinatesProvider;
  31. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  32. import org.orekit.utils.TimeStampedPVCoordinates;

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

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

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

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

  53.     /** Creates a new instance from body frame and target expressed in Cartesian coordinates.
  54.      * @param inertialFrame frame in which orbital velocities are computed
  55.      * @param bodyFrame body frame.
  56.      * @param target target position in body frame
  57.      * @exception OrekitException if the first frame specified is not a pseudo-inertial frame
  58.      * @since 7.1
  59.      */
  60.     public TargetPointing(final Frame inertialFrame, final Frame bodyFrame, final Vector3D target)
  61.         throws OrekitException {
  62.         super(inertialFrame, bodyFrame);
  63.         this.target = target;
  64.     }

  65.     /** Creates a new instance from body shape and target expressed in geodetic coordinates.
  66.      * @param inertialFrame frame in which orbital velocities are computed
  67.      * @param targetGeo target defined as a geodetic point in body shape frame
  68.      * @param shape body shape
  69.      * @exception OrekitException if the frame specified is not a pseudo-inertial frame
  70.      * @since 7.1
  71.      */
  72.     public TargetPointing(final Frame inertialFrame, final GeodeticPoint targetGeo, final BodyShape shape)
  73.         throws OrekitException {
  74.         super(inertialFrame, shape.getBodyFrame());
  75.         // Transform target from geodetic coordinates to Cartesian coordinates
  76.         target = shape.transform(targetGeo);
  77.     }

  78.     /** {@inheritDoc} */
  79.     @Override
  80.     public TimeStampedPVCoordinates getTargetPV(final PVCoordinatesProvider pvProv,
  81.                                                 final AbsoluteDate date, final Frame frame)
  82.         throws OrekitException {
  83.         final Transform t = getBodyFrame().getTransformTo(frame, date);
  84.         final TimeStampedPVCoordinates pv =
  85.                 new TimeStampedPVCoordinates(date, target, Vector3D.ZERO, Vector3D.ZERO);
  86.         return t.transformPVCoordinates(pv);
  87.     }

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

  99. }