COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.

Slides:



Advertisements
Similar presentations
Computer Graphics: 3D Transformations
Advertisements

COMPUTER GRAPHICS 2D TRANSFORMATIONS.
Computer Graphics Lecture 4 Geometry & Transformations.
Geometric Transformations
General Physics (PHYS101)
Two-Dimensional Geometric Transformations
CMPE 466 COMPUTER GRAPHICS
Image Warping : Computational Photography Alexei Efros, CMU, Fall 2006 Some slides from Steve Seitz
CS 4731: Computer Graphics Lecture 6: Points, Scalars and Vectors Emmanuel Agu.
2D/3D Geometric Transformations CS485/685 Computer Vision Dr. George Bebis.
Image Warping : Computational Photography Alexei Efros, CMU, Fall 2008 Some slides from Steve Seitz
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter Vector Tools for Graphics.
©College of Computer and Information Science, Northeastern UniversityJune 26, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 11.
Computer Graphics with OpenGL 3e
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 2: Review of Basic Math
Mathematical Fundamentals
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformation of Graphics
Mathematical Foundations Sections A-1 to A-5 Some of the material in these slides may have been adapted from university of Virginia, MIT and Åbo Akademi.
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
Graphics Graphics Korea University cgvr.korea.ac.kr 2D Geometric Transformations 고려대학교 컴퓨터 그래픽스 연구실.
2D Transformation of Graphics
Lecture Notes: Computer Graphics.
2D Geometric Transformations
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Transformations Jehee Lee Seoul National University.
Geometric Transformations
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
Geometric Objects and Transformation
Background Mathematics Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006.
Transformation.
Two-Dimensional Geometric Transformations ch5. 참조 Subjects : Basic Transformations Homogeneous Coordinates Composite Transformations Other Transformations.
Two-Dimensional Geometric Transformations A two dimensional transformation is any operation on a point in space (x, y) that maps that point's coordinates.
Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Geometric Transformations
Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Multimedia Programming 07: Image Warping Keyframe Animation Departments of Digital Contents Sang Il Park.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Geometric Transformations UBI 516 Advanced Computer Graphics Aydın Öztürk
January 19, y X Z Translations Objects are usually defined relative to their own coordinate system. We can translate points in space to new positions.
3-D Geometric Transformations
3D Geometric Transformation
3D Geometric Transformation
CSCI 425/ D Mathematical Preliminaries. CSCI 425/525 2 Coordinate Systems Z X Y Y X Z Right-handed coordinate system Left-handed coordinate system.
Affine Geometry.
3D Coordinate Systems o3D computer graphics involves the additional dimension of depth, allowing more realistic representations of 3D objects in the real.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
CS 325 Introduction to Computer Graphics 02 / 19 / 2010 Instructor: Michael Eckmann.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Computer Graphic 2 D Transformation.
3D Geometry and Transformations
Modeling Transformation
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
3D Geometric Transformation
3. Transformation
2D Geometric Transformations
3D Transformation.
3D Geometric Transformations
Introduction to Computer Graphics CS 445 / 645
Computer Graphics Transformations
Presentation transcript:

COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013

Lecture 2 Ray Tracing & Transformations

9/5/2015 Outline Points and Vectors Matrices Vector Operations Ray Tracing Homogenous coordinates Affine Transformations –Translation –Rotation –Scaling –Projection View Point Coordinates of objects on the surface of other objects

Points and Vectors 9/5/2015

Points and Vectors Drawing systems of particles Determining coordinates of other objects Drawing objects 9/5/2015

Points and Vectors Points –(x,y,z) Representation –Absolute coordinates (point) –Relative coordinate (radius-vector) –Distance (vector) –Direction (vector)

Points in 3D 3D absolute coordinates P(x,y,z) y Z Y X x z

Radius-vector Relative coordinate (radius-vector) (0,0,0) P(x,y,z) y Z Y X x z

