Visibility of Location with FOV

Hello, I am trying to design a code that determined the visibility windows of a target location, including the FOV of its sensor. I designed the code according to another forum page (credits to writer Field of View Sat Event Detector Example), where the code is lower in that page. However, as I increase the FOV the start/end times remains the same until 70deg, when the duration time beings to decrease. This clearly makes no sense, the duration should be increasing even at 1deg FOV. Below is my code, any help would be greatly appreciated.

    // orbit creation
    Vector3D position  = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
    Vector3D velocity  = new Vector3D(505.8479685, 942.7809215, 7435.922231);
    PVCoordinates pvCoordinates = new PVCoordinates(position,velocity);
    AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
    Frame inertialFrame = FramesFactory.getEME2000();
    double mu = Constants.WGS84_EARTH_MU;
    Orbit initialOrbit = new KeplerianOrbit(pvCoordinates, inertialFrame, initialDate, mu);

    // ground station declaration
    double longitude = FastMath.toRadians(30.);
    double latitude = FastMath.toRadians(25.);
    double altitude = 0;

    GeodeticPoint geoPoint = new GeodeticPoint(latitude, longitude, altitude);
    Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame);

    TopocentricFrame gpsFrame = new TopocentricFrame(earth, geoPoint, "location_one");

    // set FOV for camera
    FieldOfView fov = new CircularFieldOfView(Vector3D.PLUS_K, FastMath.toRadians(70), FastMath.toRadians(0));
    final FieldOfViewDetector fd = new FieldOfViewDetector(gpsFrame, fov);
    final ElevationDetector ed = new ElevationDetector(gpsFrame).withConstantElevation(0.);

    // create detector
    final BooleanDetector detector = BooleanDetector.andCombine(ed,fd).withMaxCheck(10.).withHandler(new EventHandler<BooleanDetector>(){
        private AbsoluteDate start;
        public Action eventOccurred(SpacecraftState s, BooleanDetector detector, boolean increasing) throws OrekitException{
                final GeodeticPoint satelliteAsGeodeticPoint = earth.transform(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate());

                start = s.getDate();
                System.out.format("ENTERED AREA: date: %s Satellite Coordinates: {latitude: %f3.9, longitude: %f3.9, altitude: %f km}\n",
                        (satelliteAsGeodeticPoint.getAltitude() / 1000));

                return Action.CONTINUE;
            } else {
                final double duration = s.getDate().durationFrom(start);
                System.out.format("EXITING AREA: date: %s Pass duration: %f\n", s.getDate(), duration);
                return Action.CONTINUE;


    Propagator propagator = new KeplerianPropagator(initialOrbit, mu);

    SpacecraftState finalState = propagator.propagate(new AbsoluteDate(initialDate, 10000.));

According to this post the sign of the FieldOfViewDetector has to be changed

final BooleanDetector detector = BooleanDetector.andCombine(ed, BooleanDetector.notCombine(fd))

You also need to define an attitude law for the satellite e.g.,

NadirPointing nadirLaw = new NadirPointing(inertialFrame, earth);
Propagator propagator = new KeplerianPropagator(initialOrbit, mu);

try these changes and check if the results make more sense.

Hello, thank you for your help. However, when I added that modification and ran it, I got no hits, but when I compared to GMAT with no FOV modifications I got 2 hits, so there is something wrong. My previous version also got 2 hits very similar to GMAT’s, so the propagation is correct.

Weird, with the nadir pointing attitude and the change in the sign of the FOV detector I get this two hits with your code (70 deg half aperture in the FOV detector):

ENTERED AREA: date: 2004-01-01T23:33:42.74172267673828Z Satellite Coordinates: {latitude: 13,2797583.9, longitude: 54,0733843.9, altitude: 688,826360 km}
EXITING AREA: date: 2004-01-01T23:43:20.61377916165458Z Pass duration: 577,872056
ENTERED AREA: date: 2004-01-02T01:08:31.23353283372028Z Satellite Coordinates: {latitude: -0,4673723.9, longitude: 32,3040873.9, altitude: 687,810569 km}
EXITING AREA: date: 2004-01-02T01:22:16.9842935974314Z Pass duration: 825,750761

I get those values too at 70deg, however those are the same values at 0deg without notCombine. Similarly, increasing to 80deg doesn’t change the visibility windows either, which it should since you are making the circles bigger.

UPDATE: I have yet to calculate accurate results. I used STK to compare my results and they are not accurate. I used a half-FOV angle of 70deg and computed a window from Nov 13 03:04:00.552 to Nov 13 03:05:07.295 UTC. STK, on the other hand, computes that window in the same time, and 2 other ones on Nov 13 16:00 and Nov 14 02:30 that my code does not compute. Any help would be appreciated.