function s = yagi9(pos,dir,c)
% s = yagi7(pos,dir,c)
% 9-element-Yagi
% pos :  [x y z]-vector of center of mass position of the antenna
% dir :  main radiatin direction: Euler's angles or transformation matrix.
%        See function rotation for details.
% c   :  complex amplitude of excitation

% Author:  Klaus von der Heide, e-mail:  dj5hg@qsl.net

% Default
% =======
if nargin<3  c = 1; end

% Constants
% =========
k = 2;                   % index of active dipole
d = 0.002;               % diameter of passive elements
dd= 0.008;               % diameter of active dipole
x = [-0.39;  0;     0.165; 0.54;  0.93;  1.422;1.917;2.412; 3.072] - 1.30; % element positions
l = [ 0.5175;0.5000;0.4775;0.4725;0.4700;0.465;0.460;0.4525;0.4375];       % half length of elements
n = length(x);           % number of elements
z = zeros(n,1);          % height of antenna elements
m = 7;                   % number of segments per element

% Construction
% ============
a  = [x -l z];           % coordinates of one end of elements
b  = [x +l z];           % coordinates of the other end of elements
el = wires(a([1,3:end],:),b([1,3:end],:),d,m);             % passive elements
dp = exwire(a(2,:),b(2,:),dd,m,c);                         % dipole
boom = wire([x(1)-0.03 0 0], [x(end)+0.03 0 0], 0.01, 20); % Boom
s = construct(dp,el,boom);  % putting all together

% Possible shift and rotation
% ===========================
if nargin>0  s = translation(s,pos); end
if nargin>1  s = rotation(s,dir);    end
