Chapter 2 - Basic Mathematics for 3D Computer Graphics

Similar documents
Chapter 3 - Basic Mathematics for 3D Computer Graphics

Interactive Computer Graphics. Hearn & Baker, chapter D transforms Hearn & Baker, chapter 5. Aliasing and Anti-Aliasing

2D and 3D Transformations AUI Course Denbigh Starkey

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Homework 5: Transformations in geometry

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

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

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

2D Transformations Introduction to Computer Graphics Arizona State University

Computer Graphics: Geometric Transformations

Vector Algebra Transformations. Lecture 4

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

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation

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

GEOMETRIC TRANSFORMATIONS AND VIEWING

Animating orientation. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University

CT5510: Computer Graphics. Transformation BOCHANG MOON

Homework 5: Transformations in geometry

Computer Vision cmput 428/615

Computer Graphics Hands-on

Specifying Complex Scenes

2D and 3D Coordinate Systems and Transformations

Transforms. COMP 575/770 Spring 2013

Coordinate transformations. 5554: Packet 8 1

Lecture 4: Transforms. Computer Graphics CMU /15-662, Fall 2016

Transformations: 2D Transforms

UNIT 2 2D TRANSFORMATIONS

Computer Vision. Coordinates. Prof. Flávio Cardeal DECOM / CEFET- MG.

Geometric Transformations

Linear transformations Affine transformations Transformations in 3D. Graphics 2009/2010, period 1. Lecture 5: linear and affine transformations

Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ x + 5y + 7z 9x + 3y + 11z

Rotations in 3D Graphics and the Gimbal Lock

CSC418 / CSCD18 / CSC2504

Object Representation Affine Transforms. Polygonal Representation. Polygonal Representation. Polygonal Representation of Objects

Computer Graphics Hands-on

Last week. Machiraju/Zhang/Möller/Fuhrmann

3-D D Euclidean Space - Vectors

Warping. 12 May 2015

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

CS4620/5620. Professor: Kavita Bala. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

Lecture 9: Transformations. CITS3003 Graphics & Animation

Overview. Affine Transformations (2D and 3D) Coordinate System Transformations Vectors Rays and Intersections

Linear and Affine Transformations Coordinate Systems

Computer Graphics Seminar

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

Image warping , , Computational Photography Fall 2017, Lecture 10

Matrix Transformations. Affine Transformations

CS770/870 Spring 2017 Transformations

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

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

Overview. By end of the week:

2D/3D Geometric Transformations and Scene Graphs

MATRIX REVIEW PROBLEMS: Our matrix test will be on Friday May 23rd. Here are some problems to help you review.

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

Advanced Computer Graphics Transformations. Matthias Teschner

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52

XPM 2D Transformations Week 2, Lecture 3

2D Object Definition (1/3)

CS612 - Algorithms in Bioinformatics

Image Warping. Some slides from Steve Seitz

Transforms 1 Christian Miller CS Fall 2011

(Refer Slide Time: 00:04:20)

XPM 2D Transformations Week 2, Lecture 3

a a= a a =a a 1 =1 Division turned out to be equivalent to multiplication: a b= a b =a 1 b

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

Mathematics for Computer Graphics. Trigonometry

Visualisation Pipeline : The Virtual Camera

Lecture 5 2D Transformation

The Three Dimensional Coordinate System

CS452/552; EE465/505. Geometry Transformations

L6 Transformations in the Euclidean Plane

Discriminant Functions for the Normal Density

Institutionen för systemteknik

Viewing and Projection

THE VIEWING TRANSFORMATION

The Essentials of CAGD

Exercises for Chapter Three You know you've got to exercise your brain just like your muscles. Will Rogers ( )

Today. Parity. General Polygons? Non-Zero Winding Rule. Winding Numbers. CS559 Lecture 11 Polygons, Transformations

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

Computer Graphics with OpenGL ES (J. Han) Chapter IV Spaces and Transforms

Monday, 12 November 12. Matrices

Computer Graphics. Coordinate Systems and Change of Frames. Based on slides by Dianna Xu, Bryn Mawr College

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

