Recommended Posts

Recently I have been stumbling over a common problem again:
Setting up a Camera orientaiton from an up and front vector.
Or more general:
Given four vectors a, b, a' and b'. Where the angle between( a, b ) == the angle between ( a', b' ). Finding a quaternion that rotates both the given vector a to match a' and b to match b'.
There is a common "classic" approach to adjust the front ( or right ) vector first and then update the oriantation to match the up vector. Effectively computing two quaternions and multiplying them.
Some time ago, I read this paper (Geometric Algebra Primer) from Jaap Suter.
Well I have a hard time with this kind of mathematics, but I wonder if there is a way to simply take the source up and front vectors and the target up and front vectors and compute a single quaternion from it, that does the job.
Or in other words: What is geometric algebras solution to the problem statet above?
Best
Jochen

Share this post

Link to post

Share on other sites

I'd just use the up and front vector to create an ordinary rotation matrix and then convert the matrix into a quaternion. It is possible that there are mathematical simplifications possible, but I wouldn't even worry about it because this sort of calculation is usually performed so infrequently that it's a waste of time to put much effort into optimizing it (premature optimization) and making a matrix then converting it to a quaternion is already a fairly straightforward solution.

Share this post

Link to post

Share on other sites

I wrote exactly the GA solution to this example #12 in my article on Geometric Algebra which is in Games Gems 5.

I did it for aligning two oriented frames, so extend your problem to c = a cross b and c' = a' cross b' to get two frames.

Relabel the frames a1,a2,a3 and b1,b2,b3. You want a rotor R such that bi = R ai R^-1.

The solution derived gives T=1+Sum_i b_i a^i, and then the rotor is R=T/Abs(T).

Computing this at runtime is quite easy, but you have to work through the math and have the necessary GA functions in the framework.

Unfortunately I cannot post the PDF online, but if you sit in your local bookstore with pencil and paper and work through the article you'll gain a fair amount of worked through examples for Geometric Algebra.