我想旋轉在MATLAB的載體,並檢查旋轉一個原始的和之間的角度後右:旋轉在Matlab的載體,並檢查角度
v = [-1 -12 5]; %arbitrarily rotated vector
theta =30; %arbitrary angle to rotate with
R = [cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1]; %rotate around Z axis
vR = R*v'; %calculate the new vector
angle=atan2d(norm(cross(v,vR)),dot(v,vR));
%the angle between the old and rotated vector, also do normalisation before.
%atan2d is better to resolve extremely small angle
angle =
27.6588
%THIS is the problem
正如你可以看到我用30°旋轉但是在檢查時不同。
打電話給你最後一次變量'角度'是不是一個好主意......(內置matlab函數) – bla
這只是一個演示,這不是問題在這裏 – Bolee
有趣的是'rad2deg(subspace(v(:),vR(:))''會給出相同的答案 – bla