Filter löschen
Filter löschen

I want to convert a 4x1 vector column to skew symmetric matrix in matlab

14 Ansichten (letzte 30 Tage)
for example
Q=[a;b;c;d]
S is skew symmetric which satisfies the condition -S= S transpose is that true the
S(Q) =[0 -a d -c
a 0 c b
-d -c 0 -a
c -b a 0] ?
and how do it in matlab directly ?

Akzeptierte Antwort

James Tursa
James Tursa am 19 Jul. 2018
You could just use the code you have already typed above. E.g.,
a = Q(1); b = Q(2); c = Q(3); d = Q(4);
S = [0 -a d -c
a 0 c b
-d -c 0 -a
c -b a 0];
  9 Kommentare
James Tursa
James Tursa am 20 Jul. 2018
Bearbeitet: James Tursa am 20 Jul. 2018
If you have the Aerospace Toolbox installed that has the quaternion routines, you can play around with the following code. It first demonstrates the quaternion convention that MATLAB uses in these routines. Then it constructs the associated Rodrigues formulation. For some reason, the Rodrigues construction only works at replicating the quat2dcm stuff if the scalar element is negative (hence the qc stuff). Here it is:
% Demonstrates quaternion convention, by James Tursa
function quat_convention
vecpart = @(q) reshape(q(2:4),[],1);
disp('------------------------------------------------------------------');
disp('------------------------------------------------------------------');
disp(' ');
disp('The following code demonstrates the MATLAB quaternion convention');
disp(' ');
disp('Create an arbitrary unit quaternion');
q = randn(1,4); q = q/norm(q)
disp(' ');
disp('Create an arbitrary vector');
v = randn(3,1)
disp(' ');
disp('Get corresponding direction cosine matrix');
disp('dc = quat2dcm(q)');
dc = quat2dcm(q)
disp(' ');
disp('Rotate the vector using the direction cosine matrix');
disp('dc*v')
disp(dc*v);
disp(' ');
disp('Rotate the vector using the quaternion');
disp('conj(q)*v*q')
disp(vecpart(quatmultiply(quatconj(q),quatmultiply([0 v'],q))));
disp(' ');
disp('Differrence in rotated vectors (should be small)');
dcv = dc*v;
qcvq = vecpart(quatmultiply(quatconj(q),quatmultiply([0 v'],q)));
disp(max(abs(dcv(:)-qcvq(:))));
disp(' ');
disp('Quaternion convention is scalar first and successive rotations are RIGHT multiplies');
disp(' ');
disp('------------------------------------------------------------------');
disp(' ');
disp('Rodrigues Rotation Formula');
disp(' ');
if( q(1) < 0 )
qc = q;
else
qc = -q;
end
disp('cos(theta)');
c = cos(acos(qc(1))*2)
disp(' ');
disp('sin(theta)');
s = sin(asin(norm(qc(2:4)))*2)
disp(' ');
disp('theta (deg)');
disp(atan2(s,c)*180/pi);
disp(' ');
disp('Rotation axis');
k = qc(2:4)/norm(qc(2:4))
disp(' ');
disp('Skew symmetric matrix');
K = [0 -k(3) k(2); k(3) 0 -k(1); -k(2) k(1) 0]
disp(' ');
disp('R = eye(3) + s*K + (1-c)*K^2');
R = eye(3) + s*K + (1-c)*K^2
disp(' ');
disp('Differrence in dc matrices (should be small)');
disp(max(abs(R(:)-dc(:))));
end
Waleed new
Waleed new am 21 Jul. 2018
Thank you very much I appreciate your consideration time.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by