[Zz] Translation and rotation of the Cartesian coordinate system

Source: Internet
Author: User

Translation and rotation of the Cartesian coordinate system:

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

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

Comments: although the X and Y axes are only a label, they always feel awkward when the X axis is an vertical axis and the Y axis is a horizontal axis!

 

Coordinate System Conversion:

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 Functions of coordinate transformation:

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

View code

Function B = transcoord3 (a) % function: 3D coordinate-> 2D coordinate 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
View code

Function [A, AFA] = transcoord (A, center, angle) % function: 2D coordinate transformation, translation and rotation 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

The Code has inspired me a lot! But should "AFA = AFA + angle" be "AFA = afa-angle?

 

Rotation Transformation of the coordinate system:

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

Derivation of coordinate rotation transformation formula:

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

The above two theories are very clear!

 

Coordinate rotation:

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

There seems to be a problem with the formula!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.