Vector rotation
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
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.
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:
As always, the actual mathematicians are free to correct me [smile]
To find a matrix to rotate (x1,y1,z1) to (x1',y1',z1'), I'd do something like this:
- Find (xr,yr,zr), the axis of rotation, by taking the cross product of (x1,y1,z1) and (x1',y1',z1').
- 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.
- 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.
- Multiply (x2,y2,z2) by the resulting matrix.
- Profit!
As always, the actual mathematicians are free to correct me [smile]
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.
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.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement