graphics - Feb 17 (1) CGI discussion - 8 puzzle - function plotting (2) vectors, rotations, etc. - translate by (a,b) : (x,y) -> (x+a, y+b) - scale by S away from (0,0) : (x,y) -> (x S, y S) - rotate by Theta around (0,0) : (x,y) -> ( x cos(T) + y sin(T), - x sin(T) + y cos(T) ) matrix multiplication [ cos(T) sin(T) ] [ x ] [ -sin(T) cos(T) ] [ y ] ============================================================ exercises: (1) Find the rotation matrix for an angle of 30 degrees. (2) Given a line segment from (10,1) to (12,2), rotate it through 30 degrees with this matrix. The steps are (a) Find the vector by subtraction (eg translate back to origin) (b) Apply rotation matrix (c) Translate start of vector back to 10,1 Answer will be line segment from (10,1) to (?,?) which makes an angle of 30 from original. ------------ (3) (In either Canvas or GD) (a) draw a house / \ / \ ------- | | | || | ------- or something like that, either lines or filled polys. Store the points, lines, polys in an array of some kind. (b) write some subroutines that will replicate this house in another place on the screen, bigger, and rotated by an arbitrary angle. Break this into pieces: - translate (x,y) to pixels - rotate about a given point - translate by a given vector - scale by a given factor about a given point (c) Can you write this a a CGI script? ---------------------------