Summary: We present a method based on an optimal control technique for numerical computations of geodesic paths between two fixed points of a Riemannian manifold under the assumption of existence. In this method, the control variable is the tangent vector to the geodesic we are looking for. Defining a cost function corresponding to the requested control, we explain how to derive the optimal control algorithm by the use of an adjoint state method for the calculation of the gradient of that cost function. We then give a geometrical interpretation of the adjoint state. After having introduced the discrete optimal control algorithm, we show an application to wooden roof design.