Length and Magnitude Calculating the length/magnitude –Requires reference point R |p|  x x x x zzzz  y y y yR Z Y X

Direction Determines the direction in 3D –This is not sufficient for complete orientation |p| Z Y X

Points and Vectors operations

Vectors representation Vectors (points) Vector defined by points X 1 and X 2

Examples Vector p(5,2,3) Vector q from point (3,0,8) to (0,2,7)

Point Vector: Point position and direction – Magnitude - Direction V P2P2 P1P1 x1x1 x2x2 y1y1 y2y2 Points and Vectors

Length Vector p length Unit vector –Vector with length=1

Examples Vector p(5,2,3) Vector p from (3,0,8) to (0,2,7)

Addition and Subtraction Vector can be added or subtracted only to other vector

Examples Addition of p(5,2,3) and q(-1,-1,1) Subtraction of q(-1,-1,1) and r(4,1,4)

Product Various product operations –Product with scalar (i.e. vector and number) –Scalar product of vectors –Vector product of vectors Three of them are used in Computer Graphics for important operations

Product with scalar Product with number Geometrical meaning –Scaling (extending, shortening) vector –Preserves the direction for k>0 –Reverses direction when k<0 (the opposite direction)

Examples Doubled vector p(5,2,3) Reversed vector q(-1,-1,1)

Unit Vector Unit vector Geometrical meaning –Vector with length = 1 –Preserves the direction –Can be applied only over non-zero vectors

Examples Unit vector of p(5,2,3) Check

Scalar Product Product of two vectors, the result is scalar (number) –Angle  between two vectors Geometrical/Graphical meaning –Checking for perpendicularity –Lightening of surface –Calculating the area

exexexex p.q calculating Using unit axis vectors p eyeyeyey ezezezez Z Y X

Multiply Remember that Find

Lucky method –Lying in the same plane –Angle between = 45 о First class method –"First class" in terms of quality – but also because it may be applied by first grader student Examples (2,2,0).(0,1,0)

Example Check whether the vectors are perpendicular –p(4,0,1) and q(-2,3,8) Solution

Scalar Product Definition For Cartesian Reference Frame Properties –Commutative –Distributive |V 2 |cos   V2V2 V1V1 Dot Product, Inner Product

Vector product Vector product and the result is vector –Angle  between two vectors Geometrical meaning –Finding normal vectors –Parallelogram Area

Where vector points on? The Result vector of Vector product is: –Perpendicular to the plane defined by to vector in this product –Lies in the plane where the direction of rotation from the first to the second vector is positive (i. e. counterclockwise) V1V1 V2V2 V1  V2V1  V2  u

How to remember? Use right hand –Coordinate system PQR is right-hand Снимка: FreeDigitalPhotos.net

Unit Vectors exexexex eyeyeyey ezezezez exexexex eyeyeyey ezezezez Z Y X Z Y X

Calculation of pхq Using unit axis vectors

After vector product of unit vectors Regroup

Final Result

Vector Product Definition For Cartesian Reference Frame Properties –AntiCommutative –Not Associative –Distributive Cross Product, Outer Product V1V1 V2V2 V1  V2V1  V2  u

Examples Scalar ProductVector Product Normal Vector of the Plane  V2V2 V1V1 Angle between Two Edges (x2,y2)(x2,y2) (x0,y0)(x0,y0) (x1,y1)(x1,y1)

Determinant of Matrix Definition –For a square matrix, combining the matrix elements to product a single number 2  2 matrix Determinant of n  n Matrix A (n  2)

Inverse Matrix Definition –Non-singular matrix If and only if the determinant of the matrix is non-zero 2  2 matrix Properties

2D Geometric Transformations

Geometric Transformation Definition –Translation, Rotation, Scaling Motivation – Why do we need geometric transformations in CG? –As a viewing aid –As a modeling tool –As an image manipulation tool

Example: 2D Geometric Transformation Modeling Coordinates World Coordinates

