Created
September 29, 2016 15:44
-
-
Save Exchizz/a1633f23f05117c1b93fc0828092fbdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear; clc; | |
x1 = 100; | |
y1 = 0; | |
theta = 0; | |
matrix1 = transform(x1,y1,deg2rad(theta)); | |
x2 = 0; | |
y2 = 200; | |
theta = 0; | |
matrix2 = transform(x2, y2,deg2rad(theta)); | |
x3 = 0; | |
y3 = 0; | |
theta = 360-30; | |
%theta=0; | |
matrix3 = transform(x3,y3,deg2rad(theta)); | |
x4 = 200; | |
y4 = 500; | |
theta = 60; | |
%theta=0; | |
matrix4 = transform(x4,y4,deg2rad(theta)); | |
endpos = matrix1*matrix2*matrix3*matrix4; | |
endpos2 = matrix4*matrix3*matrix2*matrix1; | |
xstart = 0; | |
ystart = 0; | |
theta = 0; | |
start = transform(xstart,ystart,deg2rad(theta)); | |
pos1 = start*matrix1; | |
pos2 = pos1*matrix2; | |
pos3 = pos2*matrix3; | |
pos4 = pos3*matrix4; | |
figure | |
hold on | |
xlim( [-50 800] ); | |
ylim( [-50 800] ); | |
plot([xstart, pos1(1,3)],[ystart, pos1(2,3)]) | |
plot([ pos1(1,3), pos2(1,3)],[ pos1(2,3), pos2(2,3) ]) | |
plot([ pos2(1,3), pos3(1,3)],[ pos2(2,3), pos3(2,3) ]) | |
plot([ pos3(1,3), pos4(1,3)],[ pos3(2,3), pos4(2,3) ]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
function [ matrix ] = transform( x, y, theta )
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
matrix = [cos(theta) -sin(theta) x; sin(theta) cos(theta) y; 0 0 1];
end