1
play

1 Translation and Scalling Matrice Translation o The translation - PDF document

3D Coordinate Systems 3D Transformation o The translation, scaling and rotation transformations used for 2D o 3D computer graphics involves the additional dimension of can be extended to three dimensions depth, allowing more realistic


  1. 3D Coordinate Systems 3D Transformation o The translation, scaling and rotation transformations used for 2D o 3D computer graphics involves the additional dimension of can be extended to three dimensions depth, allowing more realistic representations of 3D objects in the real world o In 3D, each transformation is represented by a 4x4 matrix o There are two possible ways of “attaching” the Z-axis, which o Using homogeneous coordinates it is possible to represent each gives rise to a left-handed or a right-handed system type of transformation in a matrix form and integrate transformations into one matrix o To apply transformations, simply multiply matrices, also easier in hardware and software implementation o Homogeneous coordinates can represent directions o Homogeneous coordinates also allow for non-affine transformations, e.g., perspective projection Homogeneous Coordinates Basic 2D Transformations   1 0 b o In 2D, use three numbers to represent a point o Translation: x   0 1 b   y (x,y) = (wx,wy,w) for any constant w ≠ 0 o     0 0 1   s 0 0 o To go backwards, divide by w, (x,y) becomes (x,y,1) x   o Scaling: 0 s 0   y o Transformation can now be done with matrix multiplication    0 0 1  ′       x a a b x  θ − θ  cos sin 0 xx xy x       ′   = y a a b y θ θ sin cos 0       o Rotation:   yx yy y          0 0 1        1 0 0 1 1 1

  2. Translation and Scalling Matrice Translation o The translation and scaling transformations may be represented in 3D as follows: 1 0 0 tr X Translation 0 1 0 tr Y original matrix 0 0 1 tr Z 0 0 0 1 S X 0 0 0 Scaling 0 S Y 0 0 matrix 0 0 S Z 0 0 0 0 1 V=(a i + b j +c k ) == (a, b, c) translation along y, or V = (0, k, 0) Scaling 3D Shearing Shearing: The change in each coordinate is a linear combination of all three Transforms a cube into a general parallelepiped Original scale all axes scale Y axis offset from origin ′       x 1 a b 0 x ′             x a 0 0 0 x ′ y c 1 d 0 y             ′ = y 0 b 0 0 y        ′      = z e f 1 0 z  ′            z 0 0 c 0 z             1 0 0 0 1 1  1   0 0 0 1   1  2

  3. Rotation Major Axis Rotation Matrices o In 2D, rotation is about a point   1 0 0 0   θ − θ o about X axis 0 cos sin 0   = R o In 3D, rotation is about a vector, which can be done through x  θ θ  0 sin cos 0   rotations about x, y or z axes  0 0 0 1   θ θ  Rotations are cos 0 sin 0 o Positive rotations are anti-clockwise, negative rotations are o about Y axis   orthogonal matrices, 0 1 0 0   clockwise, when looking down a positive axis towards the = R preserving distances and y  − θ θ  sin 0 cos 0 origin angles.     0 0 0 1 y y y o about Z axis θ − θ   cos sin 0 0   θ θ x sin cos 0 0 x   = x R   z 0 0 1 0     z 0 0 0 1 z z Rotation Rotation Axis o In general rotation vector does not pass through origin rotation of 45 o about the Z axis offset from origin translation then rotate about Z axis 3

  4. Rotation about an Arbitrary Axis Rotation about an Arbitrary Axis o Rotation about an Arbitrary Axis o Step 1. Translation Basic Idea Basic Idea y y 1. Translate (x 1 , y 1 , z 1 ) to the origin T 1. Translate (x 1 , y 1 , z 1 ) to the origin T  −  (x 2 ,y 2 ,z 2 ) (x 2 ,y 2 ,z 2 ) 1 0 0 x 2. Rotate (x’ 2 , y’ 2 , z’ 2 ) on to the z axis 1 2. Rotate (x’ 2 , y’ 2 , z’ 2 ) on to the z axis   R − R 0 1 0 y 3. Rotate the object around the z-axis   = 3. Rotate the object around the z-axis 1 T   T − 4. Rotate the axis to the original (x 1 ,y 1 ,z 1 ) R 0 0 1 z (x 1 ,y 1 ,z 1 ) 4. Rotate the axis to the original  1  orientation  0 0 0 1  orientation R -1 R -1 x x 5. Translate the rotation axis to the 5. Translate the rotation axis to the z original position z original position T -1 T -1 = − − − 1 1 1 [ T ] [ T ] [ T ] [ T ] [ T ][ T ][ T ][ T ] ( ) ( ) ( ) ( ) ( ) α φ θ φ α R T R R R R R T arb R x y z y x R Rotation about an Arbitrary Axis Rotation about an Arbitrary Axis [ ] o Step 3. Rotate about y axis by φ o Step 2. Establish T ( α R ) x b b y y a d α = = φ = φ = sin sin , cos + 2 2 d l l b c = + + = + 2 2 2 2 2 2 l a b c a d c c (0,b,c) α = = cos (a,b,c) (a,b,c) = + + d 2 2 2 2 d b c b c l Projected Projected α      φ − φ   −  α 1 0 0 0 1 0 0 0 cos 0 sin 0 d / l 0 a / l 0 Point Point         [ ] [ ] α − α − d 0 cos sin 0 0 c / d b / d 0 0 1 0 0 0 1 0 0 x     x     = = φ = = T T ( ) α  α α    φ     R ( ) R φ φ x 0 sin cos 0 0 b / d c / d 0 y sin 0 cos 0 a / l 0 d / l 0     (a,0,d)     z  0 0 0 1   0 0 0 1      0 0 0 1 0 0 0 1 Rotated Rotated z Point Point 4

  5. Rotation about an Arbitrary Axis Rotation about an Arbitrary Axis o Step 4. Rotate about z axis by the desired angle θ o Step 5. Apply the reverse transformation to place the axis back in its initial position y y     1 0 0 x 1 0 0 0 1     α α 0 1 0 y 0 cos sin 0     − − − = 1 1 1 1 [ T ] [ T ] [ T ] ( ) ( ) α φ      θ − θ  T R R − α α 0 0 1 z 0 sin cos 0 cos sin 0 0 R x y  1      l θ θ  0 0 0 1   0 0 0 1  [ ] sin cos 0 0   = T  φ φ  ( ) θ cos 0 sin 0   R z 0 0 1 0     0 1 0 0 l   l x   0 0 0 1 x  − φ φ  θ sin 0 cos 0     0 0 0 1 z z = − − − 1 1 1 [ T ] [ T ] [ T ] [ T ] [ T ][ T ][ T ][ T ] ( ) ( ) ( ) ( ) ( ) α φ θ φ α R T R R R R R T arb R x y z y x R Rotation about an Arbitrary Axis Rotation about an Arbitrary Axis o Step1. Translate point A (2,1,0) to the origin Find the new coordinates of a unit cube 90º-rotated about an axis defined by its endpoints A(2,1,0) and B(3,3,1). y −   1 0 0 2   − 0 1 0 1 B’(1,2,1)   = [ T ]   T R 0 0 1 0   A’(0,0,0)   x 0 0 0 1 z 5

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend