# computing rotation matrix for vector rotation about another vector

Discussion in 'MATLAB' started by John, Sep 4, 2007.

1. ### JohnGuest

I have two known vectors (in 3-space if it matters), v and
b. v is rotated by an unknown rotation matrix, R, into b.

b=Rv

I want to rotate b by the same amount (and in the same plane
of rotation defined by v and b) to get c. i.e.:

c=Rb=RRv

R is orthogonal, so RR' = R'R = I, so

R'c=Rv=b

I only need to compute c. If I can compute c without
computing R, that works. But some mental block stops me from
computing c.

I could come up with:

cross(v,c) = n ( 2 * cross(v,b) * dot(v,b) )/ (|v| * |b|)

where n = cross(v,b) / |cross(v,b)|

so the LHS can be expressed as a skew-symmetric matrix, V,
with c, and the RHS is just a scalar times the normal
direction, but I can't seem to solve for c because V is rank 2.

Any ideas?

thanks,
john

John, Sep 4, 2007

2. ### W. Dale HallGuest

Try this: use the fact that the points

0 (the origin)
v
b

all lie in a plane (the plane containing the
circle that v would rotate through if you took
all real powers of the matrix R and applied to
v), and that the triangles

0 v b

0 b c

are congruent. If you were to sketch a picture
of this plane, you would get something like this:

v
. .
. .
0--------------------b
. .
. .
c

where I've indicated the lines connecting
0&v, 0&b, 0&c, v&b and v&c as well as I could
given ASCII characters. The next thing to
notice is that v and c are symmetric about the
line 0b, so you could in fact write c as the
reflection of v through this line.

The easy way to do this it to take the projection
of v along b:

(v.b/||b||^2) b

and subtract it from v:

v - (v.b/ ||b||^ 2) b

to get the component of v orthogonal to b.

I'll let p(v,b) denote v.b / ||b||^2
to simplify what follows.

Note that you get a decomposition of v into
parts parallel to b & orthogonal to b:

v = p(v,b) b + (v - p(v,b) b)

(you should verify for yourself that the
second term is indeed orthogonal to b)

The vector c you want just has the other sign
for the component orthogonal to b:

c = p(v,b) b - (v - p(v,b) b)

That should do the trick.

Dale

W. Dale Hall, Sep 5, 2007

3. ### W. Dale HallGuest

... stuff deleted ...

oops: I forgot to note that c is also in this plane.

Duh.

Dale

W. Dale Hall, Sep 5, 2007
4. ### JohnGuest

Dale,
Thanks for the idea. That looks right. I'll try it today.
thanks,
john

John, Sep 5, 2007
5. ### JohnGuest

Dale, thanks. That worked.

John, Sep 5, 2007