Changeset 5440 for trunk/MagicSoft/Simulation/Detector
- Timestamp:
- 11/21/04 19:19:49 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/ReflectorII/writemagicdef/writemagicdef.c
r5438 r5440 11 11 double x_min, y_min, x_max, y_max, a; 12 12 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 14 14 15 15 long x_index, y_index; … … 45 45 for (y = y_min ; y < y_max+1; y += step) 46 46 { 47 // Skip non existent mirrors: 47 48 48 49 if ( (fabs(x)+fabs(y)) > diameter*0.72) … … 55 56 continue; 56 57 58 57 59 x_index = x > 0? (int)(x+50)/100 : (int)(x-50)/100 ; 58 60 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);61 61 62 62 i_mirror++; … … 73 73 phin += 2*PI; 74 74 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 // 85 78 if (!((x_index+y_index)%2 != 0 || 86 79 (x_index+y_index) == 12 || … … 88 81 (x_index-y_index) == 12 || 89 82 (x_index-y_index) == -12 ) ) 90 z += 8.; 83 z += 8.; // cm 91 84 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 // 96 97 xn = - x / sqrt(x*x+y*y+(ct_f-z)*(ct_f-z)); 97 98 yn = - y / sqrt(x*x+y*y+(ct_f-z)*(ct_f-z)); 98 99 zn = 1 + (ct_f - z) / sqrt(x*x+y*y+(ct_f-z)*(ct_f-z)); 99 100 101 // 102 // Normalize the vector to obtain the versor: 103 // 100 104 norm = sqrt(xn*xn+yn*yn+zn*zn); 101 105 xn /= norm; … … 103 107 zn /= norm; 104 108 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 // 108 113 thetan = acos(zn); 109 114 110 115 a = 2*ct_f; 111 116 112 //113 // Focal distance of the mirror:114 //117 // 118 // Focal distance of the mirror: 119 // 115 120 f= 0.5 * (a*sqrt((1.+(x*x+y*y)/(a*a))* 116 121 (1.+(x*x+y*y)/(a*a))* … … 121 126 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); 122 127 } 123 128 124 129 return 0; 125 130 }
Note:
See TracChangeset
for help on using the changeset viewer.