Azimuth and Elevation between two satellites

@Serrof
Thank you so much for replying me.
Now, I am doing this. I created a SatLinkDetector to limit the distance and AzEi of the communication between two satellites, like this(Referenced from here):

public class SatLinkDetector extends AbstractDetector<SatLinkDetector> {

    private final double distance;
    private final double minElevation;
    private final double maxElevation;
    private final PVCoordinatesProvider secondary;

    public SatLinkDetector(final double distance, final double minElevation, final double maxElevation, final PVCoordinatesProvider secondary) {
        this(distance, minElevation, maxElevation, secondary, DEFAULT_MAXCHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER, new ContinueOnEvent<>());
    }

    private SatLinkDetector(final double distance,
                            final double minElevation,
                            final double maxElevation,
                            final PVCoordinatesProvider secondary,
                            final double maxCheck,
                            final double threshold,
                            final int maxIter,
                            final EventHandler<? super SatLinkDetector> handler) {
        super(maxCheck, threshold, maxIter, handler);
        this.distance = distance;
        this.minElevation = minElevation;
        this.maxElevation = maxElevation;
        this.secondary = secondary;
    }

    @Override
    public double g(SpacecraftState s) {

        // PV of the primary
        final Vector3D pPrimary = s.getPVCoordinates().getPosition();

        // PV of the secondary
        final Vector3D pSecondary = secondary.getPVCoordinates(s.getDate(), s.getFrame()).getPosition();

        OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
                Constants.WGS84_EARTH_FLATTENING, FramesFactory.getTIRF(IERSConventions.IERS_2010, true));

        // LLA
        final GeodeticPoint geodeticPoint = earth.transform(pSecondary, s.getFrame(), s.getDate());
        final TopocentricFrame observe = new TopocentricFrame(earth, geodeticPoint, "Test");
        // Elevation
        final double elevation = FastMath.toDegrees(observe.getElevation(pPrimary, s.getFrame(), s.getDate()));
        final double azimuth = FastMath.toDegrees(observe.getAzimuth(pPrimary, s.getFrame(), s.getDate()));
        final double range = Vector3D.distance(pPrimary, pSecondary) - distance;

        if (elevation < maxElevation && elevation > minElevation && range <= 0) {
            return 1;
        } else {
            return -1;
        }
    }

    @Override
    protected SatLinkDetector create(final double newMaxCheck, final double newThreshold, final int newMaxIter,
                                     final EventHandler<? super SatLinkDetector> newHandler) {
        return new SatLinkDetector(distance, minElevation, maxElevation, secondary, newMaxCheck, newThreshold, newMaxIter, newHandler);
    }
}

Am I doing this right?