Homogeneous Transformation Ref: Richard Paul Chap. 1 1 Notation Vector: v Plane: P Discussion is in 3-space Frame: I, A Point in space: p Point p as a vector v in frame E: Ev Same point as a vector w in frame H: Hw 2 Vectors Homogeneous coordinate w Inner (dot) product Outer (cross) product [a,b,c,0]T: point at infinity 3 Planes Compared with ax+by+cz+d = 0 … Point v on a plane: [x/w,y/w,z/w] [a/m,b/m,c/m] -d/m 4 Transformation v = Hu With homogeneous coordinates, translate and rotation become linear transformations in R4 5 Plane Equation after Transformation Given the transform: Q (the plane P after transformation H): Proof: We require: (=0) 6 Example The plane P defined by these points: (0,0,2), (1,0,2), (0,1,2) is [0,0,1,-2] The transform H: Transformed points are (6,-3,7), (6,-2,7), (6,-3,8) The plane after transformation: 0 0 1 Q PH 0 0 1 2 1 0 1 0 0 0 0 3 1 7 1 0 0 6 0 4 0 1 How to compute H-1 (see next page) … 7 Inverse Transformation Assumption: [n o a] is orthogonal Verify: n n n o n a n p p n o n o o o a o p p o I T 1T a n a o a a a p p a 0 0 1 0 8 Recall Normal Matrix In OpenGL, normal vectors are transformed by normal matrix into eye space Normal matrix is the inverse transpose of modelview matrix (M-T) ne M T no neT noT M 1 Normal vector and plane equation are related! 9 Point rotation is closely related to coordinate transformation (next page) Rotating a Point x 2uˆ1 uˆ 2 uˆi Ruˆi , i 1,2 x A B x’ x 2uˆ1 uˆ 2 2 Ruˆ1 Ruˆ 2 (same coordinates in new bases) R 2uˆ1 uˆ 2 Rx cos(90) sin(90) 0 1 R sin( 90 ) cos( 90 ) 1 0 0 1 2 1 x 1 0 1 2 10 Coordinate Transformation 2 B R : Rotation that takes x A frame B to frame A 1 cos(90) sin(90) 0 1 B AR sin( 90 ) cos( 90 ) 1 0 A B B A 0 1 2 1 x R x 1 0 1 2 B A A x 11 Ex: Coordinate Transform x 1 0 A x 1, B x 1 1 1 B A A x ABT Bx A B T : T takingframeA toframeB 1 0 1 2 0 1 1 0 1 1 1 0 0 1 1 T Transl(2,1) Rot(90) A B 0 1 2 1 0 2 0 1 0 1 0 1 0 1 1 1 0 0 0 0 1 0 0 1 0 0 1 12 Ex: Coordinate Transform x A B 2 2 A x 1 , B x 0 1 1 B AT Transl( 1,2) Rot(90) 1 0 1 0 0 1 2 1 0 0 1 0 2 0 1 0 1 0 1 0 0 B B x AT 1 0 0 1 1 0 0 1 0 2 0 1 0 0 1 1 2 2 1 1 1 A x 13 Coordinate Transform glTranslatef (2,1,0); glRotatef (30,0,0,1); drawtank(); • Use the transformation of the tank (and its local coordinates) to find the world coordinates of specific points. GiveAx, Find W x xWAT Ax W W A T : T takingframeW toframeA A (3,0) W 1 0 W AT 0 0 0 1 0 0 0 0 1 0 2 cos30 sin 30 1 sin 30 cos30 0 0 0 1 0 0 0 0 1 0 0 cos30 sin 30 0 sin 30 cos30 0 0 0 1 0 0 0 0 1 0 tank • Implemented by SVL (ex: tip of tank) Vec3 X = proj (HTrans4(vec3(2,1,0))*HRot4(Vec3(0,0,1),30*3.14/180)*vec4(3,0,0,1); 14 2 1 0 1 Extra 15 Relative Transform & Frames Rot(z,90) Rot(y,90) Trans(4,-3,7) 16 Reference Frame 17 Reference Frame (cont) The transformed vector is the same vector described w.r.t. the reference frame 18 Transform Equation omit superscript s 19 Transform Equation OA AB = OB The Problem cos30 sin 30 4 23 O A sin 30 cos30 6 12 0 0 1 0 23 O 1 A 12 0 A 0 3 2 0 6 12 6 23 1 3 2 1 2 cos(30) sin(30) 12 23 O B sin(30) cos(30) 2 12 0 0 1 0 AB A O 4 4 1 2 3 2 4 6 1 12 B B A 23 1 2 0 O 0 34 14 23 0 3 2 3 4 14 0 0 12 2 1 1 O B 4 23 6 12 23 4 21 6 23 12 0 1 1 2 3 2 1 2 3 2 1 2 3 2 0 12 2 1 6 3 1 2 3 3 12 6 3 2 3 3 23 0 1 3 2 1 2 0 20 4 32 4 2 3 1