Geometric Transformation CS 211A



Similar documents
Lecture 3: Coordinate Systems and Transformations

TWO-DIMENSIONAL TRANSFORMATION

Lecture L3 - Vectors, Matrices and Coordinate Transformations

Rotation Matrices and Homogeneous Transformations

2D Geometric Transformations

Vector Math Computer Graphics Scott D. Anderson

Linear algebra and the geometry of quadratic equations. Similarity transformations and orthogonal matrices

Unified Lecture # 4 Vectors

Chapter 6. Linear Transformation. 6.1 Intro. to Linear Transformation

Geometric Transformations

The Vector or Cross Product

Projective Geometry: A Short Introduction. Lecture Notes Edmond Boyer

Vector Notation: AB represents the vector from point A to point B on a graph. The vector can be computed by B A.

Review B: Coordinate Systems

L 2 : x = s + 1, y = s, z = 4s Suppose that C has coordinates (x, y, z). Then from the vector equality AC = BD, one has

v w is orthogonal to both v and w. the three vectors v, w and v w form a right-handed set of vectors.

Addition and Subtraction of Vectors

Geometric Camera Parameters

Lectures notes on orthogonal matrices (with exercises) Linear Algebra II - Spring 2004 by D. Klain

The Geometry of Perspective Projection

Adding vectors We can do arithmetic with vectors. We ll start with vector addition and related operations. Suppose you have two vectors

Geometric Transformations

521493S Computer Graphics. Exercise 2 & course schedule change

Complex Numbers. w = f(z) z. Examples

THREE DIMENSIONAL GEOMETRY

4. How many integers between 2004 and 4002 are perfect squares?

Chapter 17. Orthogonal Matrices and Symmetries of Space

Solutions for Review Problems

Cross product and determinants (Sect. 12.4) Two main ways to introduce the cross product

Given a point cloud, polygon, or sampled parametric curve, we can use transformations for several purposes:

Parametric Equations and the Parabola (Extension 1)

B4 Computational Geometry

Lecture 2: Homogeneous Coordinates, Lines and Conics

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

1.3. DOT PRODUCT If θ is the angle (between 0 and π) between two non-zero vectors u and v,

ab = c a If the coefficients a,b and c are real then either α and β are real or α and β are complex conjugates

9.4. The Scalar Product. Introduction. Prerequisites. Learning Style. Learning Outcomes

Geometry for Computer Graphics

5. Orthogonal matrices

v 1 v 3 u v = (( 1)4 (3)2, [1(4) ( 2)2], 1(3) ( 2)( 1)) = ( 10, 8, 1) (d) u (v w) = (u w)v (u v)w (Relationship between dot and cross product)

Computing Orthonormal Sets in 2D, 3D, and 4D

Physics 235 Chapter 1. Chapter 1 Matrices, Vectors, and Vector Calculus

BALTIC OLYMPIAD IN INFORMATICS Stockholm, April 18-22, 2009 Page 1 of?? ENG rectangle. Rectangle

Section 11.1: Vectors in the Plane. Suggested Problems: 1, 5, 9, 17, 23, 25-37, 40, 42, 44, 45, 47, 50

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

Linear Algebra Notes for Marsden and Tromba Vector Calculus

Fundamentals of Computer Animation

A vector is a directed line segment used to represent a vector quantity.

How to Solve a Cubic Equation Part 1 The Shape of the Discriminant

Linear Algebra: Vectors

Summary: Transformations. Lecture 14 Parameter Estimation Readings T&V Sec Parameter Estimation: Fitting Geometric Models

Orthogonal Projections

LINEAR MAPS, THE TOTAL DERIVATIVE AND THE CHAIN RULE. Contents

Two vectors are equal if they have the same length and direction. They do not

Solutions to old Exam 1 problems

CIRCLE COORDINATE GEOMETRY

Dot product and vector projections (Sect. 12.3) There are two main ways to introduce the dot product

Differentiation of vectors

MATH2210 Notebook 1 Fall Semester 2016/ MATH2210 Notebook Solving Systems of Linear Equations... 3

Affine Transformations

Section 9.5: Equations of Lines and Planes

3D Viewing. Chapter 7. Projections. 3D clipping. OpenGL viewing functions and clipping planes

Algebra 2 Chapter 1 Vocabulary. identity - A statement that equates two equivalent expressions.

