Order of Transformations

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

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

CSC 470 Computer Graphics

CS D Transformation. Junqiao Zhao 赵君峤

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

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

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

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

CS 4204 Computer Graphics

Introduction to Computer Graphics with WebGL

C OMPUTER G RAPHICS Thursday

Computer graphics MN1

Interaction Computer Graphics I Lecture 3

Interaction. CSCI 480 Computer Graphics Lecture 3

Transformation, Input and Interaction. Hanyang University

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

Computer graphics MN1

Computer Viewing Computer Graphics I, Fall 2008

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

CS452/552; EE465/505. Transformations

Precept 2 Aleksey Boyko February 18, 2011

Vertex Buffer Objects and Transformations Week 4

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

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

Computer Graphics. Chapter 7 2D Geometric Transformations

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

Transformations. Overview. Standard Transformations. David Carr Fundamentals of Computer Graphics Spring 2004 Based on Slides by E.

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

Transformations. Prof. George Wolberg Dept. of Computer Science City College of New York

Transformations. Standard Transformations. David Carr Virtual Environments, Fundamentals Spring 2005 Based on Slides by E. Angel

2/3/16. Interaction. Triangles (Clarification) Choice of Programming Language. Buffer Objects. The CPU-GPU bus. CSCI 420 Computer Graphics Lecture 3

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

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

Interaction. CSCI 420 Computer Graphics Lecture 3

Computer graphics MN1

1 (Practice 1) Introduction to OpenGL

Introduction to Computer Graphics with WebGL

Visualizing Molecular Dynamics

Introduction to OpenGL

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

7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky

Computer Graphics. Chapter 10 Three-Dimensional Viewing

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

Fundamental Types of Viewing

Scientific Visualization Basics


Computer Graphics. Transformations. CSC 470 Computer Graphics 1

CS354 Computer Graphics Viewing and Modeling

3D Viewing. With acknowledge to: Ed Angel. Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

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

Transformations. CSCI 420 Computer Graphics Lecture 4

COMP Computer Graphics and Image Processing. 5: Viewing 1: The camera. In part 1 of our study of Viewing, we ll look at ˆʹ U ˆ ʹ F ˆʹ S

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

Lecture 3. Understanding of OPenGL programming

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

Matrix-Rechnung I ' z =... Universität Frankfurt

COMP3421. Introduction to 3D Graphics

Project Sketchpad. Ivan Sutherland (MIT 1963) established the basic interactive paradigm that characterizes interactive computer graphics:

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

Outline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process

Graphics and Computation Introduction to OpenGL

OpenGL/GLUT Intro. Week 1, Fri Jan 12

Transformations Computer Graphics I Lecture 4

Using OpenGL with CUDA

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

20 GLuint objects; 36 Scale += 0.1; 37 break; 38 case GLUT_KEY_DOWN:

FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4. C++ - OpenGL

COMP3421. Introduction to 3D Graphics

