Changeset 5440 for trunk


Ignore:
Timestamp:
11/21/04 19:19:49 (20 years ago)
Author:
moralejo
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Simulation/Detector/ReflectorII/writemagicdef/writemagicdef.c

    r5438 r5440  
    1111  double x_min, y_min, x_max, y_max, a;
    1212  double norm;
    13   double step; /* (cm) separation of mirror centers = length of mirror side */
     13  double step; // (cm) separation of mirror centers = length of mirror side
    1414
    1515  long x_index, y_index;
     
    4545    for (y = y_min ; y < y_max+1; y += step)   
    4646      {
     47        // Skip non existent mirrors:
    4748
    4849        if ( (fabs(x)+fabs(y)) > diameter*0.72)
     
    5556          continue;
    5657
     58
    5759        x_index = x > 0? (int)(x+50)/100 : (int)(x-50)/100 ;
    5860        y_index = y > 0? (int)(y+50)/100 : (int)(y-50)/100 ;
    59 
    60 //      printf("%d %d  %.0f %.0f\n", x_index, y_index, x, y);
    6161
    6262        i_mirror++;
     
    7373          phin += 2*PI;
    7474
    75 //
    76 // OLD: (before chessboarding) Valid only if mirror is ON the parabola
    77 //      xn = - x / sqrt(x*x+y*y+4*ct_f*ct_f);
    78 //      yn = - y / sqrt(x*x+y*y+4*ct_f*ct_f);
    79 //      zn = 2*ct_f / sqrt(x*x+y*y+4*ct_f*ct_f);
    80 //      printf("%.6f %.6f %.6f\n", xn, yn, zn);
    81 
    82 //
    83 //      Shift z for chessboarding:
    84 //
     75        //
     76        // Shift z for chessboarding:
     77        //
    8578        if (!((x_index+y_index)%2 != 0  ||
    8679              (x_index+y_index) ==  12  ||
     
    8881              (x_index-y_index) ==  12  ||
    8982              (x_index-y_index) == -12 ) )
    90           z += 8.;
     83          z += 8.; // cm
    9184
    92 //
    93 // NEW: Valid also (correct focusing) if we shift mirrors from the parabola,
    94 //      since we use explicitely the z coordinate:
    95 //
     85        //
     86        // Calculate orientation of vector normal to the mirror:
     87        //
     88        // Add the versor pointing from the mirror element center (x,y,z)
     89        // to the camera center (0,0,ct_f), and versor (0,0,1). The
     90        // direction of the resulting vector is that of the bisector of
     91        // the two versors. If the normal of the mirror element is
     92        // oriented along that direction, light rays paralel to the
     93        // telescope axis and impinging on the center of the mirror
     94        // element will be reflected to the center of the camera.
     95        //
     96        //
    9697        xn = - x / sqrt(x*x+y*y+(ct_f-z)*(ct_f-z));
    9798        yn = - y / sqrt(x*x+y*y+(ct_f-z)*(ct_f-z));
    9899        zn = 1 + (ct_f - z) / sqrt(x*x+y*y+(ct_f-z)*(ct_f-z));
    99100
     101        //
     102        // Normalize the vector to obtain the versor:
     103        //
    100104        norm = sqrt(xn*xn+yn*yn+zn*zn);
    101105        xn /= norm;
     
    103107        zn /= norm;
    104108
    105 //      printf("%.6f %.6f %.6f\n\n", xn, yn, zn);
    106 
    107 
     109        //
     110        // Get angle between the normal to the mirror and the
     111        // telescope axis:
     112        //
    108113        thetan = acos(zn);
    109114
    110115        a = 2*ct_f;
    111116
    112 //
    113 // Focal distance of the mirror:
    114 //
     117        //
     118        // Focal distance of the mirror:
     119        //
    115120        f= 0.5 * (a*sqrt((1.+(x*x+y*y)/(a*a))*
    116121                         (1.+(x*x+y*y)/(a*a))*
     
    121126        printf("%3d %9.4f %9.4f %9.4f %9.4f %9.4f %9.4f %9.8f %9.8f %9.8f %9.8f %9.8f\n", i_mirror, f, sx, sy, x, y, z, thetan, phin, xn, yn, zn);
    122127      }
    123 
     128 
    124129  return 0;
    125130}
Note: See TracChangeset for help on using the changeset viewer.