How can I rotate, scale and transform x y z coordination.

3 views (last 30 days)
I want to do coding for following equations. How i do it using mat lab. Please help me.

Accepted Answer

KSSV
KSSV on 4 Oct 2016
clc; clear all ;
% square coordinates
Sx = [0 1 1 0 0] ;
Sy = [0 0 1 1 0] ;
S = [Sx' Sy'] ;
% Rotation
th = linspace(0,2*pi) ;
for i = 1:length(th)
R = [cos(th(i)) sin(th(i)) ; -sin(th(i)) cos(th(i))] ;
Sr = S*R ;
plot(S(:,1),S(:,2),'b')
hold on
plot(Sr(:,1),Sr(:,2),'r')
hold off
drawnow
pause(0.1)
end
  3 Comments
KSSV
KSSV on 4 Oct 2016
Edited: KSSV on 4 Oct 2016
Procedure would be same, but for 3D you need to extend R, for 3D R would be 3x3.
Refer the following for R matrice sin 3D.
https://en.wikipedia.org/wiki/Rotation_matrix
Eg.
R = [1 0 0 ; 0 cos(th) -sin(th) ; 0 sin(th) cos(th)] ;
Dumi
Dumi on 4 Oct 2016
Thank you again Dr . Siva Srinivas. I dont want 3D. sorry it is mistake. I only need x y coordinate. Is there answer for all 3 equations which I have attach. Thank you loads. I will try these. Thank you again.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!