Example: 2D Scaling Modeling Coordinates World Coordinates Scale(0.3, 0.3)

Example: 2D Rotation Modeling Coordinates Scale(0.3, 0.3) Rotate(-90) World Coordinates

Example: 2D Translation Modeling Coordinates Scale(0.3, 0.3) Rotate(-90) Translate(5, 3) World Coordinates

Example: 2D Geometric Transformation Modeling Coordinates World Coordinates Again?

Example: 2D Geometric Transformation Modeling Coordinates World Coordinates Scale Translate Scale Rotate Translate

Basic 2D Transformations Translation – Scale – Rotation – Shear –

Basic 2D Transformations Translation – Scale – Rotation – Shear – Transformations can be combined (with simple algebra)

Basic 2D Transformations Translation – Scale – Rotation – Shear –

Basic 2D Transformations Translation – Scale – Rotation – Shear –

Basic 2D Transformations Translation – Scale – Rotation – Shear –

Basic 2D Transformations Translation – Scale – Rotation – Shear –

Matrix Representation Represent a 2D Transformation by a Matrix Apply the Transformation to a Point Transformation Matrix Point

Matrix Representation Transformations can be combined by matrix multiplication Matrices are a convenient and efficient way to represent a sequence of transformations Transformation Matrix

2×2 Matrices What types of transformations can be represented with a 2×2 matrix? 2D Identity 2D Scaling

2×2 Matrices What types of transformations can be represented with a 2×2 matrix? 2D Rotation 2D Shearing

2×2 Matrices What types of transformations can be represented with a 2×2 matrix? 2D Mirror over Y axis 2D Mirror over (0,0)

2×2 Matrices What types of transformations can be represented with a 2×2 matrix? 2D Translation NO!! Only linear 2D transformations can be Represented with 2x2 matrix

2D Translation 2D translation can be represented by a 3×3 matrix –Point represented with homogeneous coordinates

Basic 2D Transformations Basic 2D transformations as 3x3 Matrices Translate Shear Scale Rotate

Homogeneous Coordinates Add a 3rd coordinate to every 2D point –(x, y, w) represents a point at location (x/w, y/w) –(x, y, 0) represents a point at infinity –(0, 0, 0) Is not allowed x y (2, 1, 1) or (4, 2, 2) or (6, 3, 3) Convenient Coordinate System to Represent Many Useful Transformations

Linear Transformations Linear transformations are combinations of … –Scale –Rotation –Shear, and –Mirror Properties of linear transformations –Satisfies: –Origin maps to origin –Lines map to lines –Parallel lines remain parallel –Ratios are preserved –Closed under composition

Affine Transformations Affine transformations are combinations of –Linear transformations, and –Translations Properties of affine transformations –Origin does not map to origin –Lines map to lines –Parallel lines remain parallel –Ratios are preserved –Closed under composition

Projective Transformations Projective transformations… –Affine transformations, and –Projective warps Properties of projective transformations –Origin does not map to origin –Lines map to lines –Parallel lines do not necessarily remain parallel –Ratios are not preserved –Closed under composition

Matrix Composition Transformations can be combined by matrix multiplication Efficiency with premultiplication –Matrix multiplication is associative

Matrix Composition Rotate by  around arbitrary point (a,b) – Scale by sx, sy around arbitrary point (a,b) – (a,b)

Pivot-Point Rotation TranslateRotateTranslate (x r,y r )

General Fixed-Point Scaling TranslateScaleTranslate (x f,y f )

Shear Converted to a parallelogram x’ = x + sh x · y, y’ = y Transformed to a shifted parallelogram (Y = Yref) x’ = x + sh x · ( y-y ref ), y’ = y (Sh x =2) (Sh x =1/2, y ref =-1) x y x y x y x y (0,0)(1,0) (1,1) (0,1) ( 0,0 )( 1,0 ) ( 1,1 ) (0,1) (0,0)(1,0) (3,1)(2,1) ( 1/2,0 ) ( 3/2,0 ) ( 2,1 ) ( 1,1 ) (0,-1)

