3D Coordinate Systems 3D Transformation o 3D computer graphics involves the additional dimension of o The translation, scaling and rotation transformations used for 2D depth, allowing more realistic representations of 3D objects can be extended to three dimensions 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 o In 2D, use three numbers to represent a point o Translation: 1 0 b x 0 1 b y o (x,y) = (wx,wy,w) for any constant w≠0 0 0 1 o To go backwards, divide by w, (x,y) becomes (x,y,1) sx 0 0 o Scaling: 0 s 0 y o Transformation can now be done with matrix multiplication 0 0 1 x′ a a b x xx xy x cosθ − sinθ 0 y′ = a a b y sinθ cosθ 0 yx yy y o Rotation: 0 0 1 1 0 0 1 1 1 Translation and Scalling Matrice Translation o The translation and scaling transformations may be represented in 3D as follows: 1 0 0 trX Translation 0 1 0 trY original matrix 0 0 1 trZ 0 0 0 1 S 0 0 0 Scaling X matrix 0 SY 00 0 0 SZ 0 0 0 0 1 V=(ai + bj +ck) == (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 0x x′ a 0 0 0x y′ c 1 d 0y y′ 0 b 0 0y = = z′ e f 1 0z z′ 0 0 c 0z 1 0 0 0 11 1 0 0 0 11 2 Rotation Major Axis Rotation Matrices o In 2D, rotation is about a point 1 0 0 0 0 cosθ − sinθ 0 o about X axis 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 cosθ 0 sinθ 0 Rotations are 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 − θ θ origin sin 0 cos 0 angles. 0 0 0 1 y y y o about Z axis cosθ − sinθ 0 0 sinθ cosθ 0 0 x x = x R z 0 0 1 0 0 0 0 1 z z z Rotation Rotation Axis o In general rotation vector does not pass through origin rotation of 45o about the Z axis offset from origin translation then rotate about Z axis 3 Rotation about an Arbitrary Axis Rotation about an Arbitrary Axis o Rotation about an Arbitrary Axis o Step 1. Translation y BasicBasic IdeaIdea y 1. Translate (x1, y1, z1) to the origin TT 1. Translate (x1, y1, z1) to the origin (x2,y2,z2) (x2,y2,z2) 1 0 0 − x 2.2. Rotate Rotate (x’ (x’2, ,y’ y’2, ,z’ z’2)) on on to to the the z z axis axis 1 R 2 2 2 R 3. Rotate the object around the z-axis 0 1 0 − y 3. Rotate the object around the z-axis T = 1 TR 4. Rotate the axis to the original 1 1 1 − (x1,y1,z1) 4. Rotate the axis to the original (x ,y ,z ) 0 0 1 z1 orientation -1 orientation 0 0 0 1 x RR-1 x 5.5. Translate Translate the the rotation rotation axis axis to to the the z -1 originaloriginal position position z TT-1 −1 −1 −1 [T ] = [T ] [T (α )] [T ()φ ] [T ()θ ][T ()φ ][T (α )][T ] Rarb TR Rx Ry Rz Ry Rx TR Rotation about an Arbitrary Axis Rotation about an Arbitrary Axis o Step 2. Establish o Step 3. Rotate about y axis by φ [T α ] Rx ( ) y b b y a d sin α = = sin φ = , cosφ = b2 + c2 d l l l 2 = a2 + b2 + c2 = a 2 + d 2 (0,b,c) α = c = c (a,b,c) cos (a,b,c) b2 + c2 d d = b2 + c2 Projected α Projected l φ − φ − Point α 1 0 0 0 1 0 0 0 Point cos 0 sin 0 d / l 0 a / l 0 0 cosα − sinα 0 0 c / d − b / d 0 d 0 1 0 0 0 1 0 0 x []= = φ x []= = TR (α ) T ()φ x 0 sinα cosα 0 0 b / d c / d 0 Ry φ φ (a,0,d) sin 0 cos 0 a / l 0 d / l 0 z 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 Rotated Rotated Point z Point 4 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 x1 1 0 0 0 α α −1 −1 −1 0 1 0 y1 0 cos sin 0 [T ] [T ()α ] [T ()φ ] = TR Rx Ry − α α cosθ − sinθ 0 0 0 0 1 z1 0 sin cos 0 l sinθ cosθ 0 0 0 0 0 1 0 0 0 1 []T ()θ = φ φ Rz cos 0 sin 0 0 0 1 0 l 0 1 0 0 x l θ 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 ] Rarb TR Rx Ry Rz Ry Rx TR 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 B’(1,2,1) 0 1 0 −1 [T ] = TR 0 0 1 0 A’(0,0,0) x 0 0 0 1 z 5 Rotation about an Arbitrary Axis Rotation about an Arbitrary Axis o Step 2. Rotate axis A’B’ about the x axis by and angle α, until it lies o Step 3. Rotate axis A’B’’ about the y axis by and angle φ, on the xz plane. until it coincides with the z axis. α = 2 = 2 = 2 5 sin φ = 1 = 6 22 +12 5 5 sin y 6 6 1 5 cos α = = 5 30 y 5 5 cos φ = = 6 6 Projected point (0,2,1) B’(1,2,1) = 2 + 2 + 2 = l 1 2 1 6 l 30 − 6 α l φ x 0 0 1 0 0 0 (0,0,√6) 6 6 x 5 2 5 √ []= 0 1 0 0 − B”(1,0, 5) TR ()φ 0 0 y 6 30 z √ []= 5 5 0 0 B”(1,0, 5) TR ()α x 2 5 5 z 6 6 0 0 0 0 0 1 5 5 0 0 0 1 Rotation about an Arbitrary Axis Rotation about an Arbitrary Axis ° o Step 4. Rotate the cube 90 about the z axis 1 0 0 0 30 6 − 1 0 0 2 5 2 5 0 00 1 0 0 0 0 6 6 − 0 1 0 1 1 0 0 0 0 1 0 0 [T ] = 5 5 0 1 0 0 Rarb 0 0 1 0 2 5 5 6 30 0 0 1 0 0 − 0− 0 0 1 0 0 0 0 0 0 1 5 5 6 6 0 0 0 1 []T ()° = 0 0 0 1 0 0 0 1 Rz 90 0 0 1 0 1 0 0 0 30 − 6 − 0 0 5 2 5 1 0 0 2 0 0 0 1 6 6 0 − 0 0 1 0 −1 0 1 0 0 5 5 6 30 2 5 5 0 0 1 0 0 00 0 Finally, the concatenated rotation matrix about the arbitrary axis AB becomes, 6 6 5 5 0 0 0 1 0 0 0 10 0 0 1 − − − 1 1 1 0.166 − 0.075 0.983 1.742 [T ] = [T ] [T ()α ] [T ()φ ] [T ][T ()φ ][T ()α ][T ] Rarb TR Rx Ry R ()90o Ry Rx TR z 0.742 0.667 0.075 −1.151 = − 0.650 0.741 0.167 0.560 0 0 0 1 6 Rotation about an Arbitrary Axis Rotation about an Arbitrary Axis o Multiplying [TR]AB by the point matrix of the original cube o Reflection Relative to the xy Plane x' 1 0 0 0 x * y y [P ]=[T ]⋅[]P y' 0 1 0 0 y Rarb = z z' 0 0 − 1 0 z 1 0 0 0 1 1 0.166 − 0.075 0.983 1.742 0 0 1 1 0 0 1 1 z x x 0.742 0.667 0.075 −1.1511 1 1 1 0 0 0 0 []P* = o Z-axis Shear − 0.650 0.741 0.167 0.560 1 0 0 1 1 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 x' 1 0 a 0 x 2.650 1.667 1.834 2.816 2.725 1.742 1.909 2.891 y' 0 1 b 0 y = − 0.558 − 0.484 0.258 0.184 −1.225 −1.151 − 0.409 − 0.483 = z' 0 0 1 0 z 1.467 1.301 0.650 0.817 0.726 0.560 − 0.091 0.076 1 0 0 0 11 1 1 1 1 1 1 1 1 Q1 - Translate by <1, 1, 1> Q2- Rotate by 45 degrees about x axis o A translation by an offset (tx, ty, tz) is achieved o So to rotate by 45 degrees about the x-axis, we using the following matrix: use the following matrix: 1 0 0 0 1 0 0 tx 1 0 0 0 1 − 1 0 1 0 t o So to translate by a vector 0 0 = y 0 cos 45 − sin 45 0 2 2 M T (tx ,ty ,tz ) (1, 1, 1), the matrix is simply: R (45) = = 0 0 1 t x 1 1 z 0 sin 45 cos 45 0 0 0 0 0 0 1 1 0 0 1 0 0 0 1 2 2 0 0 0 1 0 1 0 1 M (1,1,1) = T 0 0 1 1 0 0 0 1 7 Q3 - Rotate by 45 about axis <1, 1, 1> Q3 - Arbitrary Axis Rotation o So a rotation by 45 degrees about <1, 1, 1> can o The composite transformation can then be be achieved by a few succesive rotations about obtained as follows: the major axes.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages9 Page
-
File Size-