function twomicplot(deltasamples,C,SF)

%twomicplot
%   twomicplot(deltasamples,C,SF) shows the direction of
%   the incoming sound by plotting the range of positions
%   it could occupy.  Assumes that "point of reference"
%   mike is at the origin, and that the second mike is at
%   [0,C].
%
%   The inputs are deltat and C.  C is the distance between
%   the mikes. SF is the sampling freq. Deltasamples is the
%   number of samples difference between the two signals.
%   deltat is this time in seconds, assuming a sampling rate
%   of 44.1khz. deltat = T - t2,  where T is the time of
%   arrival at the center mike, and t2 is the time of arrival
%   at the second mike.  Watch your signs, delta samples
%   should be negative sometimes.
%   See also: maxt, fshift, gowave2, go2, blargh3.

%Converts from difference in samples to difference in time
deltat = deltasamples/SF;

%V = (Vel. of Sound) approximately (331.5 + .6*Tc) m/s
V=340.83;

%Alpha is analogous to the difference in distance between the
%path from the signal signal to each microphone.

Alpha=V*(deltat);


%Checks if the delay is reasonable, throws out any invalid delays.
if (abs(Alpha) > C), %'Invalid Shift for the Given C',
	return, end

%For any given delay and C, there is a minimum possible radius. 
%Attempting to solve the equation for a smaller radius gives
%erratic, sometimes complex, results.
MinR = max((C^2 - Alpha^2)/(2*C - 2*Alpha), (C^2 - Alpha^2)/(-2*C - 2*Alpha) ) + .00001;

%Make a plot of theta vs. a range of radii. 5*C was found to give an acceptable plot.
R = linspace(sqrt(MinR),sqrt(6*C),100);
R = R.^2;

%Equation to be plotted, with parameters Alpha and C, with variables R and theta.
theta = acos( (Alpha^2 - C^2 - 2.*R*Alpha)./(-2.*R*C) );


%Opposite side of the equation.  Cosine is an even function.
theta2 = -theta;


hold on;
polar(theta, R);  %Plot half of the curve
polar(theta2, R); %Plot the other half of the curve
polar(0,C,'*');   %Plot the right mic
polar(0,0,'*');   %Plot the center mic

hold off;

clear R theta theta2;