[robot]Quaternions and Rigid Transformations

来源:互联网 发布:手机 Ubuntu 编辑:程序博客网 时间:2024/05/18 13:10

四元数定义

四元数

单位四元数

unit-quaternions
unit
这一性质十分有用。
由于多次的旋转矩阵间相乘会导致误差累积,相乘次数越多误差越大。
如果利用单位四元数表示旋转矩阵,相乘后得到另一个单位四元数,这时对这个四元数进行renormalize就可以提高精度。

group

共轭

conjugate

先进性

advantages

这一表示形式在机器人学,计算机视觉有着广泛应用。

旋转表示方式的总结

summary

rigid-transformation

rigid-transformation

rigid-trans

44
product

inverting rigid transformation

inverting-rigid-Transformation

SpecialEulerianGroup

se3
se30

exercise

00
01
02
03

code

function q=quatprod(q1,q2)    % All quaternions q, q1 and q2 are represented as 1-by-4 row vectors     q=zeros(1,4);    u0 = q1(1);    u = q1(2:end);    v0 = q2(1);    v = q2(2:end);    q(1)= u0 * v0 - u * v';    temp = u0 * v + v0 * u + cross(u, v);    q(2)=temp(1);    q(3)=temp(2);    q(4)=temp(3);end

visualized rotation

% rand(3,1) generates a random 3 by one column vector. We use this u to plotu=rand(3,1)*2-1;% plot the originplot3(0,0,0,'.k')% axis settingaxis vis3daxis off% generate a random rotation matrix Rtheta = 2*pi*rand();w = rand(1,3);w = w / norm(w);k0 = cos(theta/2);k = sin(theta/2) * w;R = (k0^2 - (k*k'))*eye(3) + 2*k0*[0,-k(3),k(2);k(3),0,-k(1);-k(2), k(1),0] + 2 * (k' * k);% plot the x axis plot3([0,1],[0,0],[0,0],'r');text(1,0,0,'x');hold on;% plot the y axis plot3([0,0],[1,0],[0,0],'g');text(0,1,0,'y');hold on;% plot the z axis plot3([0,0],[0,0],[1,0],'b');text(0,0,1,'z');hold on;% plot the original vector uplot3([0,u(1)],[0,u(2)],[0,u(3)],'k--'); % black-dashed-linetext(u(1),u(2),u(3),['u','(',num2str(u(1),'%.3f'),',',num2str(u(2),'%.3f'),',',num2str(u(3),'%.3f'),')']);hold on;% apply rotation and calcuate v plot the vector after rotation vv = R * u;% plot the new vector vplot3([0,v(1)],[0,v(2)],[0,v(3)],'k:'); % black-dotted-linetext(v(1),v(2),v(3),['v','(',num2str(v(1),'%.3f'),',',num2str(v(2),'%.3f'),',',num2str(v(3),'%.3f'),')']);hold on;

result

0 0
原创粉丝点击