Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi

Slides:



Advertisements
Similar presentations
3D Transformations Assist. Prof. Dr. Ahmet Sayar
Advertisements

Computer Graphics: 3D Transformations
CS 450: COMPUTER GRAPHICS LINEAR ALGEBRA REVIEW SPRING 2015 DR. MICHAEL J. REALE.
COMPUTER GRAPHICS 2D TRANSFORMATIONS.
Coordinatate systems are used to assign numeric values to locations with respect to a particular frame of reference commonly referred to as the origin.
Geometric Transformations
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
2D TRANSFORMATIONS.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
Shivkumar Kalyanaraman Rensselaer Polytechnic Institute 1 : “shiv rpi” Linear Algebra A gentle introduction Linear Algebra has become as basic and as applicable.
Chapter 4.1 Mathematical Concepts
Linear Algebra and SVD (Some slides adapted from Octavia Camps)
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Computer Graphics CSC 630 Lecture 2- Linear Algebra.
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
Mathematical Fundamentals
Eigenvectors and Eigenvalues
Rotations and Translations
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
Chapter 4.1 Mathematical Concepts
Chapter 3 Vectors Coordinate Systems Used to describe the position of a point in space Coordinate system consists of A fixed reference point called.
Vectors. Vectors and Direction Vectors are quantities that have a size and a direction. Vectors are quantities that have a size and a direction. A quantity.
Introduction and Vectors
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
2D Transformation of Graphics
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
Part7: Geometric Transformations
 2D Transformations 2D Transformations  Translation Translation  Rotation Rotation  Scaling Scaling.
