1 /* Copyright 2002-2021 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
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
21 import org.hipparchus.geometry.euclidean.threed.Vector3D;
22 import org.orekit.bodies.BodyShape;
23 import org.orekit.bodies.GeodeticPoint;
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 /**
35 * This class handles target pointing attitude provider.
36
37 * <p>
38 * This class represents the attitude provider where the satellite z axis is
39 * pointing to a ground point target.</p>
40 * <p>
41 * The target position is defined in a body frame specified by the user.
42 * It is important to make sure this frame is consistent.
43 * </p>
44 * <p>
45 * The object <code>TargetPointing</code> is guaranteed to be immutable.
46 * </p>
47 * @see GroundPointing
48 * @author Véronique Pommier-Maurussane
49 */
50 public class TargetPointing extends GroundPointing {
51
52 /** Target in body frame. */
53 private final Vector3D target;
54
55 /** Creates a new instance from body frame and target expressed in Cartesian coordinates.
56 * @param inertialFrame frame in which orbital velocities are computed
57 * @param bodyFrame body frame.
58 * @param target target position in body frame
59 * @since 7.1
60 */
61 public TargetPointing(final Frame inertialFrame, final Frame bodyFrame, final Vector3D target) {
62 super(inertialFrame, bodyFrame);
63 this.target = target;
64 }
65
66 /** Creates a new instance from body shape and target expressed in geodetic coordinates.
67 * @param inertialFrame frame in which orbital velocities are computed
68 * @param targetGeo target defined as a geodetic point in body shape frame
69 * @param shape body shape
70 * @since 7.1
71 */
72 public TargetPointing(final Frame inertialFrame, final GeodeticPoint targetGeo, final BodyShape shape) {
73 super(inertialFrame, shape.getBodyFrame());
74 // Transform target from geodetic coordinates to Cartesian coordinates
75 target = shape.transform(targetGeo);
76 }
77
78 /** {@inheritDoc} */
79 @Override
80 public TimeStampedPVCoordinates getTargetPV(final PVCoordinatesProvider pvProv,
81 final AbsoluteDate date, final Frame frame) {
82 final Transform t = getBodyFrame().getTransformTo(frame, date);
83 final TimeStampedPVCoordinates pv =
84 new TimeStampedPVCoordinates(date, target, Vector3D.ZERO, Vector3D.ZERO);
85 return t.transformPVCoordinates(pv);
86 }
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
99 }