function [z,d] = gyrotronRadiusRT(R,theta) % Based on the Radius and taper angle, the distance % between changes in angle is calculated. This is % sort of the inverse of gyrotronRadiusTD, which % calculates radius based on distance and angle. % The inputs are 'Radius' and 'Theta' (angle), % hence the 'RT' in the function name. % Note: for the case of indeterminate angle (theta=0) % INF is returned as the distance. % % Inputs: % 'theta': [radians] a vector of theta angles % that describe the increase in radius with increasing % axial distance. % 'R': [distance] the corresponding radius vector % defining the points where theta changes. % % Output: % 'z': [distance] the cumulative axial distance vector. % 'd': [distance] the axial spacing distance vector. % % Example: % R = [1 2 3 2 1 1 2 ]; % theta = [0.7 0.6 0.9 -0.5 0.6 -0.6 -0.8]; % [z,d] = gyrotronRadiusRT(R,theta); % [X,Y,Z] = cylinder(R,50); % surf(X,Y,z'*ones(1,length(Z)) ); % colormap autumn; axis equal; % % Last edit by Eunmi Choi and Colin Joye 7/15/03 A = R-[0 R(1:(end-1))]; B = tan(theta); if( any( B./A <= 0 ) ), disp(['gyrotronRadiusRT.m: Radius and Theta values are inconsistent' ... 'or theta is zero.']); d=[]; z=[]; break; end d = R./abs(B); z = cumsum( d ); % ------------ End gyrotronRadiusRT.m -------------