I am looking to solve an optimization problem which has a particular rotation matrix (i.e. orthonormal basis) as its solution. More specifically. I'm looking to solve the problem numerically with gradient descent, so effectively what I need to make it work is a function that, for some set of parameters, is able to generate any rotation matrix, but also generates only rotation matrices.
My first idea was to use Givens rotations, so that my function is defined over a set of $\binom{n}{2}$ angles that rotate around each (n-2)-dimensional main plane. The overall function would be:
$f(\vec{\theta}) := \prod_{i,a>b} G_{a,b}(\theta_i)$
i.e. the product of all the main rotations, given arbitrary angles $\vec{\theta}$. However, generating this matrix symbolically for each optimization is a bit expensive, and I was wondering if there is a simpler formulation of a (differentiable) function that achieves the same: given some parameters / angles, generate an orthonormal matrix.