Home > atplot > atreforbit.m

atreforbit

PURPOSE ^

ATREFORBIT computes the coordinates of the local referential

SYNOPSIS ^

function [xref,zref] = atreforbit(ring)

DESCRIPTION ^

ATREFORBIT computes the coordinates of the local referential
           It allows plotting functions (trajectory/orbit) to plot through
           displaced elements

[XREF,ZREF]=ATREFORBIT(RING)

RING:     AT structure

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function  [xref,zref] = atreforbit(ring)
0002 %ATREFORBIT computes the coordinates of the local referential
0003 %           It allows plotting functions (trajectory/orbit) to plot through
0004 %           displaced elements
0005 %
0006 %[XREF,ZREF]=ATREFORBIT(RING)
0007 %
0008 %RING:     AT structure
0009 %
0010 
0011 xzc=[0;0];
0012 slope=[0;0];
0013 [xx,zz]=cellfun(@incr,ring);
0014 xref=[0;xx];
0015 zref=[0;zz];
0016 
0017     function varargout=incr(elem)
0018 %         if isfield(elem,'R1')
0019 %             rots(elem.R1);
0020 %         end
0021         if isfield(elem,'T1') && ~isfield(elem,'hideT1')
0022             hvkick(elem.T1(:));
0023         end
0024         if isfield(elem,'Length')
0025             xzc=xzc+slope*elem.Length;
0026         end
0027         if isfield(elem,'T2') && ~isfield(elem,'hideT2')
0028             hvkick(elem.T2(:));
0029         end
0030 %         if isfield(elem,'R2')
0031 %             rots(elem.R2);
0032 %         end
0033         varargout=num2cell(xzc');
0034     end
0035 %     function rots(R)
0036 %         cns=R(1,1);
0037 %         sns=R(1,3);
0038 %         conv=conv*[1 0 0;0 cns -sns;0 sns cns];
0039 %     end
0040     function hvkick(T1)
0041         xzc=xzc-T1([1 3]);
0042         slope=slope-tan(T1([2 4]));
0043     end
0044 end
0045

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005