Section 5.3. Section 5.3. u m ] l jj. = l jj u j + + l mj u m. v j = [ u 1 u j. l mj

CS 4204 Computer Graphics

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

Section 1.4. Lines, Planes, and Hyperplanes. The Calculus of Functions of Several Variables


13 MATH FACTS a = The elements of a vector have a graphical interpretation, which is particularly easy to see in two or three dimensions.

Computing Euler angles from a rotation matrix

Systems of Linear Equations

Solving Simultaneous Equations and Matrices

Math Placement Test Practice Problems

Recall that two vectors in are perpendicular or orthogonal provided that their dot

Solving Geometric Problems with the Rotating Calipers *

Lecture L5 - Other Coordinate Systems

AP Physics - Vector Algrebra Tutorial

CS 4204 Computer Graphics

[1] Diagonal factorization

Inner Product Spaces

Least-Squares Intersection of Lines

Section Continued

Recall the basic property of the transpose (for any A): v A t Aw = v w, v, w R n.

DERIVATIVES AS MATRICES; CHAIN RULE

discuss how to describe points, lines and planes in 3 space.

Content. Chapter 4 Functions Basic concepts on real functions 62. Credits 11

MAT 200, Midterm Exam Solution. a. (5 points) Compute the determinant of the matrix A =

2. SPATIAL TRANSFORMATIONS

Chapter 19. General Matrices. An n m matrix is an array. a 11 a 12 a 1m a 21 a 22 a 2m A = a n1 a n2 a nm. The matrix A has n row vectors

9 MATRICES AND TRANSFORMATIONS

Rotation about an arbitrary axis and reflection through an arbitrary plane


II. Linear Systems of Equations

The elements used in commercial codes can be classified in two basic categories:

Linear Programming Problems

Concepts in Calculus III

Section 9.1 Vectors in Two Dimensions

GCE Mathematics (6360) Further Pure unit 4 (MFP4) Textbook

Transcription:

Geometric Transformation CS 211A

What is transformation? Moving points (x,y) moves to (x+t, y+t) Can be in any dimension 2D Image warps 3D 3D Graphics and Vision Can also be considered as a movement to the coordinate axes

Homogeneous Coordinates Note: (2x/y, 2), (3x/y,3), and (x/y,1) represent the same 1D point P P (x,y) y=1 Q (2x,2y) Any point on the same vector has the same homogeneous coordinates P (x/y,1) 1D points on the line is represented by 2D array, called homogeneous coordinates

Generalize to Higher Dimensions Z P (x, y, z) 2D points represented by homogeneous coordinates P (x/z, y/z, 1) Similarly, 3D points are represented by homogeneous coordinates If (x,y,z,w) is the homogeneous coordinate of a 3D point, where w = 1, then the 3D point is given by (x/w,y/w,z/w,1)

Practically [x y z w], w 1 Then, [x/w, y/w, z/w, 1] Try to put it the w=1 hyperplane Why? Can represent pts at infinity 2D [, ] 3D homogeneous [2, 3, 0] Point at infinity in the direction of [2, 3] Distinguish between points and vectors [2, 3, 1] vs [2, 3, 0]

Linear Transformation L(ap+bq) = al(p) + bl(q) Lines/planes transform to lines/planes If transformation of vertices are known, transformation of linear combination of vertices can be achieved p and q are points or vectors in (n+1)x1 homogeneous coordinates For 2D, 3x1 homogeneous coordinates For 3D, 4x1 homogeneous coordinates L is a (n+1)x(n+1) square matrix For 2D, 3x3 matrix For 3D, 4x4 matrix

Linear Transformations Euclidian Length and angles are preserved Affine Ratios of lengths and angles are preserved Projective Can move points at infinity in range and finite points to infinity

Euclidian Transformations Lengths and angles are preserved Translation Rotation

2D Translation Line between two points is transformed to a line between the transformed points

3D Translation x x P = y z 1 P = y z 1 P = TP x = x + t x y = y + t y z = z + t z T = 1 0 0 t x 0 1 0 t y 0 0 1 t z 0 0 0 1 Denoted by T(t x, t y, t z )

Inverse Translation x x P = y z 1 P = y z 1 P = T -1 P x = x - t x y = y - t y z = z - t z T -1 = 1 0 0 -t x 0 1 0 -t y 0 0 1 -t z 0 0 0 1 T -1 = T(-t x, -t y, -t z )

x = ρ cos φ y = ρ sin φ x = ρ cos (θ + φ) y = ρ sin (θ + φ) 2D Rotation θ φ (x,y ) ρ (x,y) x = ρ cosθ cosφ - ρ sinθ sinφ = x cosθ y sinθ y = ρ sinθ cosφ + ρ cosθ sinφ = x sinθ + y cosθ x y 1 = R x y 1 R = cosθ sinθ 0 sinθ cosθ 0 0 0 1

Example

Rotation in 3D about z axis x = x cosθ y sinθ y = x sinθ + y cosθ z = z 1 0 0 0 R 0 cosθ sinθ 0 x = 0 sinθ cosθ 0 0 0 0 1 R z = P = R z P cosθ sinθ 0 0 sinθ cosθ 0 0 0 0 1 0 0 0 0 1 Denoted by R(θ) R -1 = R(-θ) = R T (θ) Where R = R x or R y or R z

Affine Transformations Ratio of lengths and angles are preserved Scale Lengths are not preserved Shear Angles are not preserved

Scaling P = x y z 1 x = s x x y = s y y z = s z z P = x y z 1 P = SP s x 0 0 0 S = 0 s y 0 0 0 0 s z 0 0 0 0 1 Denoted by S(s x, s y, s z ) S -1 = S(1/s x, 1/s y, 1/s z )

Shear Translation of one coordinate of a point is proportional to the value of the other coordinate of the same point. Point : (x,y) After y-shear : (x+ay,y) After x-shear : (x,y+bx) Changes the shape of the object.

Using matrix for Shear Example: Z-shear (Z coordinate does not change) 1 0 a 0 x x+az x 0 1 b 0 0 0 1 0 y z = y+bz z = y z 0 0 0 1 1 1 1

General Affine Transformation The last row is fixed Has 12 degrees of A = freedom Does not change degrees of polynomial Parallel and intersecting lines/planes to the same α 11 α 12 α 13 α 14 α 21 α 22 α 23 α 24 α 31 α 32 α 33 α 34 0 0 0 1

Fixed Points and Lines Some points and lines can be fixed under a transformation Scaling Point Origin Rotation Line Axis of rotation

Scaling About a point (0,2) (2,2) (0,4) (4,4) (0,0) (2,0) (0,0) (4,0) Origin is fixed with transformation -> Scaling about origin

Concatenation of Transformations How do we use multiple transformation? Apply F Get to a known situation Apply the required L Apply F -1

Scaling About a point (0,2) (2,2) (-1,3) (3,3) (1,1) (1,1) (0,0) (2,0) (-1,-1) (3,-1) Scaling about center -> Center is fixed with transformation

Done by concatenation (0,2) (2,2) (1,1) (-1,1) (1,1) (0,0) (2,0) (1,1) (-1,-1) (1,-1) Translate so that center coincides with origin - T(-1,-1).

Done by concatenation (0,2) (2,2) (-2,2) (2,2) (1,1) (0,0) (2,0) (1,1) (-2,-2) (2,-2) Scale the points about the center S(2,2)

Done by concatenation (0,2) (2,2) (-1,3) (3,3) (1,1) (1,1) (0,0) (2,0) (-1,-1) (3,-1) Translate it back by reverse parameters T(1,1) Total Transformation: T(1,1) S(2,2) T(-1,-1) P

Rotation about a fixed point z-axis rotation of θ about its center P f Translate by P f : T(-P f ) Rotate about z-axis : R z (θ) Translate back by P f : T(P f ) Total Transformation M = T(P f )R z (θ)t(-p f )

Rotation About an Arbitrary Axis Axis given by two points P 1 (starting point) and P 2 (ending point) P 1 (x 1, y 1, z 1 ) and P 2 (x 2, y 2, z 2 ) Anticlockwise angle of rotation is θ Rotate all points to around P 1 P 2 by θ Z P1 P2

Rotation about an Arbitrary Axis Make P 1 P 2 coincide with Z-axis Translate P 1 to origin: T(-x 1,-y 1,-z 1 ) Coincides one point of the axis with origin P1 P2 Z

Rotation about an Arbitrary Axis Make P 1 P 2 coincide with Z-axis Translate P 1 to origin: T(-x 1,-y 1,-z 1 ) Coincides one point of the axis with origin Rotate shifted axis to coincide with Z axis Z P1 P2

Rotation about an Arbitrary Axis Make P 1 P 2 coincide with Z-axis Translate P 1 to origin: T(-x 1,-y 1,-z 1 ) Coincides one point of the axis with origin Rotate shifted axis to coincide with Z axis R 1 : Rotate about to lie on Z plane Z P1 P2

Rotation about an Arbitrary Axis Make P 1 P 2 coincide with Z-axis Translate P 1 to origin: T(-x 1,-y 1,-z 1 ) Coincides one point of the axis with origin Rotate shifted axis to coincide with Z axis R 1 : Rotate about to lie on Z plane R 2 : Rotate about to lie on Z axis Z P1 P2

Rotation about an Arbitrary Axis Make P 1 P 2 coincide with Z-axis Translate P 1 to origin: T(-x 1,-y 1,-z 1 ) Coincides one point of the axis with origin Rotate shifted axis to coincide with Z axis R 1 : Rotate about to lie on Z plane R 2 : Rotate about to lie on Z axis Z P2 P1

Rotation about an Arbitrary Axis Make the axis P 1 P 2 coincide with the Z-axis Translation to move P 1 to the origin: T(-x 1,-y 1,-z 1 ) Coincides one point of the axis with origin Rotation to coincide the shifted axis with Z axis R 1 : Rotation around such that the axis lies on the Z plane. R 2 : Rotation around such that the axis coincides with the Z axis R 3 : Rotate the scene around the Z axis by an angle θ Inverse transformations of R 2, R 1 and T 1 to bring back the axis to the original position M = T -1-1 -1 R 1 R 2 R 3 R 2 R 1 T

After translation Translation P 2 P 2 Axis V = P 2 P 1 = (x 1 -x 2,y 1 -y 2,z 1 -z 2 ) P 1 u P 1 u = V V = (a, b, c) Z

Rotation about axis Rotate u about so that it coincides with Z plane u = (0, b, c) u = (a, b, c) α Z α u = (a, 0, d) R 1 = Project u on Z plane : u (0, b, c) α is the angle made by u with Z axis Cos α = c/ b 2 +c 2 = c/d Sin α = b/d 1 0 0 0 0 c/d -b/d 0 0 b/d c/d 0 0 0 0 1

Rotation about axis Rotate u about so that it coincides with Z axis Cos β = d/ a 2 +d 2 = d/ a 2 +b 2 +c 2 = d Sin β = a Z β u = (a, 0, d) R 2 = d 0 -a 0 0 1 0 0 a 0 d 0 0 0 0 1

Rotation about Z axis Rotate by θ about Z axis R 3 = cosθ sinθ 0 0 sinθ cosθ 0 0 0 0 1 0 0 0 0 1

Rotation about Arbitrary Axis M = T -1 R 1-1 R 2-1 R 3 (θ) R 2 (β) R 1 (α) T = T -1 R x -1 R y -1 R z (θ) R y (β) R x (α) T = T -1 R x (-α)r y (-β)r z (θ) R y (β) R x (α) T

Coordinate Systems Represent a point as a linear combination of three vectors and the origin Linearly independent vectors basis Orthogonal vectors are linearly independent v 2 w w = α 1 v 1 + α 2 v 2 + α 3 v 3 + R α 2 v 1 v 2 v 3 R α 1 = w α 2 v 3 α 1 α 3 v 1 α 3 1

Coordinate Systems Represent a point as a linear combination of three vectors and the origin Linearly independent vectors basis Orthogonal vectors are linearly independent v 2 w w = α 1 v 1 + α 2 v 2 + α 3 v 3 + R α 2 1 0 0 0 0 1 0 0 α 1 α 2 = w v 3 α 1 α 3 v 1 0 0 1 0 0 0 0 1 α 3 1

Change of Coordinates First coordinate v 1, v 2, v 3, R 1 Second coordinate u 1, u 2, u 3, R 2 u 2 v 2 u 1 P α 1 α 2 = C 1 R 2 R 1 v 1 α 3 1 v 3 u 3

Change of Coordinates First coordinate v 1, v 2, v 3, R 1 Second coordinate u 1, u 2, u 3, R 2 u 2 v 2 v 2 u 1 P u 1 = γ 11 v 1 + γ 21 v 2 + γ 31 v 3 R 2 u 2 = γ 12 v 1 + γ 22 v 2 + γ 32 v 3 R 1 v 1 u 3 = γ 13 v 1 + γ 23 v 2 + γ 33 v 3 v 3 R 2 = γ 14 v 1 + γ 24 v 2 + γ 34 v 3 + R 1 u 3 u 3

Change of Coordinates u 1 = γ 11 v 1 + γ 21 v 2 + γ 31 v 3 u 2 = γ 12 v 1 + γ 22 v 2 + γ 32 v 3 u 3 = γ 13 v 1 + γ 23 v 2 + γ 33 v 3 R 2 = γ 14 v 1 + γ 24 v 2 + γ 34 v 3 + R 1 γ 11 γ 12 γ 13 γ 14 u 1 u 2 u 3 R 2 = v 1 v 2 v 3 R 1 M M = γ 21 γ 22 γ 23 γ 24 γ 31 γ 32 γ 33 γ 34 0 0 0 1

Change of Coordinates If R 1 = R 2, then γ 14 = γ 24 = γ 34 = 0 M = γ 11 γ 12 γ 0 13 γ 21 γ 22 γ 0 23 γ 31 γ 32 γ 0 33 0 0 0 1

Change of Coordinates P = u 1 u 2 u 3 R 2 C 2 = = v 1 v 2 v 3 R 1 v 1 v 2 v 3 R 1 M C 2 C 1 Hence, C 1 = MC 2

What is this matrix? ou need translate Coincide origins ou need to rotate To make the axis match This is a rotation and translation concatenated M = γ 11 γ 12 γ γ 13 14 γ 21 γ 22 γ γ 23 24 γ 31 γ 32 γ γ 33 34 0 0 0 1

What is this concatenation? r 11 r 12 r 13 0 1 0 0 t x R = r 21 r 22 r 0 23 r 31 r 32 r 0 33 0 0 0 1 T = 0 1 0 t y 0 0 1 t z 0 0 0 1 r 11 r 12 r 13 t x M = r 21 r 22 r 23 t y r 31 r 32 r 33 t z 0 0 0 1 = [R RT]

How to simplify rotation about arbitrary axis? Translation goes in the last column The rotation matrix defined by finding a new coordinate with the arbitrary axis as a, or Z axis

How to find coordinate axes? N = U x V V W = N x U U

Faster Way Faster way to find R 2 R 1 u x, u y, u z are unit vectors in the,, Z direction Set up a coordinate system where u = u z u z = u u u = u z u y = u x u x u y u x u x u u x = u y x u z x u x1 u u x2 x3 0 Z R 1-1 R 2-1 = R -1 R = R 2 R 1 = u y1 u y2 u 0 y3 u z1 u z2 u 0 z3 0 0 0 1

Properties of Concatenation Not commutative R T R T RTP TRP

Properties of Concatenation Associative Does not matter how to multiply ((AB)C)P = (A(BC))P What is the interpretation of these two? Till now we were doing (A(BC))P Right to left Transforming points Coordinate axes same across A, B and C GLOBAL COORDINATES

Properties of Concatenation What is the geometric interpretation of (AB)C Left to right Transforms the axes (not the points) LOCAL COORDINATES Results are the same as long as the matrix is (ABC)

Local/Global Coordinate Systems GCS: Right to Left: point is first translated and then rotated Local Local Local Local LCS: Left to Right: coordinate first rotated and then translated

Local / Global Coordinate Systems GCS: Right to Left: point is first scaled and then rotated LCS: Left to Right: coordinate first rotated and then scaled

Projective Transformation Most general form of linear transformation Note that we are interested in points such that w =1 Takes finite points to infinity and vice versa

Example Take a circle in (x,y) x 2 +y 2 =1 Show that it goes to parabola Take two parallel lines Show that they go to intersecting lines Intersection lines can become parallel Degree of the polynomials are preserved Since linear

Images are two-dimensional patterns of brightness values. Figure from US Navy Manual of Basic Optics and Optical Instruments, prepared by Bureau of Naval Personnel. Reprinted by Dover Publications, Inc., 1969. They are formed by the projection of 3D objects.

Distant objects appear smaller

Parallel lines meet vanishing point

Vanishing points H VPL VPR VP 1 VP 2 To different directions correspond different vanishing points VP 3