Skip to content

Instantly share code, notes, and snippets.

View mpatel8's full-sized avatar

Miten Patel mpatel8

  • Imperial College - Dept of Bioengineering
  • London, UK
View GitHub Profile
@peteristhegreat
peteristhegreat / fcn_RotationFromTwoVectors.m
Created August 20, 2015 22:09
Given two vectors, create a rotation matrix to rotate from A to B, in matlab
function R=fcn_RotationFromTwoVectors(A, B)
% http://math.stackexchange.com/questions/180418/calculate-rotation-matrix-to-align-vector-a-to-vector-b-in-3d
% R*v1=v2
% v1 and v2 should be column vectors and 3x1
%% Method 1
% % 1. rotation vector
% w=cross(v1,v2);
% w=w/norm(w);
% w_hat=fcn_GetSkew(w);