290 likes | 445 Views
Learn about transformations, scaling, rotation, shearing, and matrix operations in 3D graphics. Explore how to apply transformation matrices and manipulate objects effectively.
E N D
Transformations Given two frames in an affine space of dimension n, we can find a (n+1) x (n+1) matrix that converts the coor- dinates of a point in the first frame to the coordinates of the same point in the second frame. The opera- tion are called transformation. The matrix is called transformation matrix. In 3D space, for example, the general form of the matrix is 168 471 Computer Graphics, KKU. Lecture 5
Transformations: The Relationship • In 3D space • The matrix can be applied to - the coordinate,leaving the frame fixed. - the frame, leaving the coordinate fixed. • It is useful to allow us to shift a point between the local coordinates of the point, or between the frames 168 471 Computer Graphics, KKU. Lecture 5
Cramer’s Rule Given a frame and any point having coordinates (u,v,w), we can define a vector Cramer’s Rule states that and 168 471 Computer Graphics, KKU. Lecture 5
Consider two frames denoted as and By Cramer’s rule, let Finding a transformation matrix 1. If we give , then we can get 2. If we give , then we can get 3. If we give , then we can get 4. If we give , then we can get 168 471 Computer Graphics, KKU. Lecture 5
Simple Transformations • Translation • Scaling • Rotation • Shearing 168 471 Computer Graphics, KKU. Lecture 5
Translation • Moves all points of an objects a fixed distance in a specified direction. • Translation of frames the origin is moved but the vectors stay the same. • Translation of points within the frame 168 471 Computer Graphics, KKU. Lecture 5
Translation (Cont.) • A translation matrix is • The matrix is most frequently applied to all points of an object in the local system to move the object within the system. 168 471 Computer Graphics, KKU. Lecture 5
Scaling • Scales the coordinates of an objects • Scaling a frame - expands or contracts the lengths of the vectors • Scaling a point 168 471 Computer Graphics, KKU. Lecture 5
Scaling (Cont.) • A Scaling matrix • By scaling, you multiply each point of an object by a factor which effectively scaling the object about the origin. 168 471 Computer Graphics, KKU. Lecture 5
Scaling (Cont.) • If the center of the object is not at the origin, the operation will move the object away from the origin of the frame. 168 471 Computer Graphics, KKU. Lecture 5
Scaling (Cont.) • For the case of scaling about other points, we need to combine the scaling transformation with two translation transformations in order to correctly get a transformation matrix. 168 471 Computer Graphics, KKU. Lecture 5
Rotating about a point in two dimensions Rotation • performed about an axis which is usually specified by a point P and a vector direction . Rotation matrix 168 471 Computer Graphics, KKU. Lecture 5
Rotation about the X-Axis 168 471 Computer Graphics, KKU. Lecture 5
Rotation about the Y-Axis 168 471 Computer Graphics, KKU. Lecture 5
Rotation about the Z-Axis 168 471 Computer Graphics, KKU. Lecture 5
Rotation about an arbitrary axis • Assuming the axis of rotation is represented by and then a rotation of degrees about this axis can be defined by concatenating the following transformations 1. Translate so that the point P moves to the origin 168 471 Computer Graphics, KKU. Lecture 5
where Rotation about an arbitrary axis (Cont.) 2. Rotate the vector until it is in the yz plane by using a rotation 168 471 Computer Graphics, KKU. Lecture 5
where Rotation about an arbitrary axis (Cont.) 3. Rotate the vector until it coincides with the x axis 168 471 Computer Graphics, KKU. Lecture 5
Rotation about an arbitrary axis (Cont.) 4. Rotate about the z axis. 168 471 Computer Graphics, KKU. Lecture 5
Rotation about an arbitrary axis (Cont.) 5. Use rotations and translations to reverse the first three steps 168 471 Computer Graphics, KKU. Lecture 5
The matrix representation of the general rotation is given by the product of the above transformations. Rotation about an arbitrary axis (Cont.) 168 471 Computer Graphics, KKU. Lecture 5
Shearing • Shearing transformations in three-dimensions alter two of the three coordinate values proportionally to the value of the third coordinate. 168 471 Computer Graphics, KKU. Lecture 5
X-Shearing • X-shearing a frame: We ``x-shear'' a frame by modifying the first vector of the frame by adding to it a linear combination of the other two vectors. 168 471 Computer Graphics, KKU. Lecture 5
X-Shearing (Cont.) • X-shearing a point • The X-shear transformation matrix can be defined by 168 471 Computer Graphics, KKU. Lecture 5
Y-Shearing • Y-shearing a frame 168 471 Computer Graphics, KKU. Lecture 5
Y-Shearing (Cont.) • Y-shearing a point • The Y-shear transformation matrix can be defined by 168 471 Computer Graphics, KKU. Lecture 5
Z-Shearing • Z-shearing a frame 168 471 Computer Graphics, KKU. Lecture 5
Z-Shearing (Cont.) • Z-shearing a point • The Z-shear transformation matrix can be defined by 168 471 Computer Graphics, KKU. Lecture 5