我在MATLAB中遇到了一些非常奇怪的东西,我无法弄清楚。MATLAB解决()不能解决特定值的三角矩阵
我有两组我想要找到欧拉角的物体坐标。我设置了旋转矩阵R
和符号卡丹角矩阵R_cardan
来解决角度。对于第一组,我可以简单地做solve(R==R_cardan)
,但是当我使用第二组时,它不起作用。返回的解决方案是空的。
这可能是什么原因造成的?这里是测试代码。
clc;clear;close all;
%% For some reason R2 does not want to give a solution
% Find rotation matrix to transform from origin to local reference frame
ex = [ 0.768 0.024 0.640].';
ey = [-0.424 0.768 0.480].';
ez = [-0.480 -0.640 0.600].';
ex2 = [ 0.612372 0.353553 -0.707107].';
ey2 = [0.280330 0.739199 0.612372].';
ez2 = [0.739199 -0.573223 0.353553].';
R = eye(3)*[ex ey ez]
R2 = eye(3)*[ex2 ey2 ez2]
% Symbolic variables
syms beta alpha gamma
% Set up rotatin matrices
R_alpha = [cos(alpha) -sin(alpha) 0; sin(alpha) cos(alpha) 0; 0 0 1]
R_beta = [cos(beta) 0 sin(beta); 0 1 0; -sin(beta) 0 cos(beta)]
R_gamma = [1 0 0; 0 cos(gamma) -sin(gamma); 0 sin(gamma) cos(gamma)]
% Find symbolic rotation matrix
R_cardan = R_alpha*R_beta*R_gamma
[alpha, beta, gamma] = find_angles(R,R_cardan)
[alpha, beta, gamma] = find_angles(R2,R_cardan) %fails because solution is empty
function [alpha, beta, gamma] = find_angles(R,R_cardan)
% Solve for the angles
sol = solve(R == R_cardan);
alpha = double(sol.alpha(1));
beta = double(sol.beta(1));
gamma = double(sol.gamma(1));
end
我目前的解决方案是手动计算角度是好的,但我对上述方法有什么问题感兴趣。
非常感谢您。这是一个非常好但很复杂的解决方案。然而,了解解决问题的特殊方式绝对值得。 – Ortix92