Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lecture 11: 2D Transformations I - Vectors and Vector Operations, Slides of Computer Graphics

The concepts of vectors, vector operations, and transformations in computer graphics. It includes definitions of vectors, vector projections, 2d and 3d magnitudes and directions, vector normalization, vector addition and subtraction, dot product, and cross product. The document also discusses the importance of these concepts in graphics and their applications in forming coordinate systems and basic transformations such as translation, rotation, and scaling.

Typology: Slides

2011/2012

Uploaded on 11/09/2012

bacha
bacha 🇮🇳

4.3

(42)

214 documents

1 / 41

Toggle sidebar

Related documents


Partial preview of the text

Download Lecture 11: 2D Transformations I - Vectors and Vector Operations and more Slides Computer Graphics in PDF only on Docsity! Computer Graphics Lecture 11 2D Transformations I Docsity.com Vectors Another important mathematical concept used in graphics is the Vector  If P1 = (x1, y1, z1) is the starting point and P2 = (x2, y2, z2) is the ending point, then the vector V = (x2 – x1, y2 – y1, z2 – z1) Docsity.com Vector Projections y eee Eee » Projection of v onto the re D CES BYere-) Wee) At] Projection of v onto the xz plane ® BYere-) Wee) At] 2D Magnitude and Direction  The magnitude (length) of a vector: |V| = sqrt( Vx 2 + Vy 2 ) • Derived from the Pythagorean theorem  The direction of a vector: a = tan-1 (Vy / Vx) a is angular displacement from the x-axis Docsity.com 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( 1 2 + 2 2 + 3 2 ) = sqrt(14) = 3.74 Docsity.com Vector Normalization Vnorm = V / |V| = (1, 2, 3) / 3.74 = (1 / 3.74, 2 / 3.74, 3 / 3.74) = (.27, .53, .80) |Vnorm| = sqrt( .27 2 + .53 2 + .80 2 ) = 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. Docsity.com Vector Addition Equation: V3 = V1 + V2 = (V1x+V2x , V1y+V2y , V1z+V2z) Visually: Docsity.com Why is dot product important for graphics? – It is zero iff the 2 vectors are perpendicular • cos(90) = 0 Docsity.com  The Dot Product computation can be simplified when it is known that the vectors are unit vectors V1 . V2 = cos(q) because |V1| and |V2| are both 1 – Saves 6 squares, 4 additions, and 2 square roots Docsity.com Cross Product  The cross product of 2 vectors is a vector V1 x V2 = ( V1y V2z - V1z V2y , V1z V2x - V1x V2z , V1x V2y - V1y V2x ) – Note that if you are into linear algebra there is also a way to do the cross product calculation using matrices and determinants Docsity.com 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 V1 and V2 to form V3 – V3 is now perpendicular to both V1 and V2 – Cross V2 and V3 to form V4 – V4 is now perpendicular to both V2 and V3 – Then V2, V4, and V3 form your new frame Docsity.com V1 and V2 are in the new xy plane Docsity.com Basic Transformations  Translation  Rotation  Scaling Docsity.com Translation Distances tx, ty For point P(x,y) after translation we have P′(x′,y′) x′ = x + tx , y′ = y + ty  (tx, ty) is Translation vector Docsity.com Now x′ = x + tx , y′ = y + ty can be expressed as a single matrix equation: P′ = P + T Where P = P′ = T =       y x       ' ' y x       y x t t Docsity.com 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 Docsity.com 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θ Docsity.com Replacing r cosФ with x and r sinФ with y, we have: x′ = x cosθ – y sinθ and y′ = x sinθ + y cosθ Docsity.com Column vector representation: P′ = R . P Where         qq qq cossin sincos R        y x P        ' ' ' y x P Docsity.com 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 Docsity.com Scaling Y X 0 1 1 2 2 3 4 5 6 7 8 9 10 3 4 5 6       1 2       1 3       2 6       2 9 2 3   y x s s Docsity.com Scaling Scaling alters the size of an object Scaling factors Sx and Sy are used For polygons, coordinates of each vertex may be multiplied by Sx & Sy to produce the transformed coordinates: x′ = x.Sx y′ = y.Sy Docsity.com 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%. Docsity.com This can be controlled by scaling w.r.t. a fixed point (xf,yf) • x’ = xf + (x - xf)Sx • y’ = yf + (y - yf)Sy  These can be rewritten as: • x’ = x. Sx + xf (1 – Sx) • y’ = y. Sy + yf (1 – Sy) • Where the terms xf (1 – Sx) and yf (1 – Sy) are constant for all points in the object Docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved