I think I understand what you mean, but then, I'd possibly solve this matter? Would the solution you provided in your first reply do it ? BTW, what means the "constraint was that it was the minimum possible rotation"?
Sorry for all these questions, it's just that I'm very bad at math and all these terms and notions puzzle me.
My solution is one way of doing it given the constraint I assumed. As has been said, you need to fix the problem that your direction vector does not correspond to an orientation. There are infinitely many orientations, and consequently infinitely many rotations that you can apply, that maps your original vector to the vector AB. You need additional information to reduce this set from infinity to one.
I just claim that I want the shortest possible rotation. The solution I proposed gives you the shortest possible rotation. There is no other rotation that has a shorter angle.
The final orientation may not be what you expect, but the object is indeed pointing in the right direction just as you requested.
Well, changing SDK unfortunately is not an option 
The order of rotation is ZXY.
I'm so bad at math that I'm really amazed to realize how something that I figured out a simple operation (place an object at the same base point of a guide, and orient it along it), instead seems to be so complicated.
I hope you guys can come up with a solution to help me with this.
As has been said also, you only need two rotations but an ZXY order has three rotations. One rotation must be removed from the calculation or you have too many rotations to solve the problem. You could, for example, leave one of the rotations at zero degrees and calculate the other two. That will give you a unique solution. But the problem is that you have three angles and thus three ways to zero an angle, leaving you with three different solutions. Three different solutions that indeed give you three different orientations.
I'll see if I can demonstrate the issue with a very simple experiment for you.
- Sit in front of your computer as usual, looking towards your screen. Your face is now facing the direction towards the screen.
- Tilt your head towards the right but keep looking at the screen. Your face is still facing the direction towards the screen, but the head is tilted 20-ish degrees.
- Tilt your head towards the left instead.
In all three points, your head is facing towards your screen. Thus, they all satisfy your wish to face in a certain direction, but their orientations are different, since you tilt your head to the sides.
That is the difference between direction and orientation: you have a direction and you want an orientation.
Edited by Brother Bob, 01 November 2012 - 05:07 AM.