1 /* 4 C:\opencv\build\include. 6 C:\opencv\build\x86\vc10\lib

SOURCES AND URLS BIBLIOGRAPHY AND REFERENCES

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

Overview. Viewing and perspectives. Planar Geometric Projections. Classical Viewing. Classical views Computer viewing Perspective normalization

Programming with OpenGL Part 3: Three Dimensions

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

Transformations. CSCI 420 Computer Graphics Lecture 5

Transformations. OpenGL Transformations. 4x4 Model-view Matrix (this lecture) OpenGL Transformation Matrices. 4x4 Projection Matrix (next lecture)

3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. x y z. x y z. glvertex3f(x, y,z);

COMP3421. Introduction to 3D Graphics

Transformation Pipeline

Transformations Computer Graphics I Lecture 4

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

GL_MODELVIEW transformation

Transformations (Rotations with Quaternions) October 24, 2005

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

1) Program to display a set of values {fij} as a rectangular mesh. #include<gl/glut.h> #define maxx 20. #define maxy 20. #define dx 15.

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

QUESTION 1 [10] 2 COS340-A October/November 2009

Viewing Transformation

yahoo.com

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

CSCI E-74. Simulation and Gaming

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

GLUT Tutorial. John Tsiombikas (Nuclear / The Lab Demos) May 6, Introduction to GLUT (OpenGL Utility Toolkit)

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

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

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

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

Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1

Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics Geometric Transformations

Transcription:

Order of Transformations Because the same transformation is applied to many vertices, the cost of forming a matrix M=ABCD is not significant compared to the cost of computing Mp for many vertices p Note that matrix on the right is the first applied Mathematically, the following are equivalent p = ABCp = A(B(Cp)) Note many references use column matrices to represent points. In terms of column matrices p T = p T C T B T A T

General Rotation About the Origin A rotation by q about an arbitrary axis can be decomposed into the concatenation of rotations about the x, y, and z axes y q x v R(q) = R z (q z ) R y (q y ) R x (q x ) z q x q y q z are called the Euler angles

Rotation About a Fixed Point other than the Origin Move fixed point to origin Rotate Move fixed point back M = T(p f ) R(q) T(-p f )

Instancing In modeling, we often start with a simple object centered at the origin, oriented with the axis, and at a standard size We apply an instance transformation to its vertices to Scale Orient Locate

OpenGL Matrices In OpenGL matrices are part of the state Multiple types Model-View (GL_MODELVIEW) Projection (GL_PROJECTION) Select which to manipulated by glmatrixmode(gl_modelview); glmatrixmode(gl_projection);

Current Transformation Matrix (CTM) Conceptually there is a 4 x 4 homogeneous coordinate matrix, the current transformation matrix (CTM) that is part of the state and is applied to all vertices that pass down the pipeline The CTM is defined in the user program and loaded into a transformation unit p C p =Cp vertices CTM vertices

CTM operations The CTM can be altered either by loading a new CTM or by post-mutiplication Load an identity matrix: C I Load an arbitrary matrix: C M Load a translation matrix: C T Load a rotation matrix: C R Load a scaling matrix: C S Post-multiply by an arbitrary matrix: C CM Post-multiply by a translation matrix: C CT Post-multiply by a rotation matrix: C C R Post-multiply by a scaling matrix: C C S

Rotation about a Fixed Point Start with identity matrix: C I Move fixed point to origin: C CT Rotate: C CR Move fixed point back: C CT -1 Result: C = TR T 1 which is backwards. This result is a consequence of doing postmultiplications. Let s try again.

Reversing the Order We want C = T 1 R T so we must do the operations in the following order C I C CT -1 C CR C CT Each operation corresponds to one function call in the program. Note that the last operation specified is the first executed in the program

CTM in OpenGL OpenGL has a model-view and a projection matrix in the pipeline which are concatenated together to form the CTM Can manipulate each by first setting the correct matrix mode

Rotation, Translation, Scaling Load an identity matrix: glloadidentity() Multiply on right: glrotatef(theta, vx, vy, vz) theta in degrees, (vx, vy, vz) define axis of rotation gltranslatef(dx, dy, dz) glscalef( sx, sy, sz) Each has a float (f) and double (d) format (glscaled)

Example Rotation about z axis by 30 degrees with a fixed point of (1.0, 2.0, 3.0) glmatrixmode(gl_modelview); glloadidentity(); gltranslatef(1.0, 2.0, 3.0); glrotatef(30.0, 0.0, 0.0, 1.0); gltranslatef(-1.0, -2.0, -3.0); Remember that last matrix specified in the program is the first applied

Using Transformations Example: use idle function to rotate a cube and mouse function to change direction of rotation Start with a program that draws a cube Centered at origin Sides aligned with axes

main.c void main(int argc, char **argv) { glutinit(&argc, argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(500, 500); glutcreatewindow("colorcube"); glutreshapefunc(myreshape); glutdisplayfunc(display); glutidlefunc(spincube); glutmousefunc(mouse); glenable(gl_depth_test); glutmainloop(); }

Idle and Mouse callbacks void spincube() { theta[axis] += 2.0; if( theta[axis] > 360.0 ) theta[axis] -= 360.0; glutpostredisplay(); } void mouse(int btn, int state, int x, int y) { if(btn==glut_left_button && state == GLUT_DOWN) axis = 0; if(btn==glut_middle_button && state == GLUT_DOWN) axis = 1; if(btn==glut_right_button && state == GLUT_DOWN) axis = 2; }

Display callback void display() { glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glloadidentity(); glrotatef(theta[0], 1.0, 0.0, 0.0); glrotatef(theta[1], 0.0, 1.0, 0.0); glrotatef(theta[2], 0.0, 0.0, 1.0); colorcube(); glutswapbuffers(); } Note that because of fixed from of callbacks, variables such as theta and axis must be defined as globals Camera information is in standard reshape callback

Using the Model-view Matrix In OpenGL the model-view matrix is used to Position the camera Can be done by rotations and translations but is often easier to use glulookat glulookat(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz ) Build models of objects The projection matrix is used to define the view volume and to select a camera lens