Shear Transformed to a shifted parallelogram (X = Xref) x’ = x, y’ = sh y · ( x-x ref ) + y (Sh y =1/2, x ref =-1) x y x y (-1,0) ( 0,0 )( 1,0 ) ( 1,1 ) ( 0,1 ) ( 0,1/2 )( 1,1 ) ( 1,2 ) ( 0,3/2 )

3D Geometric Transformation

Contents Translation Scaling Rotation Rotations with Quaternions Other Transformations Coordinate Transformations

Transformation in 3D Transformation Matrix 3  3 : Scaling, Reflection, Shearing, Rotation 3  1 : Translation 1  3 : Homogeneous representation 1  1 : Uniform global Scaling

3D Translation Translation of a Point x z y

3D Scaling Uniform Scaling x z y

Relative Scaling Scaling with a Selected Fixed Position xxx x z z zz y yy y Original positionTranslateScaling Inverse Translate

3D Rotation Coordinate-Axes Rotations –X-axis rotation –Y-axis rotation –Z-axis rotation General 3D Rotations –Rotation about an axis that is parallel to one of the coordinate axes –Rotation about an arbitrary axis

Coordinate-Axes Rotations Z-Axis Rotation X-Axis Rotation Y-Axis Rotation z y x z y x z y x

Order of Rotations Order of Rotation Affects Final Position –X-axis  Z-axis –Z-axis  X-axis

General 3D Rotations Rotation about an Axis that is Parallel to One of the Coordinate Axes –Translate the object so that the rotation axis coincides with the parallel coordinate axis –Perform the specified rotation about that axis –Translate the object so that the rotation axis is moved back to its original position

General 3D Rotations Rotation about an Arbitrary Axis Basic Idea 1.Translate (x1, y1, z1) to the origin 2.Rotate (x’2, y’2, z’2) on to the z axis 3.Rotate the object around the z-axis 4.Rotate the axis to the original orientation 5.Translate the rotation axis to the original position Basic Idea 1.Translate (x1, y1, z1) to the origin 2.Rotate (x’2, y’2, z’2) on to the z axis 3.Rotate the object around the z-axis 4.Rotate the axis to the original orientation 5.Translate the rotation axis to the original position (x 2,y 2,z 2 ) (x 1,y 1,z 1 ) x z y R -1 T -1 R R T T

General 3D Rotations Step 1. Translation (x 2,y 2,z 2 ) (x 1,y 1,z 1 ) x z y

General 3D Rotations Step 2. Establish [ T R ]  x x axis (a,b,c) (0,b,c) Projected Point   Rotated Point x y z

Arbitrary Axis Rotation Step 3. Rotate about y axis by  (a,b,c) (a,0,d)  l d x y Projected Point z Rotated Point

Arbitrary Axis Rotation Step 4. Rotate about z axis by the desired angle   l y x z

Arbitrary Axis Rotation Step 5. Apply the reverse transformation to place the axis back in its initial position x y l l z

Find the new coordinates of a unit cube 90º-rotated about an axis defined by its endpoints A(2,1,0) and B(3,3,1). A Unit Cube Example

Step1. Translate point A to the origin A’(0,0,0) x z y B’(1,2,1)

x z y l  Projected point (0,2,1) B”(1,0,  5) Example Step 2. Rotate axis A’B’ about the x axis by and angle , until it lies on the xz plane.

x z y l  B”(1,0,  5) (0,0,  6) Example Step 3. Rotate axis A’B’’ about the y axis by and angle , until it coincides with the z axis.

Example Step 4. Rotate the cube 90° about the z axis –Finally, the concatenated rotation matrix about the arbitrary axis AB becomes,

Example

Multiplying R(θ) by the point matrix of the original cube

Questions? 9/5/2015