1   /* Copyright 2002-2025 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.geometry.fov;
18  
19  import org.hipparchus.geometry.euclidean.threed.RotationOrder;
20  import org.hipparchus.geometry.euclidean.threed.Vector3D;
21  import org.hipparchus.random.Well19937a;
22  import org.hipparchus.util.FastMath;
23  import org.junit.jupiter.api.Test;
24  import org.orekit.attitudes.LofOffset;
25  import org.orekit.attitudes.NadirPointing;
26  import org.orekit.frames.LOFType;
27  import org.orekit.frames.Transform;
28  import org.orekit.time.AbsoluteDate;
29  
30  public class CircularFieldOfViewTest extends AbstractSmoothFieldOfViewTest {
31  
32      @Test
33      public void testNadirNoMargin() {
34          doTestFootprint(new CircularFieldOfView(Vector3D.PLUS_K, FastMath.toRadians(3.0), 0.0),
35                          new NadirPointing(orbit.getFrame(), earth),
36                          3.0, 3.0, 85.3650, 85.3745, 181027.5, 181028.5);
37      }
38  
39      @Test
40      public void testNadirMargin() {
41          doTestFootprint(new CircularFieldOfView(Vector3D.PLUS_K, FastMath.toRadians(3.0), 0.01),
42                          new NadirPointing(orbit.getFrame(), earth),
43                          3.0, 3.0, 85.3650, 85.3745, 181027.5, 181028.5);
44      }
45  
46      @Test
47      public void testRollPitchYaw() {
48          doTestFootprint(new CircularFieldOfView(Vector3D.PLUS_K, FastMath.toRadians(3.0), 0.0),
49                          new LofOffset(orbit.getFrame(), LOFType.LVLH_CCSDS, RotationOrder.XYZ,
50                                        FastMath.toRadians(10),
51                                        FastMath.toRadians(20),
52                                        FastMath.toRadians(5)),
53                          3.0, 3.0, 48.8582, 59.4238, 1256410.4, 1761338.4);
54      }
55  
56      @Test
57      public void testFOVPartiallyTruncatedAtLimb() {
58          doTestFootprint(new CircularFieldOfView(Vector3D.PLUS_K, FastMath.toRadians(3.0), 0.0),
59                          new LofOffset(orbit.getFrame(), LOFType.LVLH_CCSDS, RotationOrder.XYZ,
60                                        FastMath.toRadians(-10),
61                                        FastMath.toRadians(-39),
62                                        FastMath.toRadians(-5)),
63                          0.3899, 3.0, 0.0, 21.7315, 3431325.4, 5346737.5);
64      }
65  
66      @Test
67      public void testFOVLargerThanEarth() {
68          doTestFootprint(new CircularFieldOfView(Vector3D.PLUS_K, FastMath.toRadians(45.0), 0.0),
69                          new NadirPointing(orbit.getFrame(), earth),
70                          40.3505, 40.4655, 0.0, 0.0, 5323032.8, 5347029.8);
71      }
72  
73      @Test
74      public void testFOVAwayFromEarth() {
75          doTestFOVAwayFromEarth(new CircularFieldOfView(Vector3D.MINUS_K, FastMath.toRadians(3.0), 0.0),
76                                 new LofOffset(orbit.getFrame(), LOFType.LVLH_CCSDS, RotationOrder.XYZ,
77                                               FastMath.toRadians(-10),
78                                               FastMath.toRadians(-39),
79                                               FastMath.toRadians(-5)),
80                                 Vector3D.MINUS_K);
81      }
82  
83      @Test
84      public void testBoundary() {
85          doTestBoundary(new CircularFieldOfView(Vector3D.MINUS_K, FastMath.toRadians(3.0), 0.01),
86                         new Well19937a(0x2fdf54d1c6f679afl),
87                         2.0e-15);
88      }
89  
90      @Test
91      public void testNoFootprintInside() {
92          doTestNoFootprintInside(new CircularFieldOfView(Vector3D.PLUS_K, FastMath.toRadians(3.0), 0.0),
93                                  new Transform(AbsoluteDate.J2000_EPOCH, new Vector3D(5e6, 3e6, 2e6)));
94      }
95  
96  }