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