function [d,P1,P2] = UTM_trajDist(O1,V1,ts1,O2,V2,ts2,t)
% UTM_trajDist - determines distance between two closest points
%                on two line segments
% On input:
%     O1 (1x3 vector): Origin vector of segment 1
%     V1 (1x3 vector): Velocity vector of segment 1
%     ts1 (float): Start time of segment 1
%     O2 (1x3 vector): Origin vector of segment 2
%     V2 (1x3 vector): Velocity vector of segment 2
%     ts2 (float): Start time of segment 2
%     t (float): time to find distance
% On output:
%     d (float): distance at time t
%     P1 (1x3 vector): Position along traj 1 at time t.
%     P2 (1x3 vector): Position along traj 2 at time t.
% Call:
%     [d,P1,P2] = trajDistT(O1,V1,ts1,O2,V2,ts2,t);
% Author:
%     B. Russon      / modified by T. Henderson
%     UU
%     Spring 2020    / Summer 2020

%Find the position at time t.
P1 = O1+V1*(t-ts1);
P2 = O2+V2*(t-ts2);

%Find the distance between P1 and P2.
d = norm(P1-P2);
