rotateLine

# rotateLine - %usage[vecx vecy = rotateLine(vx,vy,th th =...

This preview shows page 1. Sign up to view the full content.

function [vecx vecy] = rotateLine(vx,vy,ang) %Given a vector of x coordinates, a vector of y coordintates, and an %angle by which to rotate, write a function rotateLine that rotates the %x and y coordinates counter-clockwise around the origin by the given %angle (in degrees). rotateLine should return a vector of rotated x %coordinates and a vector of rotated y coordinates.
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %usage: [vecx vecy] = rotateLine(vx,vy,th); th = ang.*(pi./180); %converts the angle to radians A = [cos(th) -sin(th); sin(th) cos(th)]; %rotation matrix new = [vx;vy]; %new matrix is the first vector veertically concatenated with the second %vector arr = A*new; %matrix multiplication vecx = arr(1,:); %gives the x values vecy = arr(2,:); %gives the y values end...
View Full Document

## This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Tech.

Ask a homework question - tutors are online