CSCE 552 Spring 2011 Math By Jijun Tang. Layered.
CS 325 Introduction to Computer Graphics 02 / 17 / 2010 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Magnitude of a Vector The magnitude of a vector, denoted as |a|, is defined as the square root of the sum of the squares of its components: |a| = (x 2.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
GG313 Lecture 14 Coordinate Transformations Strain.
Midterm Review  Five Problems 2-D/3-D Vectors, 2-D/3-D equilibrium, Dot Product, EoE, Cross Product, Moments  Closed Book & Note  Allowed to bring.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Computer Graphics 3D Transformations. Translation.
Two-Dimensional Geometric Transformations ch5. 참조 Subjects : Basic Transformations Homogeneous Coordinates Composite Transformations Other Transformations.
Chun-Yuan Lin Mathematics for Computer Graphics 2015/12/15 1 CG.
Geometric Transformations
GEOMETRIC TRANFORMATIONS Presented By -Lakshmi Sahithi.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Math Review.
2D Geometric Transformation Translation A translation is applied to an object by repositioning it along a straight-line path from one coordinate location.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Computer Graphics I, Fall 2010 Transformations.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
INTRODUCTION TO DYNAMICS ANALYSIS OF ROBOTS (Part 1)
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Learning from the Past, Looking to the Future James R. (Jim) Beaty, PhD - NASA Langley Research Center Vehicle Analysis Branch, Systems Analysis & Concepts.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
Graphics Graphics Korea University kucg.korea.ac.kr Mathematics for Computer Graphics 고려대학교 컴퓨터 그래픽스 연구실.
Transformations. Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation.
Math Fundamentals Maths revisit.
Geometric Transformations
Computer Graphics Lecture 18 3-D Transformations-II Taqdees A
Line and Character Attributes 2-D Transformation
Lecture 03: Linear Algebra
Vectors & Equilibrium Sara sultan 07/04/2019.
Linear Algebra A gentle introduction
Game Programming Algorithms and Techniques
Presentation transcript:

Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi

Vectors  Another important mathematical concept used in graphics is the Vector  If P 1 = (x 1, y 1, z 1 ) is the starting point and P 2 = (x 2, y 2, z 2 ) is the ending point, then the vector V = (x 2 – x 1, y 2 – y 1, z 2 – z 1 )

 and if P 2 = (x 2, y 2, z 2 ) is the starting point and P1 = (x 1, y 1, z 1 ) is the ending point, then the vector V = (x 1 – x 2, y 1 – y 2, z 1 – z 2 )

 This just defines length and direction, but not position

Vector Projections  Projection of v onto the x-axis

 Projection of v onto the xz plane

2D Magnitude and Direction  The magnitude (length) of a vector: |V| = sqrt( V x 2 + V y 2 ) Derived from the Pythagorean theorem  The direction of a vector:  = tan -1 (V y / V x )  is angular displacement from the x-axis

3D Magnitude and Direction  3D magnitude is a simple extension of 2D |V| = sqrt( V x 2 + V y 2 + V z 2 )  3D direction is a bit harder than in 2D – Need 2 angles to fully describe direction Latitude/longitude is a real-world example

– Direction Cosines are often used: , , and  are the positive angles that the vector makes with each of the positive coordinate axes x, y, and z, respectively cos  = V x / |V| cos  = V y / |V| cos  = V z / |V|

Vector Normalization  “Normalizing” a vector means shrinking or stretching it so its magnitude is 1 – creating unit vectors – Note that this does not change the direction  Normalize by dividing by its magnitude; V = (1, 2, 3) |V| = sqrt( ) = sqrt(14) = 3.74

Vector Normalization V norm = V / |V| = (1, 2, 3) / 3.74 = (1 / 3.74, 2 / 3.74, 3 / 3.74) = (.27,.53,.80) |V norm | = sqrt( ) = sqrt(.9 ) =.95  Note that the last calculation doesn’t come out to exactly 1. This is because of the error introduced by using only 2 decimal places in the calculations above.

Vector Addition  Equation: V 3 = V 1 + V 2 = (V 1x +V 2x, V 1y +V 2y, V 1z +V 2z )  Visually:

Vector Subtraction  Equation: V 3 = V 1 - V 2 = (V 1x -V 2x, V 1y -V 2y, V 1z -V 2z )  Visually:

Dot Product  The dot product of 2 vectors is a scalar V 1. V 2 = (V 1x V 2x ) + (V 1y V 2y ) + (V 1z V 2z )  Or, perhaps more importantly for graphics: V 1. V 2 = |V 1 | |V 2 | cos(  ) where  is the angle between the 2 vectors and  is in the range 0    

 Why is dot product important for graphics? – It is zero iff the 2 vectors are perpendicular cos(90) = 0

 The Dot Product computation can be simplified when it is known that the vectors are unit vectors V 1. V 2 = cos(  ) because |V 1 | and |V 2 | are both 1 – Saves 6 squares, 4 additions, and 2 square roots

Cross Product  The cross product of 2 vectors is a vector V 1 x V 2 = ( V 1y V 2z - V 1z V 2y, V 1z V 2x - V 1x V 2z, V 1x V 2y - V 1y V 2x ) – Note that if you are into linear algebra there is also a way to do the cross product calculation using matrices and determinants

 Again, just as with the dot product, there is a more graphical definition: V 1 x V 2 = u |V 1 | |V 2 | sin(  ) where  is the angle between the 2 vectors and  is in the range 0     and u is the unit vector that is perpendicular to both vectors – Why u? |V 1 | |V 2 | sin(  ) produces a scalar and the result needs to be a vector

 The direction of u is determined by the right hand rule – The perpendicular definition leaves an ambiguity in terms of the direction of u  Note that you can’t take the cross product of 2 vectors that are parallel to each other – sin(0) = sin(180) = 0  produces the vector (0, 0, 0)

Forming Coordinate Systems  Cross products are great for forming coordinate system frames (3 vectors that are perpendicular to each other) from 2 random vectors – Cross V 1 and V 2 to form V 3 – V 3 is now perpendicular to both V 1 and V 2 – Cross V 2 and V 3 to form V 4 – V 4 is now perpendicular to both V 2 and V 3 – Then V 2, V 4, and V 3 form your new frame

 V 1 and V 2 are in the new xy plane

Basic Transformations  Translation  Rotation  Scaling

 Translation – Straight line movement  Rotation – Circular movement w.r.t pivot  Scaling – Change of size

Translation tx = 2 ty = 3 Y X

 Translation Distances t x, t y  For point P(x,y) after translation we have P′(x′,y′)  x′ = x + t x, y′ = y + t y  (t x, t y ) is Translation vector

Now x′ = x + t x, y′ = y + t y can be expressed as a single matrix equation: P′ = P + T Where P =P′ = T =

 Rigid Body Transformation  Objects are moved without deformation  Every point on the object is translated by the same amount  Typically all the endpoints are translated and object is redrawn using new endpoint positions

Rotation Y X

 Repositions an object along a circular path in xy-plane  Rotation Angle θ  Rotation Point (x r, y r )  θ is +ve  counterclockwise rotation  θ is -ve  clockwise rotation  θ is zero  ?

 For simplicity, consider the pivot at origin and rotate point P (x,y) where x = r cosФ and y = r sinФ  If rotated by θ then:  x′ = r cos(Ф + θ) = r cosФ cosθ – r sinФ sinθ and  y′ = r sin(Ф + θ) = r cosФ sinθ + r sinФ cosθ

 Replacing r cosФ with x and r sinФ with y, we have:  x′ = x cosθ – y sinθ and  y′ = x sinθ + y cosθ

 Column vector representation: P′ = R. P  Where

 For Row vector representation of P and P′, in order to get the same results:  Which is actually transpose of original R, therefore: P′ T = (R. P) T = P T. R T

 When rotating about (x r,y r )  x’ = x r + (x - x r ) cosθ – (y - y r ) sinθ  y’ = y r + (x - x r ) sinθ – (y - y r ) cosθ  A better way of expressing these as matrix operations would be discussed later

 Rigid Body Transformation  Objects are rotated without deformation  Every point on the object is rotated by the same angle  Typically all the endpoints are rotated and object is redrawn using new endpoint positions

Scaling Y X

Scaling  Scaling alters the size of an object  Scaling factors S x and S y are used  For polygons, coordinates of each vertex may be multiplied by S x & S y to produce the transformed coordinates: x′ = x.S x y′ = y.S y

In matrix form it can be expressed as : P′ = S.P

Scaling factor > 1 Scaling factor < 1 Scaling factor = 1 Same valued scaling factors  uniform scaling in x and y Different valued scaling factors  differential scaling in x and y

When scaling w.r.t. origin, both the size and distance form origin get scaled. Size and distance fro origin: for Scaling factor 2 (double the size and double the distance from origin.) for Scaling factor 0.5 (reduce the size to 50% and also the distance from origin to 50%.

This can be controlled by scaling w.r.t. a fixed point (x f,y f ) x’ = x f + (x - x f )S x y’ = y f + (y - y f )S y  These can be rewritten as: x’ = x. S x + x f (1 – S x ) y’ = y. S y + y f (1 – S y ) Where the terms x f (1 – S x ) and y f (1 – S y ) are constant for all points in the object

Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi