Computer Graphics. 2D Transforma5ons. Review Vertex Transforma5ons 2/3/15. adjust the zoom. posi+on the camera. posi+on the model

Similar documents
1/29/13. Computer Graphics. Transformations. Simple Transformations

Computer Graphics. 2D transformations. Transforma3ons in computer graphics. Overview. Basic classes of geometric transforma3ons

Today s class. Geometric objects and transformations. Informationsteknologi. Wednesday, November 7, 2007 Computer Graphics - Class 5 1

4. Two Dimensional Transformations

CSE328 Fundamentals of Computer Graphics: Theory, Algorithms, and Applications

Image Warping : Computational Photography Alexei Efros, CMU, Fall Some slides from Steve Seitz

Image Warping. Some slides from Steve Seitz

Two Dimensional Viewing

CS F-07 Objects in 2D 1

3D Coordinates & Transformations

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

CS Computer Graphics: Transformations & The Synthetic Camera

Viewing. Cliff Lindsay, Ph.D. WPI

Scene Graphs & Modeling Transformations COS 426

1. We ll look at: Types of geometrical transformation. Vector and matrix representations

Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University

3D graphics rendering pipeline (1) 3D graphics rendering pipeline (3) 3D graphics rendering pipeline (2) 8/29/11

Homogeneous Coordinates

Image Warping. Many slides from Alyosha Efros + Steve Seitz. Photo by Sean Carroll

3D Viewing and Projec5on. Taking Pictures with a Real Camera. Steps: Graphics does the same thing for rendering an image for 3D geometric objects

Computer Graphics. Geometric Transformations

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Computer Graphics. Geometric Transformations

6. Modelview Transformations

CS 335 Graphics and Multimedia. Geometric Warping

What and Why Transformations?

How is project #1 going?

CAP5415-Computer Vision Lecture 8-Mo8on Models, Feature Tracking, and Alignment. Ulas Bagci

Editing and Transformation

Ligh%ng in OpenGL. The Phong Illumina%on Model. Vector Background

CS559: Computer Graphics

Math 26: Fall (part 1) The Unit Circle: Cosine and Sine (Evaluating Cosine and Sine, and The Pythagorean Identity)

Modeling Transformations

Modeling Transformations

Interactive Computer Graphics. Warping and morphing. Warping and Morphing. Warping and Morphing. Lecture 14+15: Warping and Morphing. What is.

2D transformations and homogeneous coordinates

Image Warping. Some slides from Steve Seitz

Warping, Morphing and Mosaics

Modeling Transformations Revisited

What does OpenGL do?

PreCalculus Unit 1: Unit Circle Trig Quiz Review (Day 9)

CSCI-4530/6530 Advanced Computer Graphics

Transformations II. Arbitrary 3D Rotation. What is its inverse? What is its transpose? Can we constructively elucidate this relationship?

High Dimensional Rendering in OpenGL

CSCI-4530/6530 Advanced Computer Graphics

Introduction to Homogeneous Transformations & Robot Kinematics

Quiz #2 Review. Transformations & Matrices. Quiz #2 Review. Quiz #2 Review. Example: Change the time on y the clock. Example: Move clock hands

[ ] [ ] Orthogonal Transformation of Cartesian Coordinates in 2D & 3D. φ = cos 1 1/ φ = tan 1 [ 2 /1]

Image Metamorphosis By Affine Transformations

Supplementary Material: The Rotation Matrix

Modeling Transformations

Image Warping CSE399b, Spring 07 Computer Vision

Modeling Transformations

General Purpose Computation (CAD/CAM/CAE) on the GPU (a.k.a. Topics in Manufacturing)

(x, y) (ρ, θ) ρ θ. Polar Coordinates. Cartesian Coordinates

Modeling Transformations

To Do. Course Outline. Course Outline. Goals. Motivation. Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1

Determining the 2d transformation that brings one image into alignment (registers it) with another. And

Honors Advanced Math More on Determinants, Transformations and Systems 14 May 2013

GRAPHING QUADRATIC FUNCTIONS IN STANDARD FORM

3D Geometry and Camera Calibration

GEOMETRIC TRANSFORMATIONS AND VIEWING

Introduction to Homogeneous Transformations & Robot Kinematics

13.2. General Angles and Radian Measure. What you should learn

Network Coding: Theory and Applica7ons

We can conclude that if f is differentiable in an interval containing a, then. f(x) L(x) = f(a) + f (a)(x a).

