function [Vx,Vy] = srcPanel(r1,r2,X,Y) %% Source Pannel % *Input* - endpoints of a source pannel, and size of vector field: % r1 and r2 - source pannel endpoints % X and Y - coordinate field to evaluate the pannel on % *Output* - Calculates the velocity of a source pannel given: % Vx and Vy - Matrix of vector field values for use with the quiver % comand. % Length of panel L = norm(r1-r2); % Calculates the midpoint of panel r1-r2 r_m = (r1+r2)./2; % Angle of the panel x_r = r1(1)-r2(1); y_r = r1(2)-r2(2); d = atan(y_r/x_r); % Directions t_hat = [cos(d) sin(d)]; % Vector tangent to the panel % Length of r1-r2 (magnatude) dr = sqrt((X-r_m(1)).^2+(Y-r_m(2)).^2); % t component of dr (R dot t_hat) rDt = X.*t_hat(1) + Y.*t_hat(2); % Calculating the BIG VELOCITY EQUATION % Repeating terms in the big equation coeff_a = sqrt(dr.^2-rDt.^2); coeff_b = (L/2-rDt); coeff_c = (-L/2-rDt); % Quantitys inside the brackets coeff_d = atan(coeff_b./coeff_a)-1.*atan(coeff_c./coeff_a); coeff_e = log(1+(coeff_b./coeff_a).^2)-1*log(1+(coeff_c./coeff_a).^2); % Plugging everything in to the big equation Vx = ((X-t_hat(1)*rDt)./(2*pi*coeff_a)).*coeff_d - (t_hat(1)/(4*pi))*coeff_e; Vy = ((Y-t_hat(2)*rDt)./(2*pi*coeff_a)).*coeff_d - (t_hat(2)/(4*pi))*coeff_e;