From: yuan on
Hi there,

I got a problem about the multiple-vector rotation. It is stated as follows:

% randomly initialize two vectors
a = rand(10,1);b=rand(10,1);

% get the angle between them and save it as 'ane'
ane = dot(a,b)/(norm(a)*norm(b));
ane = acos(ane)*180/pi;

Now I want to get a new vector, say 'c', which has the same direction with 'a'. I check some materials about the vector rotation, but they only demonstrate how to rotate a 2D vector using a transformation matrix:

T=[cos(ane ),sin(ane );-sin(ane ),cos(ane )];

Can anyone give me hand...

Thanks so much....
From: Roger Stafford on
"yuan " <tianyuan_2003(a)163.com> wrote in message <huetdi$p0f$1(a)fred.mathworks.com>...
> ........
> Now I want to get a new vector, say 'c', which has the same direction with 'a'. I check some materials about the vector rotation, but they only demonstrate how to rotate a 2D vector using a transformation matrix:
> ........

What exactly do you mean by "which has the same direction with 'a'"? If you meant that literally it would be too trivial a problem. Perhaps you mean that you are to find a vector c which makes the same angle with respect to a as does b. If so, you should realize that in ten dimensions this can't be approached as some kind of "rotation". In three dimensions there would have been just one degree of freedom, namely the amount of rotation, whereas in ten dimensions you have eight degrees of freedom, so it becomes a very different sort of problem.

I'll give you a strong hint. You can randomly create another vector which you could call d. It is unlikely to be parallel to a. (If it is, try again.) Now take a linear combination of a and d such that the result is orthogonal to a and call it e. This you should know how to do using the dot product appropriately. Next normalize a and e so they are unit vectors and write

c = a*cos(t)+e*sin(t)

where t is the desired angle. Now see if you can prove that c will indeed have the angle t with respect to a.

Roger Stafford