Sign in to follow this  
fear4ever

Vector rotation

Recommended Posts

Hi, I have 2 vectors. a=[x1,y1,y1] b=[x2,y2,z2] Now somehow the vector a is rotated to a'=[x1',y1',z1'] a' is given without the rotation matrix that produced it. What i need is to rotate the vector b the same way vector a has been rotated to obtain b'=[x2',y2',z2']. Any (if possible easy) way to do this? Thanks

Share this post


Link to post
Share on other sites
Unfortunately, the rotation from a to a' isn't unique, meaning there are any number of different rotation matrices that could perform that transformation. For instance, the rotation axis could have been parallel to a x a', or it could have been parallel to a + a'. Perhaps you could provide us with context to help you chose the best rotation.

Share this post


Link to post
Share on other sites
There's probably a "right" way to do this, but I'll give it a go (despite this sounding like homework).

To find a matrix to rotate (x1,y1,z1) to (x1',y1',z1'), I'd do something like this:

  1. Find (xr,yr,zr), the axis of rotation, by taking the cross product of (x1,y1,z1) and (x1',y1',z1').

  2. Find the angle you need to rotate by taking the dot product of the normalized (1-length) original vectors (x1,y1,z1) and (x1',y1',z1'), then taking the acos of the result.

  3. Google up "rotation arbitrary axis" or something to figure out how to make a matrix out of the information from step 1 and step 2.

  4. Multiply (x2,y2,z2) by the resulting matrix.

  5. Profit!



As always, the actual mathematicians are free to correct me [smile]

Share this post


Link to post
Share on other sites
As Zipster said, the axis of rotation can be the median axis of any single cone which contains the start and end vectors — so any vector perpendicular to v' - v fits, which constitutes an infinite set.

To determine a rotation, you need at least two independent pairs of transformed vectors: a given pair determines a plane of possible axes, so two independent pairs intersect their planes and yield an axis.

Share this post


Link to post
Share on other sites
This is not a homework. I am trying to build a pipe around a curve, the normals at curve points need to match so i can create circles around it and connect them with triangle strips.

BeanDog, your methods seems like it will work. I am not very good with linear algebra, so i'll try to implement this and let you know.

Thanks for replies

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this