%**************************************************************************
%This function draws the projection of the blocks and plots the
%projection of the charges in the YZ plane.
%
%Input:
%plt_file, plot file for results
%block, structure containing the block information
%charge, structure containing the magnetic charge information
%
%Zachary Wolf, 1/13/09

function ppm_plot_block_charge_yz(plt_file, block, charge)

%Initialize
figure;
hold on;

%Draw the projection of the blocks
for ii = 1 : block.num_block
    line([block.z_center(ii) - block.z_width(ii) / 2, block.z_center(ii) + block.z_width(ii) / 2],...
        [block.y_center(ii) + block.y_width(ii) / 2, block.y_center(ii) + block.y_width(ii) / 2]);  %Top
    line([block.z_center(ii) - block.z_width(ii) / 2, block.z_center(ii) + block.z_width(ii) / 2],...
        [block.y_center(ii) - block.y_width(ii) / 2, block.y_center(ii) - block.y_width(ii) / 2]);  %Bottom
    line([block.z_center(ii) - block.z_width(ii) / 2, block.z_center(ii) - block.z_width(ii) / 2],...
        [block.y_center(ii) - block.y_width(ii) / 2, block.y_center(ii) + block.y_width(ii) / 2]);  %Left
    line([block.z_center(ii) + block.z_width(ii) / 2, block.z_center(ii) + block.z_width(ii) / 2],...
        [block.y_center(ii) - block.y_width(ii) / 2, block.y_center(ii) + block.y_width(ii) / 2]);  %Right
end

%Draw the projection of the charges
index_array = find(charge.q > 0);
plot(charge.z(index_array), charge.y(index_array), 'r+');
index_array = find(charge.q < 0);
plot(charge.z(index_array), charge.y(index_array), 'kx');

%Labels
title('Permanent Magnet Blocks And Charges');
xlabel('Z Position (m)');
ylabel('Y Position (m)');

%Finalize
grid on;
zoom on;
hold off;

%Print
orient landscape;
print('-append', '-dpsc', plt_file);

%Done
