function [ distanceToTravel, thetaOfTurning ] = GeometryTest( r1, r2, uMax,...
    v, dt, rf, thetaf)
%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;
%     h = r1Prime*sin(phi) - 2*R*sin(thetaOfTurning/2)*sin((pi+thetaOfTurning)/2) %h is distance between running parallel and barrier
%     distanceToTravel = sqrt((rf*rf)-(h*h));
    r1h = r1 - R*tan(thetaOfTurning/2);
	h = r1h*cos(phi-pi/2);
    thetaOfTurningWithError = thetaOfTurning + dTheta;  

    thetafPrime = thetaOfTurning - thetaf;
    rfPrime = rf - R*tan(thetafPrime/2);
    distanceToTravelWithoutError = rfPrime*cos(thetafPrime) - R*tan(thetafPrime/2); 
    
    thetaE = thetaf + dTheta;
    thetaEPrime = thetaOfTurning - thetaE;
    distanceToTravel = (h/tan(thetaEPrime)) - R*tan(thetaEPrime/2);
end

