博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

[zz] 直角坐标系的平移和旋转

Posted on 2013-04-08 11:12  编著人  阅读(2995)  评论(0编辑  收藏  举报

直角坐标系的平移和旋转:

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 systems
A=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*n
fprintf(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*3
fclose(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/

公式好像有问题!