0001 function re=setTiltAbout(r,pos,coord,PSI)
0002
0003
0004
0005
0006
0007
0008 numelems = length(pos);
0009
0010 if (numelems ~= length(PSI))
0011 error('ELEMINDEX, D must have the same number of elements');
0012 end
0013
0014 b_s=1;
0015
0016 additive=0;
0017
0018 switch coord
0019 case 'y_MAD8'
0020 for i = 1:length(pos)
0021
0022 C = cos(PSI);
0023 S = sin(PSI);
0024 T = tan(PSI);
0025
0026 RM = diag([1 1 C(i) 1/C(i) 1 1 ]);
0027 RM(4,5) = -1/b_s*T(i);
0028 RM(1,6) = 1/b_s*S(i);
0029
0030 r{pos(i)}.R1 = RM;
0031 r{pos(i)}.R2 = RM';
0032 r{pos(i)}.RotAboutY = PSI(i);
0033
0034
0035 end
0036 case 'x_MAD8'
0037 for i = 1:length(pos)
0038 C = cos(PSI);
0039 S = sin(PSI);
0040 T = tan(PSI);
0041
0042 RM = diag([ C(i) 1/C(i) 1 1 1 1 ]);
0043 RM(2,5) = -1/b_s*T(i);
0044 RM(1,6) = 1/b_s*S(i);
0045
0046 r{pos(i)}.R1 = RM;
0047 r{pos(i)}.R2 = RM';
0048
0049 r{pos(i)}.RotAboutX = PSI(i);
0050
0051
0052 end
0053
0054 case 'y'
0055 for i = 1:length(pos)
0056 if additive
0057 r{pos(i)}.T1(1,2) = r{pos(i)}.T1(2) -PSI(i);
0058 r{pos(i)}.T2(1,2) = r{pos(i)}.T2(2) +PSI(i);
0059 r{pos(i)}.T1(1,1) = r{pos(i)}.T1(1) +r{pos(i)}.Length/2*sin(PSI(i));
0060 r{pos(i)}.T2(1,1) = r{pos(i)}.T2(1) +r{pos(i)}.Length/2*sin(PSI(i));
0061 r{pos(i)}.RotAboutY = r{pos(i)}.RotAboutY + PSI(i);
0062
0063
0064 else
0065 r{pos(i)}.T1(1,2) = -PSI(i);
0066 r{pos(i)}.T2(1,2) = +PSI(i);
0067 r{pos(i)}.T1(1,1) = +r{pos(i)}.Length/2*tan(PSI(i));
0068 r{pos(i)}.T2(1,1) = +r{pos(i)}.Length/2*tan(PSI(i));
0069 r{pos(i)}.RotAboutY = PSI(i);
0070
0071
0072 end
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 end
0090 case 'x'
0091 for i = 1:length(pos)
0092 if additive
0093 r{pos(i)}.T1(1,4) = r{pos(i)}.T1(4) -PSI(i);
0094 r{pos(i)}.T2(1,4) = r{pos(i)}.T2(4) +PSI(i);
0095 r{pos(i)}.T1(1,3) = r{pos(i)}.T1(3) +r{pos(i)}.Length/2*sin(PSI(i));
0096 r{pos(i)}.T2(1,3) = r{pos(i)}.T2(3) +r{pos(i)}.Length/2*sin(PSI(i));
0097 r{pos(i)}.RotAboutX = r{pos(i)}.RotAboutX+ PSI(i);
0098
0099
0100 else
0101 r{pos(i)}.T1(1,4) = -PSI(i);
0102 r{pos(i)}.T2(1,4) = +PSI(i);
0103 r{pos(i)}.T1(1,3) = +r{pos(i)}.Length/2*sin(PSI(i));
0104 r{pos(i)}.T2(1,3) = +r{pos(i)}.Length/2*sin(PSI(i));
0105 r{pos(i)}.RotAboutX = PSI(i);
0106
0107
0108 end
0109 end
0110 case 's'
0111
0112
0113
0114
0115 r=atsettiltdipole(r,pos,PSI);
0116 otherwise
0117 disp('tilt about x, y or s');
0118 end
0119
0120 re=r;