Transformations void draw House gl BeginGLQUADS vertex0 0
Transformations void draw. House() { gl. Begin(GL_QUADS); vertex(0, 0); vertex(0, 1); vertex(1, 0); gl. End(); // …. Lots more stuff } void vertex(int x, int y) { gl. Vertex 2 d(x, y); } void main() { draw. House(); }
• Translate then rotate then translate then scale? • S(R(p+T)+T) • Not very clean or compressible, homogenous coordinates are a clever trick to turn this into: • TRTS*p = M*p matrix
Point at infinity
Q on 2 D transforms (A) (B) (C) (D)
http: //www. cs. brown. edu/exploratories/free. Software/repository/edu/brown/cs/exploratories/applets/transformation. Game/transformation_game_java_browser. html
2. What is the matrix necessary to perform the following 2 D transformation? (You don’t need to actually solve the math, just set up far enough that I would get an actual matrix result if the math was completed. )
Q on 3 D rotation Rotate 30 deg around this axis? (A) [T(10)] [Rx(45)] [T(-10)] p (B) [Rz(45)] [Rx(30)] [Rz(-45)] p (C) [Rx(45)] [Rz(30)] [Rx(-45)] p (D) [Ry(45)] [Rx(30)] [Ry(-45)] p (E) Don’t Know Rotation axis in XY plane
Right multiply matrices • Open. GL right multiplies the matrix • Must specify transformations in reverse order of effect
Suppose we have a minimal graphics language called Simple. GL which does not support a full range of commands. It has only the following: SGL_Translate. X 1() = gl. Translate(1, 0) SGL_Translate. X 2() = gl. Translate(2, 0) SGL_Translate. Y() = gl. Translate(0, 1) SGL_Push. Matrix() = gl. Push. Matrix() SGL_Pop. Matrix() = gl. Pop. Matrix() SGL_Draw. Box() ={gl. Begin(); gl. Vertex(0, 0); gl. Vertex(0, 1); gl. Vertex(1, 1), gl. Vertex(1, 0); gl. End()} Write out the shortest program, using this library, that will produce the image above.
- Slides: 24