Short version of question: I am trying to use quaternions to avoid gimbal-lock, but I don't know how to express unit quaternions using three degrees of freedom without re-introducing Euler angles and (I suspect) the problem of gimbal-lock.
Long version of question: I confess am not very familiar with the limitations of numberic solvers (such as gradient-descent method) for finding minima of functions. I am concerned that if I feed in extra dependent variables or if I have weird situations that could arise (such as gimbal-lock) the solvers may behave strangely. Which leads to my question: is there a way to express the unit vector part of a unit quaternion with only two variables, other than using spherical coordinates (which essentially re-introduces the gimbal-lock)?
Context of the problem: I am trying to devise a way to reverse-solve the relative position/orientation between two stereo cameras. There are six degrees of freedom here: three translation, three rotation. The basic idea is to pre-calibrate each camera so you can express the direction each pixel points as a vector in the camera's reference frame, where in the pinhole camera model each vector from a single camera passes through a common point in space. Then, you can pick an object (say some corner) that you can see from both cameras. The pixel on that object from the first camera represents a vector from the first camera's position. The second camera also has a pixel on that object, representing a second vector, this time from the second camera's position. These two vectors should intersect, since they point at the same object. Finding several such intersecting vectors between the two cameras will give you enough constraints to solve your six-degrees-of-freedom issue, and finding more-than-enough common points will leave you with a non-linear least-squares sort of problem, which I am trying to solve numerically.
Thanks for reading.