Implementing a virtual camera. Graphics 2. Creating a view of the scene an outline. Virtual camera - definitions

Geometric transformations in 3D and coordinate frames. Computer Graphics CSE 167 Lecture 3

Incremental Image Synthesis

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

with slopes m 1 and m 2 ), if and only if its coordinates satisfy the equation y y 0 = 0 and Ax + By + C 2

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

Review of Thursday. xa + yb xc + yd

Polynomials. Math 4800/6080 Project Course

Computer Graphics. Geometric Transformations

CSE328 Fundamentals of Computer Graphics

Computer Graphics. Geometric Transformations

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

Chapter 5. Transformations of Objects

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

Game Engineering CS S-05 Linear Transforms

Transcription:

Chapter 2 - Basic Mathematics for 3D Computer Graphics Three-Dimensional Geometric Transformations Affine Transformations and Homogeneous Coordinates Combining Transformations

Translation t + t Add a vector t Geometrical meaning: Shifting Inverse operation? + t 2 t 3 + t 2 + t 3 Neutral operation? y z x 2

Uniform Scaling s Multiply with a scalar s Geometrical meaning: Changing the size of an object s s s What happens when we scale objects which are not at the origin? y How can we fix that? x z 3

Non-Uniform Scaling s 0 0 s Multiply with three scalars One for each dimension Geometrical meaning? 0 s 2 0 0 0 s 3 s 2 s 3 y x z http://en.wikipedia.org/wiki/utah_teapot 4

Reflection Mirroring) Special case of scaling s s 2 s 3 < 0 s 0 0 0 s 2 0 0 0 s 3 s s 2 s 3 Example: s, s, s 2 3 y Discuss: What does this mean for surface normals? order of polygon edges? handedness? z x 5

Shearing along X Axis + m m 0 0 0 0 0 Only x coordinate values are modified Modification depends linearly on y coordinate value Areas in x/y and x/z plane, as well as volume remain the same Generalization to other axes and arbitrary axis: see later... z y x 6

Rotation about X Axis ) y x coordinate value remains constant Rotation takes place in y/z-plane 2D) α How to compute new x and z coordinates from old ones? y z x ϕ y old sinϕ z old r z old r sinϕ z r cosϕ y old r y old r cosϕ z old 7

Rotation about X Axis 2) y cosα +ϕ) y new r r ϕ y new r cosα +ϕ) r cosa cosϕ r sinα sinϕ α y new cosα y old sinα z old z z new y old r cosϕ z old r sinϕ sinα +ϕ) z new r z r sinα +ϕ) new r sina cosϕ + r cosα sinϕ sinα y old + cosα z old 8

Rotation about X Axis 3) 0 0 0 cosα sinα 0 sinα cosα cosα sinα sinα + cosα y Special cases, e.g. 90 degrees, 80 degrees? How to rotate about other axes? α z x 9

Elementary rotations Combine to express arbitrary rotation 0 0 0 cosα sinα 0 sinα cosα cosα sinα sinα + cosα This is not always intuitive Order matters a lot) cosβ 0 sinβ 0 0 sinβ 0 cosβ cosβ + sinβ cosβ sinβ Likely source of bugs cosγ sinγ 0 sinγ cosγ 0 0 0 cos χ sinγ sinγ + cosγ 0

Transformation of Coordinate Systems Applying a geometric transformation......to all points of a single object: Transforming the object within its own coordinate system....to all points of all objects of the world : effectively transforming the reference coordinate system in the opposite direction Geometric transformations can be used to modify an object...place an object within a reference coordinate system...switch to different reference coordinates

Transformation from 3D to 2D: Projection Many different projections exist see later) Projection onto x/y plane: Forget the z coordinate value Other projections? Other viewpoints? y y 0 0 0 0 p p 2 x x z 2

Chapter 2 - Basic Mathematics for 3D Computer Graphics Three-Dimensional Geometric Transformations Affine Transformations and Homogeneous Coordinates Combining Transformations 3

