1   /* Contributed in the public domain.
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.frames;
18  
19  import org.hipparchus.CalculusFieldElement;
20  import org.orekit.time.AbsoluteDate;
21  import org.orekit.time.FieldAbsoluteDate;
22  import org.orekit.utils.AngularCoordinates;
23  import org.orekit.utils.FieldAngularCoordinates;
24  
25  /**
26   * Transform provider used to match the orientation of a given frame.
27   *
28   * @author Evan M. Ward
29   * @see OriginTransformProvider
30   * @see org.orekit.files.ccsds.definitions.ModifiedFrame
31   * @since 14.0
32   */
33  public class AngularTransformProvider implements TransformProvider {
34  
35      /** Parent frame. */
36      private final Frame parent;
37      /** Orientation provider. */
38      private final Frame orientation;
39  
40      /**
41       * Construct a transform provide that generates angular transforms from
42       * {@code parent} to {@code orientation}. Useful for creating a new frame
43       * centered on {@code parent} and with the same orientation as
44       * {@code orientation}.
45       *
46       * @param parent      frame.
47       * @param orientation provider.
48       */
49      public AngularTransformProvider(final Frame parent,
50                                      final Frame orientation) {
51          this.parent = parent;
52          this.orientation = orientation;
53      }
54  
55      @Override
56      public Transform getTransform(final AbsoluteDate date) {
57          final AngularCoordinates angular =
58                  parent.getTransformTo(orientation, date).getAngular();
59          return new Transform(date, angular);
60      }
61  
62      @Override
63      public <T extends CalculusFieldElement<T>> FieldTransform<T>
64          getTransform(final FieldAbsoluteDate<T> date) {
65  
66          final FieldAngularCoordinates<T> angular =
67                  parent.getTransformTo(orientation, date).getAngular();
68          return new FieldTransform<>(date, angular);
69      }
70  
71      @Override
72      public KinematicTransform getKinematicTransform(final AbsoluteDate date) {
73          final KinematicTransform xform =
74                  parent.getKinematicTransformTo(orientation, date);
75          return KinematicTransform
76                  .of(date, xform.getRotation(), xform.getRotationRate());
77      }
78  
79      @Override
80      public <T extends CalculusFieldElement<T>> FieldKinematicTransform<T>
81          getKinematicTransform(final FieldAbsoluteDate<T> date) {
82  
83          final FieldKinematicTransform<T> xform =
84                  parent.getKinematicTransformTo(orientation, date);
85          return FieldKinematicTransform
86                  .of(date, xform.getRotation(), xform.getRotationRate());
87      }
88  
89      @Override
90      public StaticTransform getStaticTransform(final AbsoluteDate date) {
91          final StaticTransform xform =
92                  parent.getStaticTransformTo(orientation, date);
93          return StaticTransform.of(date, xform.getRotation());
94      }
95  
96      @Override
97      public <T extends CalculusFieldElement<T>> FieldStaticTransform<T>
98          getStaticTransform(final FieldAbsoluteDate<T> date) {
99  
100         final FieldStaticTransform<T> xform =
101                 parent.getStaticTransformTo(orientation, date);
102         return FieldStaticTransform.of(date, xform.getRotation());
103     }
104 
105 }