And an introduction to matrices COORDINATE SYSTEMS JEFF CHASTINE 1.

Slides:



Advertisements
Similar presentations
Points, Vectors, Lines, Spheres and Matrices
Advertisements

Computer Graphics 2D & 3D Transformation.
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
1 3D Vector & Matrix Chapter 2. 2 Vector Definition: Vector is a line segment that has the direction. The length of the line segment is called the magnitude.
Computer Graphics Lecture 4 Geometry & Transformations.
Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Transformations Rüdiger Westermann Lehrstuhl für Computer Graphik und.
Geometric Transformations
CS 4363/6353 INTRODUCTION TO COMPUTER GRAPHICS. WHAT YOU’LL SEE Interactive 3D computer graphics Real-time 2D, but mostly 3D OpenGL C/C++ (if you don’t.
Camera Models A camera is a mapping between the 3D world and a 2D image The principal camera of interest is central projection.
3-D Geometry.
1 Geometrical Transformation Tong-Yee Lee. 2 Modeling Transform Specify transformation for objects Allow definitions of objects in own coordinate systems.
OpenGL (II). How to Draw a 3-D object on Screen?
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
CS 450: Computer Graphics 2D TRANSFORMATIONS
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
UNIT - 5 3D transformation and viewing. 3D Point  We will consider points as column vectors. Thus, a typical point with coordinates (x, y, z) is represented.
1 Matrix Math ©Anthony Steed Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices.
Mathematical Fundamentals
Vectors Jeff Chastine.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Transformations of Objects CVG lab. Introduction  Affine transformations : Affine transformations are a fundamental cornerstone of computer graphics.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Transformations Dr. Amy Zhang.
Geometric Transforms Changing coordinate systems.
Geometric transformations The Pipeline
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
Foundations of Computer Graphics (Fall 2012) CS 184, Lectures 13,14: Reviews Transforms, OpenGL
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
1 Computer Graphics Week9 -3D Geometric Transformation.
Graphics Matrices. Today’s Lecture Brought to you by the integer 6 and letter ‘K’; 2D and 3D points Matrices Rotations Translation Putting it all together.
CSE Real Time Rendering Week 5. Slides(Some) Courtesy – E. Angel and D. Shreiner.
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Part One - Parallel Projection textbook
Lecture 5: Introduction to 3D
Composing Transformations
CS 325 Introduction to Computer Graphics 02 / 19 / 2010 Instructor: Michael Eckmann.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Introduction to Computer Graphics
Viewing Viewing and viewing space (camera space)
Computer Graphics CC416 Week 15 3D Graphics.
Review: Transformations
and an introduction to matrices
Graphics Fundamentals
CSCE 441 Computer Graphics 3-D Viewing
Introduction to Computer Graphics CS 445 / 645
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Lecture 2 Transformations
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Day 05 Shader Basics.
Chapters 5/4 part2 understanding transformations working with matrices
Projection in 3-D Glenn G. Chappell
Last Time Canonical view pipeline Projection Local Coordinate Space
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Introduction to Computer Graphics with WebGL
with Applications in Computer Graphics
Watch out!! OpenGL post-multiplies each new transformation matrix
Presentation transcript:

and an introduction to matrices COORDINATE SYSTEMS JEFF CHASTINE 1

THE LOCAL COORDINATE SYSTEM JEFF CHASTINE 2 Sometimes called “Object Space” It’s the coordinate system the model was made in

THE LOCAL COORDINATE SYSTEM JEFF CHASTINE 3 Sometimes called “Object Space” It’s the coordinate system the model was made in (0, 0, 0)

THE WORLD SPACE JEFF CHASTINE 4 The coordinate system of the virtual environment (619, 10, 628)

JEFF CHASTINE 5 (619, 10, 628)

QUESTION JEFF CHASTINE 6 How did get the monster positioned correctly in the world? Let’s come back to that…

CAMERA SPACE JEFF CHASTINE 7 It’s all relative to the camera…

CAMERA SPACE JEFF CHASTINE 8 It’s all relative to the camera… and the camera never moves! (0, 0, -10)

THE BIG PICTURE JEFF CHASTINE 9 How to we get from space to space? ? ?

THE BIG PICTURE JEFF CHASTINE 10 How to we get from space to space? For every model Have a (M)odel matrix! Transforms from object to world space M ?

THE BIG PICTURE JEFF CHASTINE 11 How to we get from space to space? To put in camera space Have a (V)iew matrix Usually need only one of these M V

THE BIG PICTURE JEFF CHASTINE 12 How to we get from space to space? The ModelView matrix Sometimes these are combined into one matrix Usually keep them separate for convenience M V MV

MATRIX - WHAT? JEFF CHASTINE 13 A mathematical structure that can: Translate (a.k.a. move) Rotate Scale Usually a 4x4 array of values Idea: multiply each point by a matrix to get the new point Your graphics card eats matrices for breakfast The Identity Matrix

BACK TO THE BIG PICTURE JEFF CHASTINE 14 If you multiply a matrix by a matrix, you get a matrix! How might we make the model matrix? M

BACK TO THE BIG PICTURE JEFF CHASTINE 15 If you multiply a matrix by a matrix, you get a matrix! How might we make the model matrix? M Translation matrix T Rotation matrix R 1 Rotation matrix R 2 Scale matrix S

BACK TO THE BIG PICTURE JEFF CHASTINE 16 If you multiply a matrix by a matrix, you get a matrix! How might we make the model matrix? M Translation matrix T Rotation matrix R 1 Rotation matrix R 2 Scale matrix S T * R 1 * R 2 * S = M

MATRIX ORDER JEFF CHASTINE 17 Multiply left to right Results are drastically different (an angry vertex)

MATRIX ORDER JEFF CHASTINE 18 Multiply left to right Results are drastically different Order of operations Rotate 45°

MATRIX ORDER JEFF CHASTINE 19 Multiply left to right Results are drastically different Order of operations Rotate 45° Translate 10 units

MATRIX ORDER JEFF CHASTINE 20 Multiply left to right Results are drastically different Order of operations Rotate 45° Translate 10 units before after

MATRIX ORDER JEFF CHASTINE 21 Multiply left to right Results are drastically different Order of operations

MATRIX ORDER JEFF CHASTINE 22 Multiply left to right Results are drastically different Order of operations Translate 10 units

MATRIX ORDER JEFF CHASTINE 23 Multiply left to right Results are drastically different Order of operations Translate 10 units Rotate 45°

MATRIX ORDER JEFF CHASTINE 24 Multiply left to right Results are drastically different Order of operations Translate 10 units Rotate 45° before after

BACK TO THE BIG PICTURE JEFF CHASTINE 25 If you multiply a matrix by a matrix, you get a matrix! How might we make the model matrix? M Translation matrix T Rotation matrix R 1 Rotation matrix R 2 Scale matrix S T * R 1 * R 2 * S = M Backwards

BACK TO THE BIG PICTURE JEFF CHASTINE 26 If you multiply a matrix by a matrix, you get a matrix! How might we make the model matrix? M Translation matrix T Rotation matrix R 1 Rotation matrix R 2 Scale matrix S S * R 1 * R 2 * T = M

THE (P)ROJECTION MATRIX JEFF CHASTINE 27 Projects from 3D into 2D Two kinds: Orthographic : depth doesn’t matter, parallel remains parallel Perspective : Used to give depth to the scene (a vanishing point) End result: Normalized Device Coordinates (NDCs between -1.0 and +1.0)

ORTHOGRAPHIC VS. PERSPECTIVE JEFF CHASTINE 28

AN OLD VERTEX SHADER JEFF CHASTINE 29 in vec4 vPosition;// The vertex in NDC void main () { gl_Position = vPosition; } Originally we passed using NDCs (-1 to +1)

A BETTER VERTEX SHADER JEFF CHASTINE 30 in vec4 vPosition;// The vertex in the local coordinate system uniform mat4 mM;// The matrix for the pose of the model uniform mat4 mV;// The matrix for the pose of the camera uniform mat4 mP;// The projection matrix (perspective) void main () { gl_Position = mP*mV*mM*vPosition; } Original (local) positionNew position in NDC

SMILE – IT’S THE END! JEFF CHASTINE 31

HOW ABOUT MORE THAN ONE OBJECT? Hierarchical Transformations Composing transformations Coordinate systems/frames

33 COMPOSING TRANSFORMATIONS: ROTATION ABOUT A FIXED POINT Basic idea: 1) Move fixed point to origin 2) Rotate 3) Move the fixed point back Remember, postmultiplication applies transforms in reverse Result: M = T RT –1 What does this look like graphically?

