vc=30; % Speed of vehicle (m/s) - note has no effect on optimal angle, though increases minimum running speed
da=10; % Distance from vehicle (m) - larger distance allows for angle closer to the perpendicular along with slower speed
dc=1;  % Half of vehicle width (m) - larger width forces angle closer to car direction and faster speed
theta=0:0.01:pi()/2; % Possible running angles, 0=with car, pi()/2=directly perpendicular
vr=1./((da./(dc*vc)+cos(theta)./(sin(theta).*vc)).*sin(theta)); % required safe running velocity at each angle theta
[m,p]=min(vr); % find the minimum safe running velocity out of those tested
hold on; % overlay multiple runs of this script
plot(theta,vr,theta(p),m,'*r'); % plot the angle-velocity relation and highlight min point
[theta(p),m,dc/(m*sin(theta(p)));theta(end),vr(end),dc/(vr(end)*sin(theta(end)))] % display the angle associated with minimum safe velocity, and the velocity value (5.4 m/s is about the fastest you can run), as well as required velocity for perpendicular crossing, and finally the time it is safe to be on the road for each theta showing the extra time that a non-perpendicular theta affords
(ans(1,3)-ans(2,3))*vc % To finish, show the along-vehicle distance that the optimal theta affords