COMPLEMENT





Percy



Syntax




   LET @schedule = @schedule COMPLEMENT


Description




The program finds intervals when geometric constraints are satisfied. Frequently, you will be more interested in the intervals during which the constraints are not satisfied. (For example, when an object is not eclipsed.)

The complement of a schedule is analogous to the complement of a set: the resulting schedule contains every point in the default interval that is not contained in the original schedule.

Formally, suppose that W is the schedule consisting of the intervals

   [a_1,b_1], [a_2, b_2],..., [a_n, b_n]
and that the endpoints of the default schedule are A and B respectively. The complement of W is defined to be the schedule that represents the intersection of the sets

   (-infinity,a_1]  U  [b_1,a_2]  U  [b_2,a_3]  U  ... [b_n,infinity)
and

   [A,B]
Because the intervals in the original schedule are closed, the intervals in the mathematical complement must be open. This is a problem because the result of the operation must also be a schedule, and because the intervals in a schedule must be closed. By convention, then, the endpoints of the intervals in a schedule are also contained in its complement.

(This convention means that zero-length intervals in the original schedule give rise to adjacent intervals with a common endpoint, which are then merged. Thus, any zero-length intervals in a schedule cannot be recovered once the schedule has been complemented.)

A graphical description of the COMPLEMENT command is shown below.

   Input schedule  :   ---     --------   ---------
   Bounds        : ----------------------------------
   Output schedule : --   -----        ---         ----


Examples






Example 1



In the following example, the COMPLEMENT command is used to determine a set of intervals during which Io is not obscured by Jupiter: that is, not occulted, not eclipsed, and not in transit.

   DEFINE RESOLUTION  STEP SIZE 30 MINUTES;
   FIND OCC OCCULTATION OF IO BY     JUPITER FROM EARTH RESOLUTION;
   FIND ECL ECLIPSE     OF IO BY     JUPITER FROM EARTH RESOLUTION;
   FIND TRN TRANSIT     OF IO ACROSS JUPITER FROM EARTH RESOLUTION;
 
   LET BAD  = OCC + ECL;
   LET BAD  = BAD + TRN;
   LET GOOD = BAD COMPLEMENT;
Note that this involves some redundant searching. For instance, a satellite cannot simultaneously be occulted by and in transit across the same body. The following commands achieve the same results, but much more efficiently.

   ;
   ;  Begin by finding intervals of non-occultation.
   ;
   DEFINE RESOLUTION  STEP SIZE 30 MINUTES;
   FIND BAD OCCULTATION OF IO BY JUPITER FROM EARTH RESOLUTION;
   LET GOOD = BAD COMPLEMENT;
 
   ;
   ;  Search for transits only when not occulted.
   ;  Subtract them out.
   ;
   FIND TRN TRANSIT OF IO
                    ACROSS JUPITER
                    FROM EARTH
                    WITHIN GOOD RESOLUTION;
 
   LET NOT_TRN = TRN COMPLEMENT;
   LET GOOD    = NOT_TRN * GOOD;
 
   ;
   ;  Search for eclipses only when not occulted or in transit.
   ;  Subtract them out.
   ;
   FIND ECL ECLIPSE IOBODS WITHIN GOOD RESOLUTION;
   LET NOT_ECL = ECL COMPLEMENT;
   LET GOOD    = GOOD * NOT_ECL;
The second strategy is less obvious than the first, but for long searches this kind of optimization can pay off.



Related Topics




  1. Difference
  2. Intersect
  3. About Schedules
  4. The Percy Help System