ROTATE AROUND A FIXED POINT T -1

ROTATE AROUND A FIXED POINT R Ө

Ө

ROTATE AROUND A FIXED POINT T Ө

38 OPENGL/GLM EXAMPLE Rotation about z axis by 30 degrees with a fixed point of (1.0, 2.0, 3.0) Remember that last transform specified in the program is the first applied model *= glm::translate(1.0, 2.0, 3.0)* glm::rotate(30.0, 0.0, 0.0, 1.0)* glm::translate(-1.0, -2.0, -3.0); cube.render(view*model, &shader);...

TRANSFORMATION HIERARCHIES For example, a robot arm

Transformation Hierarchies Let’s examine:

Transformation Hierarchies What is a better way?

Transformation Hierarchies What is a better way?

Transformation Hierarchies We can have transformations be in relation to each other How do we do this in openGL and glm? World Coordinates Upper Arm Coordinates Lower Arm Coordinates Hand Coordinates Transformation: Upper Arm -> World Transformation: Lower -> Upper Transformation: Hand-> Lower

Transformation Hierarchies Activity: how you would have an object B orbiting object A, and object A is constantly translating. World Coordinates Upper Arm Coordinates Lower Arm Coordinates Hand Coordinates Transformation: Upper Arm -> World Transformation: Lower -> Upper Transformation: Hand-> Lower