[zz] 直角座標系的平移和旋轉

來源:互聯網
上載者:User

直角座標系的平移和旋轉:

http://www.oschina.net/question/565065_67286

http://xinxing124.blog.163.com/blog/static/30170195201162815851981/

點評:x, y軸雖然只是一種標號,但是x軸做縱軸,y軸做橫軸,始終感覺彆扭!

 

座標系轉換:

http://blog.sina.com.cn/s/blog_429a1dbf010009vg.html

View Code

% Matlab File: Tcoord.m% Transformation for different coordnate systemsA=load('p1.dat');   % A is a matrix of n*3. Each row is the three components% of a point in the original coordinate system.T=load('T1.dat');   % T is a matrix of 3*4. The first three column vectors% denote the three axis vectors of the new coordinate system. The fourth column% is the position of the new origin.n=size(A,1); % Rows of Matrix A.At=repmat(T(:,4)',n,1);Y=T(:,1:3)'*(A-At)';   % the new coordinate values. 3*nfprintf(1,'The new coordinate values are stored in the file of p2.dat\n');fid=fopen('p2.dat','w+');fprintf(fid,'%12.8f %12.8f %12.8f\n',Y); % n*3fclose(fid);

 

座標變換之MATLAB函數分享:

http://shiaohoo.blogbus.com/logs/53777599.html

View Code

function B = TransCoord3( A ) %   功能:三維座標 -> 二維座標 x_axis = A(2,:) - A(1,:); y_axis = A(3,:) - A(1,:); z_axis = cross( x_axis, y_axis ); y_axis = cross( x_axis, z_axis );  x_axis = x_axis/norm( x_axis ); y_axis = y_axis/norm( y_axis ); z_axis = z_axis/norm( z_axis ); TransMatrix = [x_axis;y_axis;z_axis]; len = length(A); for i = 1:len     R_vector = A(i,:) - A(1,:);     B(i,:) = R_vector/TransMatrix; end end
View Code

function [A,afa] = TransCoord( A, Center, Angle) %   功能:二維座標變換,平移和旋轉 len = length(A); for i = 1:len     A(i, 1) = A(i, 1) - Center(1);     A(i, 2) = A(i, 2) - Center(2); end for i = 1:len     R = sqrt( A(i, 1)*A(i, 1)+A(i, 2)*A(i, 2) );     k = A(i, 2)/A(i,1);     if A(i,1) < 0         afa = atan(k) + pi;     elseif A(i,1) >0         afa = atan(k);     else        afa = pi/2;    end    afa = afa + Angle;    A(i, 1) = R*cos(afa);     A(i, 2) = R*sin(afa); end end

代碼給我很大啟發!但是:“afa=afa+Angle” 應該為“afa=afa-Angle”吧?

 

座標系的旋轉變換:

http://blog.sina.com.cn/s/blog_5f853eb10100zx2z.html

座標旋轉變換公式的推導:

http://blog.csdn.net/Tangyongkang/article/details/5484636

上面2篇理論講的很清楚!

 

座標旋轉:

http://blog.163.com/yhtian619@126/blog/static/1625512802010717112643721/

公式好像有問題!

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.