How to find rotation matrix given two vectors in Matlab?
조회 수: 9 (최근 30일)
이전 댓글 표시
Hiii! Is there a function in Matlab which finds rotation matrix R given two vectors v1,v2 size dx1 so that Rv1=v2? If no, how can I code this? Thanks for your help
댓글 수: 1
Roger Stafford
2016년 6월 5일
Specifying v1 and v2 (of the same magnitude) does not uniquely determine a rotation matrix. Place the base of the two vectors at the origin and connect the other ends with a straight line segment. Any axis through the origin and lying in the plane of the perpendicular bisector of that line segment can be used as a rotation axis that will rotate v1 into v2.
답변 (1개)
Star Strider
2016년 6월 5일
It depends on the result you want. Simple matrix right division will give you a mapping in ‘Method #1’, but if you want to estimate the angle, you have to use a parameter estimation approach in ‘Method #2’:
R = @(a) [cos(a) -sin(a); sin(a) cos(a)]; % Parametric Rotation Matrix
v1 = rand(2, 1) % Create Data
v2 = R(1.5)*v1 % Create Data
Rm = v2/v1; % Matrix Right Division - Method #1
v2s1 = Rm*v1 % Check Result
SSECF = @(b) sum((v2 - R(b)*v1).^2); % Sum-Squared_Error Cost Function
[B,SSE] = fminsearch(SSECF, 2); % Estimate Angle - Method #2
v2s = R(B)*v1 % Check Result
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Portfolio Optimization and Asset Allocation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!