BUMP MAPPING. Programação 3D Simulação e Jogos Prof. João A. Madeiras Pereira MEIC-A/IST

Image Warping (Szeliski Sec 2.1.2)

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6

Matrix Transformations. Affine Transformations

10. ROTATIONS (I) I Main Topics

CS 157: Assignment 6

STRAND I: Geometry and Trigonometry. UNIT 37 Further Transformations: Student Text Contents. Section Reflections. 37.

Lecture 4: Viewing. Topics:

Sample Problems for Quiz # 3

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

Polar Coordinates

is a plane curve and the equations are parametric equations for the curve, with parameter t.

Computer Graphics. Geometric. Transformations. by Brian Wyvill University of Calgary. Lecture 2 Geometric. Transformations. Lecture 2 Geometric

2D Transformations. 7 February 2017 Week 5-2D Transformations 1

Name: [20 points] Consider the following OpenGL commands:

CMSC 425: Lecture 10 Basics of Skeletal Animation and Kinematics

Uses of Transformations. 2D transformations Homogeneous coordinates. Transformations. Transformations. Transformations. Transformations and matrices

Computer Graphics 7: Viewing in 3-D

2D Image Transforms Computer Vision (Kris Kitani) Carnegie Mellon University

Double Integrals in Polar Coordinates

Transforming Coordinates

3D Computer Vision II. Reminder Projective Geometry, Transformations. Nassir Navab. October 27, 2009

CS 450: COMPUTER GRAPHICS 2D TRANSFORMATIONS SPRING 2016 DR. MICHAEL J. REALE

To Do. Demo (Projection Tutorial) Motivation. What we ve seen so far. Outline. Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 5: Viewing

CS770/870 Spring 2017 Transformations

Image Warping. Computational Photography Derek Hoiem, University of Illinois 09/28/17. Photo by Sean Carroll

It s Not Complex Just Its Solutions Are Complex!

Graphics Programming. Computer Graphics, VT 2016 Lecture 2, Chapter 2. Fredrik Nysjö Centre for Image analysis Uppsala University

IMGD The Game Development Process: 3D Modeling and Transformations

To Do. Motivation. Demo (Projection Tutorial) What we ve seen so far. Computer Graphics. Summary: The Whole Viewing Pipeline

GPU-Accelerated Iterated Function Systems. Simon Green, NVIDIA Corporation

For example, could you make the XNA func8ons yourself?

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6. ) is graphed below:

STRAND J: TRANSFORMATIONS, VECTORS and MATRICES

Transcription:

/3/5 Computer Graphics D Transforma5ons Review Verte Transforma5ons posi+on the model posi+on the camera adjust the zoom verte shader input verte shader output, transformed

/3/5 From Object to World Space Graphics Coordinate Sstems Right hand (or counterclockwise) coordinate sstem

/3/5 Object to World Transforma5ons D Transformations Required background reading: https://open.gl/transformations 3

/3/5 Translate (t, t) ʹ + t ʹ + t t p p t t T(t,t ) t Note: 3 rd dimension needed to encode transla+ons in matri Translate (t, t) OpenGL Implementa5on Verte shader: t t t p t p in vec3 vert; uniform mat4 model; gl_position model * vec4(vert, ); OpenGL: using namespace glm; mat4 tmat translate(mat4(.f), vec3(t,t,.f)); // Set the uniform model in the verte shader. Using tdogl: gprogram->setuniform("model", tmat); 4

/3/5 Transla5on of Objects How do en+re objects get translated? Individual ver+ces get translated The transforma+on applies to all ver+ces in the currentl bound verte arra object (VAO) " # % " # s s Scale (s, s) % ( ʹ, ʹ ) (, ) s s S(s,s ) fied point (pivot) 5

/3/5 6 Scale, then translate (note the order of calls in OpenGL): Actual transforma.on order should be read in reverse using namespace glm; mat4 tmat scale(mat4(.), vec3(s,s,.f)); OpenGL: Scale (s, s) OpenGL Implementation s s ( ), ( ) ʹ ʹ, pivot mat4 tmat(.f); tmat translate(tmat, vec3(.f,.f,.f)); tmat scale(tmat, vec3(.f,.f,.f)); Reflec5on as Scale Along X- ais Along Y- ais ʹ ʹ ʹ ʹ

