CS380: Computer Graphics 2D Imaging and Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

Similar documents
S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

CSC 470 Computer Graphics

Computer Graphics. Chapter 7 2D Geometric Transformations

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

Screen Space & World Space

C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008


Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics Geometric Transformations

CS380: Computer Graphics Basic OpenGL Structure. Sung-Eui Yoon ( 윤성의 ) Course URL:

OpenGL/GLUT Intro. Week 1, Fri Jan 12

CS380: Computer Graphics Screen Space & World Space. Sung-Eui Yoon ( 윤성의 ) Course URL:

Transformations. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Objectives. transformation. General Transformations. Affine Transformations. Notation. Pipeline Implementation. Introduce standard transformations

Order of Transformations

Transforms 1 Christian Miller CS Fall 2011

Computer Graphics CS 543 Lecture 5 (Part 2) Implementing Transformations

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,

Precept 2 Aleksey Boyko February 18, 2011

Lecture 4: Transformations and Matrices. CSE Computer Graphics (Fall 2010)

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

C OMPUTER G RAPHICS Thursday

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009

CS D Transformation. Junqiao Zhao 赵君峤

Fall CSCI 420: Computer Graphics. 2.2 Transformations. Hao Li.

Lecture 2 2D transformations Introduction to OpenGL

Hierarchical Modeling. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Lecture 4 of 41. Lab 1a: OpenGL Basics

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

Lecture 2 CISC440/640 Spring Department of Computer and Information Science

CS 4204 Computer Graphics

Review of Thursday. xa + yb xc + yd

Translations. Geometric Image Transformations. Two-Dimensional Geometric Transforms. Groups and Composition

Modeling Objects by Polygonal Approximations. Linear and Affine Transformations (Maps)

Transformations. CSCI 420 Computer Graphics Lecture 4

Translation. 3D Transformations. Rotation about z axis. Scaling. CS 4620 Lecture 8. 3 Cornell CS4620 Fall 2009!Lecture 8

Classic Rendering Pipeline

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

CS 428: Fall Introduction to. Transformations in OpenGL + hierarchical modeling. Andrew Nealen, Rutgers, /21/2009 1

CS380: Computer Graphics Viewing Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

Interacting with a 3D World

Computer graphics MN1

Chapter 3 - Basic Mathematics for 3D Computer Graphics

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

Better Interactive Programs

Computer Science 336 Fall 2017 Homework 2

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

6.837 LECTURE 7. Lecture 7 Outline Fall '01. Lecture Fall '01

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

Interaction Computer Graphics I Lecture 3

Transformation Pipeline

Introduction to 3D Graphics with OpenGL. Z-Buffer Hidden Surface Removal. Binghamton University. EngiNet. Thomas J. Watson

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

2D Transforms. Lecture 4 CISC440/640 Spring Department of Computer and Information Science

Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

Transformations Computer Graphics I Lecture 4

More on Coordinate Systems. Coordinate Systems (3) Coordinate Systems (2) Coordinate Systems (5) Coordinate Systems (4) 9/15/2011

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

Reading. Hierarchical Modeling. Symbols and instances. Required: Angel, sections , 9.8. Optional:

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

Modeling with Transformations

Introduction to OpenGL

OpenGL: Setup 3D World

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

Interaction. CSCI 480 Computer Graphics Lecture 3

Describe the Orthographic and Perspective projections. How do we combine together transform matrices?

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

Hidden Surface Removal. 3D Graphics with OpenGL. Back-Face Culling

by modifying the glutinitwindowsize() function you can change the screen size to whatever you please.

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

Imaging and 2D Transforms

Lecture 5b. Transformation

Computer Graphics. Bing-Yu Chen National Taiwan University

Luiz Fernando Martha André Pereira

Transformations Computer Graphics I Lecture 4

Input and Interaction. 1. Interaction. Chapter 3. Introduction: - We now turn to the development of interactive graphics programs.

Affine Transformations in 3D

Lecture 5 2D Transformation

Computer Vision Projective Geometry and Calibration. Pinhole cameras

Using OpenGL with CUDA

Computer Graphics: Geometric Transformations

Introduction to Computer Graphics with OpenGL/GLUT

Graphics and Visualization

Computer graphics Labs: OpenGL (1/3) Geometric transformations and projections

GL_MODELVIEW transformation

OpenGL: A Practical Introduction. (thanks, Mark Livingston!)

Computer Graphics Introduction to OpenGL

CS 4204 Computer Graphics

OpenGL refresher. Advanced Computer Graphics 2012

2D transformations: An introduction to the maths behind computer graphics

3D Transformations World Window to Viewport Transformation Week 2, Lecture 4

Two possible ways to specify transformations. Each part of the object is transformed independently relative to the origin

Rendering Pipeline/ OpenGL

Transcription:

CS380: Computer Graphics 2D Imaging and Transformation Sung-Eui Yoon ( 윤성의 ) Course URL: http://sglab.kaist.ac.kr/~sungeui/cg

Class Objectives Write down simple 2D transformation matrixes Understand the homogeneous coordinates and its benefits Know OpenGL-transformation related API Implement idle-based animation method Related chapter in the book 2.2 2D Transformation 2

2D Geometric Transforms Functions to map points from one place to another Geometric transforms can be applied to Drawing primitives (points, lines, conics, triangles) Pixel coordinates of an image Demo 3

Translation Translations have the following form: x' = x + t x y' = y + t y ' x ' y = x y + t t x y inverse function: undoes the translation: x = x' - t x y = y' - t y identity: leaves every point unchanged x' = x + 0 y' = y + 0 4

2D Rotations Another group - rotation about the origin: 5

