Results 1 to 2 of 2

Math Help - Vector to rotation

  1. #1
    Newbie
    Joined
    Jan 2011
    Posts
    2

    Vector to rotation

    Hi,

    I have this small problem. I have looked on the internet and I found some answers but they weren't 100% clear.
    Let's say I have two 3D vectors:

    x: -0.551020951227745 y: 0.291595823345109 z: 0.781887323797847
    and
    x: -0.881938222372968 y: -0.362656707254797 z: 0.301106434007507

    I need to find the rotation matrix which rotates the first vector onto the second one. Can somebody explain to me how I do this exactly? Like with a formula or something? Thx
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Jan 2011
    Posts
    2
    Never mind, problem solved, if anyone else ever needs it, here's the solution in matlab code, im assuming it's readable even if u can't read matlab code, cross = cross product and dot = dot product:

    Code:
        u = normal_vectors(1);
        v = normal_vectors(2);
        n = cross(u,v);
        n = n/norm(n);
        phi = acos(dot(u,v) / (norm(u) * norm(v))); %in radials
    
        t = (1-cos(phi));
        s = sin(phi);
        d = cos(phi);
    
        a = n(1);
        b = n(2);
        c = n(3);
    
        Rmatrix = [   t*a^2+d t*a*b-s*c t*a*c + s*b; 
                t*a*b + s*c t*b^2+d t*b*c - a*s; 
                t*a*c - s*b t*b*c+s*a t*c^2 + d 
                ];
    So you end up with a rotation matrix which if applied rotates like the first vector to the second
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Silly yet annoying porblem concening vector rotation
    Posted in the Advanced Algebra Forum
    Replies: 1
    Last Post: December 5th 2010, 06:32 AM
  2. Up vector and angle to rotation matrix
    Posted in the Geometry Forum
    Replies: 0
    Last Post: March 16th 2010, 07:21 AM
  3. Replies: 1
    Last Post: August 25th 2009, 03:18 AM
  4. rotation of vector on diagonal plane
    Posted in the Calculus Forum
    Replies: 9
    Last Post: August 9th 2009, 01:31 PM
  5. Vector Rotation 3D - determine correct angle
    Posted in the Calculus Forum
    Replies: 1
    Last Post: January 18th 2008, 07:32 AM

Search Tags


/mathhelpforum @mathhelpforum