AttitudeProviderModifier.java

  1. /* Copyright 2002-2024 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. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.geometry.euclidean.threed.FieldRotation;
  20. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  21. import org.hipparchus.geometry.euclidean.threed.Rotation;
  22. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  23. import org.orekit.frames.Frame;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.time.FieldAbsoluteDate;
  26. import org.orekit.utils.AngularCoordinates;
  27. import org.orekit.utils.FieldAngularCoordinates;
  28. import org.orekit.utils.FieldPVCoordinatesProvider;
  29. import org.orekit.utils.PVCoordinatesProvider;

  30. /** This interface represents an attitude provider that modifies/wraps another underlying provider.
  31.  * @author Luc Maisonobe
  32.  * @since 5.1
  33.  */
  34. public interface AttitudeProviderModifier extends AttitudeProvider {

  35.     /** Get the underlying attitude provider.
  36.      * @return underlying attitude provider
  37.      */
  38.     AttitudeProvider getUnderlyingAttitudeProvider();

  39.     /**
  40.      * Wrap the input provider with a new one always returning attitudes with zero rotation rate and acceleration.
  41.      * It is not physically sound, but remains useful for performance when a full, physical attitude with time derivatives is not needed.
  42.      * @param attitudeProvider provider to wrap
  43.      * @return wrapping provider
  44.      * @since 12.1
  45.      */
  46.     static AttitudeProviderModifier getFrozenAttitudeProvider(final AttitudeProvider attitudeProvider) {
  47.         return new AttitudeProviderModifier() {
  48.             @Override
  49.             public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) {
  50.                 final Rotation rotation = attitudeProvider.getAttitudeRotation(pvProv, date, frame);
  51.                 final AngularCoordinates angularCoordinates = new AngularCoordinates(rotation, Vector3D.ZERO);
  52.                 return new Attitude(date, frame, angularCoordinates);
  53.             }

  54.             @Override
  55.             public <T extends CalculusFieldElement<T>> FieldAttitude<T> getAttitude(final FieldPVCoordinatesProvider<T> pvProv, final FieldAbsoluteDate<T> date, final Frame frame) {
  56.                 final FieldRotation<T> rotation = attitudeProvider.getAttitudeRotation(pvProv, date, frame);
  57.                 final FieldAngularCoordinates<T> angularCoordinates = new FieldAngularCoordinates<>(rotation, FieldVector3D.getZero(date.getField()));
  58.                 return new FieldAttitude<>(date, frame, angularCoordinates);
  59.             }

  60.             @Override
  61.             public AttitudeProvider getUnderlyingAttitudeProvider() {
  62.                 return attitudeProvider;
  63.             }
  64.         };
  65.     }
  66. }