Rotations in Series We want to rotate the object 30 degree and, then, 60 degree x y ' ' = cos(60) sin(60) x y ' ' - sin(60) cos(30) cos(60) sin(30) cos(90) = sin(90) - sin(90) x cos(90) y - sin(30) x cos(30) y We can merge multiple rotations into one rotation matrix 6

Euclidean Transforms Euclidean Group Translations + rotations Rigid body transforms Properties: Preserve distances Preserve angles How do you represent these functions? 7

Problems with this Form Translation and rotation considered separately Typically we perform a series of rotations and translations to place objects in world space It s inconvenient and inefficient in the previous form Inverse transform involves multiple steps How can we address it? How can we represent the translation as a matrix multiplication? 8

Homogeneous Coordinates Consider our 2D plane as a subspace within 3D (x, y) (x, y, z) 9

Matrix Multiplications and Homogeneous Coordinates Can use any planar subspace that does not contain the origin Assume our 2D space lies on the 3D plane z = 1 Now we can express all Euclidean transforms in matrix form: 10

11 S is a scaling factor Scaling = 1 y x s s y x ' ' 1 0 0 0 0 0 0 1

Example: World Space to NDC x n ( 1) 1 ( 1) = x w (w.l) w.r w.l 1 w.t x n = x w (w.l) 2 1 w.r w.l -1 w.b xn = Ax w + B -1 w.l x n? x w 1 w.r A = w.r 2 w.l, B = w.r w.r + w.l w.l 12

Example: World Space to NDC Now, it can be accomplished via a matrix multiplication Also, conceptually simple x y 1 n n = 2 w.r w.l 0 0 0 2 w.t w.b 0 w.r+ w.l w.r w.l w.t+ w.b w.t w.b 1 x y 1 w w 13

Shearing Push things sideways Shear along x-axis Shear along y-axis 14

Reflection Reflection about x-axis Reflection about y-axis 15

Composition of 2D Transformation Quite common to apply more than one transformations to an object E.g., v 2 =Sv 1, v 3 =Rv 2, where S and R are scaling and Rotation matrix Then, we can use the following representation: v 3 =R(Sv 1 ) or v 3 =(RS)v 1 why? 16

Transformation Order Order of transforms is very important Why? 17

Affine Transformations Transformed points (x, y ) have the following form: ' x a11 a12 a13 x ' = y a21 a22 a23 y 1 0 0 1 1 Combinations of translations, rotations, scaling, reflection, shears Properties Parallel lines are preserved Finite points map to finite points 18

Rigid-Body Transforms in OpenGL gltranslate (tx, ty, tz); glrotate (angleindegrees, axisx, axisy, axisz); glscale(sx, sy, sz); OpenGL uses matrix format internally. - glm (Ver. 4.3) stands for OpenGL Mathematics 19

OpenGL Example Rectangle Animation (double.c) Demo 20

Main Display Function void display(void) { glclear(gl_color_buffer_bit); glpushmatrix(); glrotatef(spin, 0.0, 0.0, 1.0); glcolor3f(1.0, 1.0, 1.0); glrectf(-25.0, -25.0, 25.0, 25.0); glpopmatrix(); } glutswapbuffers(); 21

Frame Buffer Contains an image for the final visualization Color buffer, depth buffer, etc. 22 Buffer initialization glclear(gl_color_buffer_bit); glclearcolor (..); Buffer creation glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); Buffer swap glutswapbuffers();

Matrix Stacks OpenGL maintains matrix stacks Provides pop and push operations Convenient for transformation operations glmatrixmode() sets the current stack GL_MODELVIEW, GL_PROJECTION, or GL_TEXTURE glpushmatrix() and glpopmatrix() are used to manipulate the stacks 23

OpenGL Matrix Operations gltranslate(tx, ty, tz) glrotate(angleindegrees, axisx, axisy, axisz) glmultmatrix(*arrayof16incolumnmajororder) Concatenate with the current matrix glloadmatrix (*arrayof16incolumnmajororder) glloadidentity() Overwrite the current matrix 24

Matrix Specification in OpenGL Column-major ordering m1 m2 M = m3 m4 m m m m 5 6 7 8 m m m m 9 10 11 12 m m m m 13 14 15 16 Reverse to the typical C-convention (e.g., m [i][j] : row i & column j) Better to declare m [16] Also, glloadtransportmatrix*() & glmulttransposematrix*() are available 25

Animation It consists of redraw and swap It s desirable to provide more than 30 frames per second (fps) for interactive applications We will look at an animation example based on idle-callback function 26

Idle-based Animation 27 void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: if (state == GLUT_DOWN) glutidlefunc (spindisplay); break; case GLUT_RIGHT_BUTTON: if (state == GLUT_DOWN) glutidlefunc (NULL); break; } } void spindisplay(void) { spin = spin + 2.0; if (spin > 360.0) spin = spin - 360.0; glutpostredisplay(); }

Class Objectives were: Write down simple 2D transformation matrixes Understand the homogeneous coordinates and its benefits Know OpenGL-transformation related API Implement idle-based animation method 28

Homework Go over the next lecture slides before the class Watch 2 SIGGRAPH videos and submit your summaries before every Tue. class Submit online Just one paragraph for each summary 29 Example: Title: XXX XXXX XXXX Abstract: this video is about accelerating the performance of ray tracing. To achieve its goal, they design a new technique for reordering rays, since by doing so, they can improve the ray coherence and thus improve the overall performance.

Any Questions? Come up with one question on what we have discussed in the class and submit at the end of the class 1 for already answered questions 2 for typical questions 3 for questions with thoughts or that surprised me Submit at least four times during the whole semester 30

Next Time 3D transformations 31