ATSETTILT sets the entrance and exit rotation matrices of an element or a group of elements in THERING RING=ATSETTILT(RING,ELEMINDEX, PSI) ELEMINDEX contains indexes of elements to be rotated PSI - angle(s) of rotation in RADIANS POSITIVE PSI corresponds to a CORKSCREW (right) rotation of the ELEMENT looking in the direction of the beam. (or CORKSCREW, aligned with s-axis) rotation of the ELEMENT The misalgnment matrixes are stored in fields R1 and R2 R1 = [ cos(PSI) sin(PSI); -sin(PSI) cos(PSI) ] R2 = R1' ATSETTILT(ELEMINDEX, PSI) Uses the global variable THERING See also ATSETSHIFT
0001 function ring=atsettilt(varargin) 0002 %ATSETTILT sets the entrance and exit rotation matrices 0003 % of an element or a group of elements in THERING 0004 % 0005 % RING=ATSETTILT(RING,ELEMINDEX, PSI) 0006 % ELEMINDEX contains indexes of elements to be rotated 0007 % PSI - angle(s) of rotation in RADIANS 0008 % POSITIVE PSI corresponds to a CORKSCREW (right) 0009 % rotation of the ELEMENT looking in the direction of the beam. 0010 % (or CORKSCREW, aligned with s-axis) rotation of the ELEMENT 0011 % The misalgnment matrixes are stored in fields R1 and R2 0012 % R1 = [ cos(PSI) sin(PSI); -sin(PSI) cos(PSI) ] 0013 % R2 = R1' 0014 % 0015 % ATSETTILT(ELEMINDEX, PSI) Uses the global variable THERING 0016 % 0017 % See also ATSETSHIFT 0018 0019 global THERING 0020 if ~iscell(varargin{1}) 0021 THERING=atsettilt(THERING,varargin{:}); 0022 else 0023 [ring,idx,rot]=deal(varargin{:}); 0024 0025 if length(rot) == 1 0026 rot=rot*ones(size(idx)); 0027 elseif length(rot) ~= length(idx) 0028 error('AT:length','Vector lengths are incompatible: %i/%i.',length(idx),length(rot)) 0029 end 0030 0031 for i = 1:length(idx) 0032 ring{idx(i)}=attiltelem(ring{idx(i)},rot(i)); 0033 end 0034 end