Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
cspice_brcktd

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries


Abstract


   CSPICE_BRCKTD brackets a double precision number. That is, given a number
   and an acceptable interval, make sure that the number is contained in the
   interval. (If the number is already in the interval, leave it alone. If
   not, set it to the nearest endpoint of the interval.)

I/O


   Given:

      number   the number to be bracketed.

               help, number
                  DOUBLE = Scalar

               That is, the value of `number' is constrained to lie in the
               interval bounded by `end1' and `end2'.

      end1,
      end2     the lower and upper bounds for `number'.

               help, end1
                  DOUBLE = Scalar
               help, end2
                  DOUBLE = Scalar

               The order is not important.

   the call:

      brcktd = cspice_brcktd( number, end1, end2 )

   returns:

      brcktd   the bracketed number.

               help, brcktd
                  DOUBLE = Scalar

               That is `number', if it was already in the interval provided.
               Otherwise the returned value is the nearest bound of the
               interval.

Parameters


   None.

Examples


   Any numerical results shown for these examples may differ between
   platforms as the results depend on the SPICE kernels used as input
   and the machine specific arithmetic implementation.

   1) The following code example illustrates the operation of
      cspice_brcktd.

      Example code begins here.


      PRO brcktd_ex1

         ;;
         ;; Local parameters.
         ;;
         LISTSZ =   4

         ;;
         ;; Set the values for the example.
         ;;
         end1   = [ 1.D0,   1.D0,  10.D0, -10.D0]
         end2   = [10.D0,  10.D0, -10.D0,  -1.D0]
         number = [-1.D0,  29.D0,   3.D0,   3.D0]

         print, format='(A)', ' Number  End1   End2   Bracketed'
         print, format='(A)', ' ------  -----  -----  ---------'

         for i=0L, LISTSZ-1L do begin

            print, format='(3F7.1,F11.1)', number[i], end1[i], end2[i],      $
                            cspice_brcktd( number[i], end1[i], end2[i] )

         endfor

      END


      When this program was executed on a Mac/Intel/IDL8.x/64-bit
      platform, the output was:


       Number  End1   End2   Bracketed
       ------  -----  -----  ---------
         -1.0    1.0   10.0        1.0
         29.0    1.0   10.0       10.0
          3.0   10.0  -10.0        3.0
          3.0  -10.0   -1.0       -1.0


   2) The following code example illustrates a typical use for
      cspice_brcktd: force a star magnitude limit to be within a range.
      Note that this code assumes that the user provided value
      is a valid double precision number.


      Example code begins here.


      PRO brcktd_ex2

         ;;
         ;; Prompt the user for the star magnitude.
         ;;
         usrin = ' '
         read, usrin, PROMPT = 'Enter star magnitude: '

         ;;
         ;; Convert the user input to double precision.
         ;;
         cspice_prsdp, usrin, maglin

         ;;
         ;; Star magnitude must be in the range 0-10.
         ;;
         maglok = cspice_brcktd( maglin, 0.D0, 10.D0 )

         ;;
         ;; Display confirmation message.
         ;;
         if ( maglin ne maglok ) then begin

            print, format='(A,F4.1,A)', 'Provided star magnitude ', maglin,  $
                                        ' is out of range (0-10).'

         endif else begin

            print, format='(A,F4.1,A)', 'Provided star magnitude ', maglin,  $
                                        ' is in range (0-10).'

         endelse

      END


      When this program was executed on a Mac/Intel/IDL8.x/64-bit
      platform, using '10.1' as user provided input, the output was:


      Enter star magnitude: 10.1
      Provided star magnitude 10.1 is out of range (0-10).


Particulars


   This routine provides a shorthand notation for code fragments
   like the following:

      if ( end1 lt end2 ) then begin
         if ( number lt end1 ) then begin
            number = end1
         endif else if ( number gt end2 ) then begin
            number = end2
         endif
      endif else begin
         if ( number lt end2 ) then begin
            number = end2
         endif else if ( number gt end1 ) then begin
            number = end1
         endif
      endif

   which occur frequently during the processing of program inputs.

Exceptions


   1)  If any of the input arguments, `number', `end1' or `end2', is
       undefined, an error is signaled by the IDL error handling
       system.

   2)  If any of the input arguments, `number', `end1' or `end2', is
       not of the expected type, or it does not have the expected
       dimensions and size, an error is signaled by the Icy
       interface.

Files


   None.

Restrictions


   None.

Required_Reading


   ICY.REQ

Literature_References


   None.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)
   B.V. Semenov        (JPL)
   E.D. Wright         (JPL)

Version


   -Icy Version 1.1.0, 08-AUG-2021 (JDR) (BVS)

       BUG FIX: corrected to make the order of endpoints not important
       as stated in the description.

       Edited the header to comply with NAIF standard. Added complete
       code examples.

       Added the -Parameters, -Particulars, -Exceptions, -Files,
       -Restrictions and -Literature_References sections.

       Removed reference to the routine's corresponding CSPICE header from
       -Abstract section.

       Added arguments' type and size information in the -I/O section.

   -Icy Version 1.0.0, 16-JUN-2003 (EDW)

Index_Entries


   bracket a d.p. value within an interval



Fri Dec 31 18:43:02 2021