From: Sang-yeop Chung on
Hi,

I have two vectors in 3D, in other words,
I know the two points.
And the magnitude of two vectors are the same.
then, is there any function or way to get a
'rotation' matrix between two vectors??
I think about projection, but it isn't easy as i supposed.
If you have any idea or know about the function in MATLAB,
I need your help

Regards,

Chung
From: Matt J on
Your problem is a little bit under-defined. Assuming you want the rotation around the axis perpendicular to both vectors x and y, you can do the following:


rotationAxis=cross(x,y);
rotationAngle=acosd( dot(x,y)/norm(x)/norm(y) );

rotationMatrix=R3d(rotationAngle, rotationAxis);

function R=R3d(deg,u)
%R3D - 3D Rotation matrix counter-clockwise about an axis.
%
%R=R3d(deg,u)
%
% deg: The counter-clockwise rotation about the axis u in degrees.
%


R=eye(3);
u=u(:)/norm(u);
x=deg; %abbreviation

for ii=1:3

v=R(:,ii);

R(:,ii)=v*cosd(x) + cross(u,v)*sind(x) + (u.'*v)*(1-cosd(x))*u;
%Rodrigues' formula

end

end
 | 
Pages: 1
Prev: greta
Next: GUI during computation