PointingPanel.java

  1. /* Copyright 2022-2025 Luc Maisonobe
  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.forces;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.hipparchus.util.FastMath;
  22. import org.hipparchus.util.Precision;
  23. import org.orekit.propagation.FieldSpacecraftState;
  24. import org.orekit.propagation.SpacecraftState;
  25. import org.orekit.utils.ExtendedPositionProvider;

  26. /** Class representing one panel of a satellite, roughly pointing towards some target.
  27.  * <p>
  28.  * It is mainly used to represent a rotating solar array that points towards the Sun.
  29.  * </p>
  30.  * <p>
  31.  * The panel rotation with respect to satellite body is the best pointing orientation
  32.  * achievable when the rotation axix is fixed by body attitude. Target is therefore
  33.  * always exactly in meridian plane defined by rotation axis and panel normal vector.
  34.  * </p>
  35.  * <p>
  36.  * These panels are considered to be always {@link #isDoubleSided() double-sided}.
  37.  * </p>
  38.  *
  39.  * @author Luc Maisonobe
  40.  * @since 3.0
  41.  */
  42. public class PointingPanel extends Panel {

  43.     /** Rotation axis. */
  44.     private final Vector3D rotationAxis;

  45.     /** Target towards which the panel will point. */
  46.     private final ExtendedPositionProvider target;

  47.     /** Simple constructor.
  48.      * <p>
  49.      * As the sum of absorption coefficient, specular reflection coefficient and
  50.      * diffuse reflection coefficient is exactly 1, only the first two coefficients
  51.      * are needed here, the third one is deduced from the other ones.
  52.      * </p>
  53.      * <p>
  54.      * The panel is considered to rotate about one axis in order to make its normal
  55.      * point as close as possible to the target. It means the target will always be
  56.      * in the plane defined by the rotation axis and the panel normal.
  57.      * </p>
  58.      * @param rotationAxis rotation axis of the panel
  59.      * @param target target towards which the panel will point (the Sun for a solar array)
  60.      * @param area panel area in m²
  61.      * @param drag drag coefficient
  62.      * @param liftRatio drag lift ratio (proportion between 0 and 1 of atmosphere modecules
  63.      * that will experience specular reflection when hitting spacecraft instead
  64.      * of experiencing diffuse reflection, hence producing lift)
  65.      * @param absorption radiation pressure absorption coefficient (between 0 and 1)
  66.      * @param reflection radiation pressure specular reflection coefficient (between 0 and 1)
  67.      */
  68.     public PointingPanel(final Vector3D rotationAxis, final ExtendedPositionProvider target,
  69.                          final double area,
  70.                          final double drag, final double liftRatio,
  71.                          final double absorption, final double reflection) {
  72.         super(area, true, drag, liftRatio, absorption, reflection);
  73.         this.rotationAxis = rotationAxis.normalize();
  74.         this.target       = target;
  75.     }

  76.     /** {@inheritDoc} */
  77.     @Override
  78.     public Vector3D getNormal(final SpacecraftState state) {

  79.         // compute orientation for best pointing
  80.         final Vector3D targetInert = target.getPosition(state.getDate(), state.getFrame()).
  81.                                      subtract(state.getPosition()).normalize();
  82.         final Vector3D targetSpacecraft = state.getAttitude().getRotation().applyTo(targetInert);
  83.         final double d = Vector3D.dotProduct(targetSpacecraft, rotationAxis);
  84.         final double f = 1 - d * d;
  85.         if (f < Precision.EPSILON) {
  86.             // extremely rare case: the target is along panel rotation axis
  87.             // (there will not be much output power if it is a solar array…)
  88.             // we set up an arbitrary normal
  89.             return rotationAxis.orthogonal();
  90.         }

  91.         final double s = 1.0 / FastMath.sqrt(f);
  92.         return new Vector3D(s, targetSpacecraft, -s * d, rotationAxis);

  93.     }

  94.     /** {@inheritDoc} */
  95.     @Override
  96.     public <T extends CalculusFieldElement<T>> FieldVector3D<T> getNormal(final FieldSpacecraftState<T> state) {
  97.         // compute orientation for best pointing
  98.         final FieldVector3D<T> targetInert = target.getPosition(state.getDate(), state.getFrame()).
  99.                                              subtract(state.getPosition()).normalize();
  100.         final FieldVector3D<T> targetSpacecraft = state.getAttitude().getRotation().applyTo(targetInert);
  101.         final T d = FieldVector3D.dotProduct(targetSpacecraft, rotationAxis);
  102.         final T f = d.multiply(d).subtract(1).negate();
  103.         if (f.getReal() < Precision.EPSILON) {
  104.             // extremely rare case: the target is along panel rotation axis
  105.             // (there will not be much output power if it is a solar array…)
  106.             // we set up an arbitrary normal
  107.             return new FieldVector3D<>(f.getField(), rotationAxis.orthogonal());
  108.         }

  109.         final T s = f.sqrt().reciprocal();
  110.         return new FieldVector3D<>(s, targetSpacecraft,
  111.                                    s.multiply(d).negate(), new FieldVector3D<>(state.getDate().getField(), rotationAxis));
  112.     }

  113. }