# Closest points between parametric curve

I would like to ask how to find shortest distance between arbitrary parametric curve in 3D space. I know, that shortest distance is the one that is perpendicular to both curves, so I can find tangent line on each curve. Once I find both tangents, what would be my next step?

You do not need the tangent lines, just the tangent directions along the two curves. Let $$s\mapsto{\bf x}(s)\quad(a\leq s\leq b),\qquad t\mapsto{\bf y}(t)\quad(c\leq t\leq d)$$ be the given parametrizations. Then you want to know the values $s$, $t$ for which $$\bigl({\bf x}(s)-{\bf y}(t)\bigr)\cdot \dot{\bf x}(s)=0,\qquad \bigl({\bf x}(s)-{\bf y}(t)\bigr)\cdot \dot{\bf y}(t)=0\ .$$ These are two scalar equations for the unknowns $s$, $t$. Solving them gives you a few candidates $(s_k,t_k)$. In addition you will have to care about the edges and the vertices of the parameter rectangle $[a,b]\times[c,d]$. I won't go into this here. In all you obtain a candidate list $(s_k,t_k)_{1\leq k\leq N}$ and now have to check by comparing the values $\rho_k:=|{\bf x}(s_k)-{\bf y}(t_k)|$ (resp., their squares) where the global minimum of the distance occurs.