solutions18 - return the new coordinates using the...

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

View Full Document Right Arrow Icon
CSCI-1100 Computer Science I Rensselaer Polytechnic Institute Spring 2004 Studio 18 -- Solutions 1. 2. //PURPOSE: rotate point around the origin //PRECONDITIONS: none //POSTCONDITIONS: new coordinates for (x,y) computed by // rotating it around the origin angle degrees { int newx; // new x-coordinate int newy; // new y-coordinate // compute new coordinates based on old ones newx = x*cos(angle) + y*sin(angle); newy = -x*sin(angle) + y*cos(angle);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // return the new coordinates using // the reference parameters x = newx; y = newy; } // Translate point to a new origin void move(int &x, int &y, int orig_x, int orig_y) //PURPOSE: translate point to a new position //PRECONDITIONS: none //POSTCONDITIONS: new coordinates for (x,y) // computed by moving orig_x in the x // direction and orig_y in the y direction. { x = x + orig_x; y = y + orig_y; }...
View Full Document

This homework help was uploaded on 04/16/2008 for the course CSCI 1100 taught by Professor Hardwick during the Fall '08 term at Rensselaer Polytechnic Institute.

Ask a homework question - tutors are online