function [thetaOfTurning ] = FindTurningTheta( r1, r2, uMax, v, dt)
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here
    if uMax == 0;
        R = 100000;
    else
        R = 1/uMax;
    end
    dTheta = uMax*v*dt;
    
    r2Prime = r2 + R*tan(dTheta/2);
    r1Prime = r1 - R*tan(dTheta/2);
    r3 = sqrt((r1Prime*r1Prime)+(r2Prime*r2Prime)-2*r1Prime*r2Prime*cos(dTheta)); %law of cosines
    phi = pi - asin(r1Prime*sin(dTheta)/r3) - dTheta; %phi is original angle of incidence with barrier
    thetaOfTurning = pi - phi;
end


