1 /* Copyright 2002-2020 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.RealFieldElement;
20 import org.hipparchus.geometry.euclidean.threed.Rotation;
21 import org.orekit.annotation.DefaultDataContext;
22 import org.orekit.data.DataContext;
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
31
32 /**
33 * This class handles an inertial attitude provider.
34 * <p>Instances of this class are guaranteed to be immutable.</p>
35 * @author Luc Maisonobe
36 */
37 public class InertialProvider implements AttitudeProvider {
38
39
40 /** Dummy attitude provider, perfectly aligned with the EME2000 frame.
41 *
42 * <p>This field uses the {@link DataContext#getDefault() default data context}.
43 *
44 * @see #InertialProvider(Rotation, Frame)
45 * @see #InertialProvider(Frame)
46 */
47 @DefaultDataContext
48 public static final InertialProvider EME2000_ALIGNED =
49 new InertialProvider(Rotation.IDENTITY);
50
51 /** Fixed satellite frame. */
52 private final Frame satelliteFrame;
53
54 /** Creates new instance.
55 *
56 * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
57 *
58 * @param rotation rotation from EME2000 to the desired satellite frame
59 * @see #InertialProvider(Rotation, Frame)
60 */
61 @DefaultDataContext
62 public InertialProvider(final Rotation rotation) {
63 this(rotation, DataContext.getDefault().getFrames().getEME2000());
64 }
65
66 /**
67 * Creates new instance aligned with the given frame.
68 *
69 * @param frame the reference frame for the attitude.
70 */
71 public InertialProvider(final Frame frame) {
72 this(Rotation.IDENTITY, frame);
73 }
74
75 /**
76 * Creates new instance with a fixed attitude in the given frame.
77 *
78 * @param rotation rotation from {@code reference} to the desired satellite frame
79 * @param reference frame for {@code rotation}.
80 * @since 10.1
81 */
82 public InertialProvider(final Rotation rotation,
83 final Frame reference) {
84 satelliteFrame =
85 new Frame(reference,
86 new Transform(AbsoluteDate.ARBITRARY_EPOCH, rotation), null, false);
87 }
88
89 /** {@inheritDoc} */
90 public Attitude getAttitude(final PVCoordinatesProvider pvProv,
91 final AbsoluteDate date, final Frame frame) {
92 final Transform t = frame.getTransformTo(satelliteFrame, date);
93 return new Attitude(date, frame, t.getRotation(), t.getRotationRate(), t.getRotationAcceleration());
94 }
95
96 /** {@inheritDoc} */
97 public <T extends RealFieldElement<T>>FieldAttitude<T> getAttitude(final FieldPVCoordinatesProvider<T> pvProv,
98 final FieldAbsoluteDate<T> date, final Frame frame) {
99 final FieldTransform<T> t = frame.getTransformTo(satelliteFrame, date);
100 return new FieldAttitude<>(date, frame, t.getRotation(), t.getRotationRate(), t.getRotationAcceleration());
101 }
102
103 }