Affine Transformation Mathematically: A transformation preserving collinearity Points lying on a line before are on a line after transformation Ratios of distances are preserved e.g. midpoint of a line segment) Parallel lines remain parallel Angles and lengths are not preserved Basic transformations: translation, rotation, scaling and shearing All combinations of these are affine transformations again Combination is associative, but not commutative General form of computation: New coordinate values are defined by linear function of the old values p p 2 p 3 a a 2 a 3 a 2 a 22 a 23 a 3 a 32 a 33 + t t 2 t 3 Ap + t 4

Combining Multiple Transformations Rotation, scaling and shearing are expressed as matrices Associative, hence can all be combined into one matrix Many of these operations can also be combined into one matrix Translation is expressed by adding a vector Adding vectors is also associative Many translations can be combined into a single vector Combination of Translation with other operations? Series of matrix multiplications and vector additions, difficult to combine How about using a matrix multiplication to express translation?? 5

Homogeneous Coordinates Usage of a representation of coordinate-positions with an extra dimension Extra value is a scaling factor 3D position x, y, z) is represented by xh, yh, zh, h) such that x x h h, y y h h, z z h h Simple choice for scaling factor h is the value In special cases other values can be used 3D position x, y, z) is represented by x, y, z, ) 6

Translation Expressed in Homogeneous Coordinates p t + t p 2 p 3 + t 2 t 3 + t 2 + t 3 p 0 0 t + t p 2 p 3 0 0 t 2 0 0 t 3 p + t 2 2 p + t 3 3 0 0 0 7

Scaling Expressed in Homogeneous Coordinates p s 0 0 s p 2 p 3 0 s 2 0 0 0 s 3 s 2 s 3 p s 0 0 0 s p 2 p 3 0 s 2 0 0 0 0 s 3 0 s 2 s 3 0 0 0 8

Rotation Expressed in Homogeneous Coordinates p 0 0 p 2 p 3 0 cosα sinα 0 sinα cosα cosα sinα sinα + cosα p p 2 p 3 0 0 0 0 cosα sinα 0 0 sinα cosα 0 0 0 0 cosα p sinα 3 sinα p + cosα 3 9

Shearing Expressed in Homogeneous Coordinates p m 0 + m y p 2 p 3 0 0 0 0 z x p m 0 0 + m p 2 p 3 0 0 0 0 0 0 0 0 0 20

Shearing: General Case p m 2 m 3 0 p 2 p 3 m 2 m 23 0 m 3 m 32 0 0 0 0 + m 2 + m 3 p + m p + m 2 23 3 p + m p + m 3 32 2 2

Computational Complexity for 3D Transformations p p 2 p 3 a a 2 a 3 t a 2 a 22 a 23 t 2 a 3 a 32 a 33 t 3 0 0 0 a + a 2 + a 3 + t a 2 + a 22 + a 23 + t 2 a 3 + a 32 + a 33 + t 3 Operations needed: 9 multiplications 9 additions for an arbitrarily complex affine 3D transformation Runtime complexity improved by pre-calculation of composed transformation matrices Hardware implementations in graphics processors 22

Chapter 2 - Basic Mathematics for 3D Computer Graphics Three-Dimensional Geometric Transformations Affine Transformations and Homogeneous Coordinates Combining Transformations 23

Combining several transformations: Order matters A Rotation 90 around X axis i.e. Y becomes Z ;-) B Translation by 5 along Y axis ABp ABp) means: first translate, then rotate the result BAp BAp) means: first rotate, then translate the result 24

The same example in Three.js var p new THREE.Vector4, 0, 0, ); var m new THREE.Matrix4); // initialized by identity var a new THREE.Matrix4); var b new THREE.Matrix4); var gamma Math.PI/2; // equals 90 degrees a.makerotationx gamma ); // rotation by 90 degrees around X axis b.maketranslation 0, 5, 0 ); // translation by 5 along Y axis m.multiply a ); // Now m contains a m.multiply b ); // Now m contains ab p.applymatrix4 m ); // Now p contains abp 25