Sub-Riemannian geodesics (thesis)