/3/5 Rota5on cosθ sinθ sinθ + cosθ ( ʹ, ʹ ) θ (, ) cos θ sin θ -sin θ cos θ R(θ) pivot In D, rota+on is about the z- ais vec3(,,) Rota5on Pivot Default rota+on center is world origin (,) θ > : Rotate counterclockwise θ < : Rotate clockwise 7

/3/5 Rotation OpenGL Implementation cos θ sin θ -sin θ cos θ ( ʹ, ʹ ) θ (, ) OpenGL: pivot using namespace glm; mat4 tmat(.f); tmat rotate(tmat, radians(45.f), vec3(,,)); First scale, then rotate, then translate: mat4 tmat(.f); tmat translate(tmat, vec3(.f,.f,.f)); tmat rotate(tmat, radians(45.f), vec3(,,)); tmat scale(tmat, vec3(.f,.f,.f)); Rota5ng an En5re Object 8

/3/5 Arbitrar Rota5on Center Where is the rotation center here? Arbitrar Rota5on Center To rotate about arbitrar point P ( r, r ) b θ: Translate object b (- r, - r ) so that P is at origin Rotate the object b θ Translate object back b ( r, r ) In matri form: T( r, r) R( θ ) T( r, r) 9

/3/5 Arbitrar Rota5on Center T(r, r) r # # r # " % " # R(θ) cosθ sinθ sinθ cosθ % T( r, r) " r r # " cosθ sinθ r( cosθ) + r sinθ % sinθ cosθ r( cosθ) rsinθ # % Non- Commuta5ve Transforms Scale then Translate: (,) (,) Scale(,) (,) (,) Translate(3,) (3,) (5,3) Translate then Scale: (8,4) (,) Translate(3,) (4,) (3,) Scale(,) (6,) (,)

/3/5 Non- Commuta5ve Transforms Scale then Translate: p T ( S p ) TS p T(3,)*S(,) 3 3 Translate then Scale: p S ( T p ) ST p S(,)*T(3,) 3 6 Suppose we want Eample What are the transforma+ons?

/3/5 Composing Transforma5ons Matri mul+plica+on is not commuta+ve R( 9 ) T(,3) T(,3) R( 9 ) Rotation followed b translation Translation followed b rotation Hands- On Prac5ce D Transforma+on Applet at hdp://www.wile.com/legac/products/subject/life/biological_anthropolog/ 47579_virtual_reconstruc+on/chapter5_trafo.html Handout distributed b instructor

/3/5 Hands- On Ac5vit Modif _tetures to scale and rotate our tetured image to produce this image: a) Update the verte shader to input a model matri into a uniform mat4 variable, and use it to transform the input verte (see lecture notes) b) Switch to the main program. Reset the verte coordinates in vertedata to represent a square, then focus on the Render func+on. c) Before drawing the image (with DrawArras), create the transforma+on matri and use it to set the model shader variable. The transforma+on is a uniform scale (b.5), follow b a counterclockwise 9 - rota+on. Recall that ou need to list these transforma+ons in reverse order (see notes) d) To be able to use matri opera+ons in our code, include <glm/gtc/ matri_transform.hpp> in our main program Hands- On Ac5vit Lets rotate our image over +me and for fun well also reposi+on it at the bodom- right side of the window: We will use the func+on glfwgettime, which returns the +me elapsed since GLFW has been ini+alized To rotate the image over +me, use a rota+on transforma+on similar to model rotate(model, (float)glfwgettime()*5.f, vec3(.f,.f,.f)); In addi+on to rota+on, scale and translate our image to appear similar to the one above. Pa careful aden+on to the order of transforma+ons Note that the model transforma+on matri gets recreated each +me the Render func+on is called (ever frame) 3

/3/5 Hands- On Ac5vit 3 Lets draw a second image with another call to gldrawarras, using transforma+ons onl: Add a second call to gldrawarras for the second image Before this second gldrawarras call, set the transforma+on matri to scale and posi+on the image at the top- lel of our window Readjust the transforma+on matri to scale this second image over +me, using the sin func+on for eample, the scale factor could be sin(glfwgettime()) note that sin will cause the object to invert as soon as the scale turns nega+ve Hands- On Ac5vit 4 Create a D image of our choice. You will need to tell the verte shader how to transform the verte data (b senng the model uniform) and draw it mul+ple +mes with gldrawarras You are free to choose our own design, or ou ma tr the birthda cake shown below. The teture images are available on the class website.. (,).4.4.4.6.4.8 4