function ROT = rotDvl(Bd,theta, psi) 
%% Return a unit vector describing the ray path of the dvl. 
% Inputs
% Bd = tilt radians from vertical 
% theta pitch from horizontal of beam in radians
% psi= heading in radians
% now we can generate a rotation matrix rotate about the x axis
Rf = [
    1,   0,   0;
    0,   cos(Bd), - sin(Bd);
    0,   sin(Bd), cos(Bd)
    ];


% det the rotated vectors 
ROT = zeros(length(theta),3);
for n=1:length(theta)
    U = [
        cos(theta(n))*cos(psi(n));
        cos(theta(n))*sin(psi(n));
        -sin(theta(n))
        ];
    
    ROT(n,:) = [Rf*U]';
        
end
