%**************************************************************************
%This function calculates a new charge structure after the original charges
%are rotated about an axis parallel to the z axis passing through an (x, y)
%location.
%
%Input:
%charge, structure containing the charge information
%   num_charge      %Number of charges
%   q               %Magnetic charge, M.n dA (Am)
%   x               %X position of charge (m)
%   y               %Y position of charge (m)
%   z               %Z position of charge (m)
%   block_num       %Block number the charge came from
%x_0, x coordinate of the rotation axis (m)
%y_0, y coordinate of the rotation axis (m)
%theta_z, angle to rotate the charges by (rad)
%
%Output:
%rotz_charge, structure containing the rotated charge information
%
%Zachary Wolf, 6/3/08

function [rotz_charge] = ppm_calc_rotz_charge(charge, x_0, y_0, theta_z)

%Fill the rotated charge structure
rotz_charge.num_charge = charge.num_charge;
rotz_charge.q = charge.q;
rotz_charge.x = x_0 + (charge.x - x_0) * cos(theta_z) - (charge.y - y_0) * sin(theta_z);
rotz_charge.y = y_0 + (charge.y - y_0) * cos(theta_z) + (charge.x - x_0) * sin(theta_z);
rotz_charge.z = charge.z;
rotz_charge.block_num = charge.block_num;

%Done
        
