1 Computer Graphics Week7 -2D Rotation. 3-Rotation A shape can be rotated about any of the three axes. A rotation about the z-axis will actually rotate.

Slides:



Advertisements
Similar presentations
Transformations Ed Angel Professor Emeritus of Computer Science
Advertisements

COMPUTER GRAPHICS 2D TRANSFORMATIONS.
Geometric Transformations
1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.
8. 2D Coordinate Operations Assoc.Prof.Dr. Ahmet Zafer Şenalp Mechanical Engineering Department Gebze.
25 May May May 2015Week 5-2D Transformations1 2D Transformations By: KanwarjeetSingh.
CMPE 466 COMPUTER GRAPHICS
Transformations II Week 2, Wed Jan 17
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
CS 4731: Computer Graphics Lecture 7: Introduction to Transforms, 2D transforms Emmanuel Agu.
CS 376 Introduction to Computer Graphics 02 / 09 / 2007 Instructor: Michael Eckmann.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
2D/3D Geometric Transformations CS485/685 Computer Vision Dr. George Bebis.
2.1 si SI31 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Introduction to Robotics Lecture II Alfred Bruckstein Yaniv Altshuler.
Now Playing: Gong Sigur Rós From Takk... Released September 13, 2005.
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Computer Graphics with OpenGL 3e
2D transformations and homogeneous coordinates Dr Nicolas Holzschuch University of Cape Town Modified.
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
CAP4730: Computational Structures in Computer Graphics
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
CS 450: Computer Graphics 2D TRANSFORMATIONS
1 Matrix Math ©Anthony Steed Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices.
Mathematical Fundamentals
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Lecture Notes: Computer Graphics.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Lecture 3 Transformations.
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
Part7: Geometric Transformations
Geometric Transformations
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
Geometric Objects and Transformation
1 Computer Graphics Week9 -3D Geometric Transformation.
Geometric Transformations
Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.
Lecture 3 Transformations. 2D Object Transformations The functions used for modifying the size, location, and orientation of objects or of the camera.
Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Geometric Transformations UBI 516 Advanced Computer Graphics Aydın Öztürk
Affine Geometry.
Computer Graphics Matrices
II-1 Transformations Transformations are needed to: –Position objects defined relative to the origin –Build scenes based on hierarchies –Project objects.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 By Dr. HANY ELSALAMONY.  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations.
III- 1 III 3D Transformation Homogeneous Coordinates The three dimensional point (x, y, z) is represented by the homogeneous coordinate (x, y, z, 1) In.
Computer Graphics I, Fall 2010 Transformations.
2D Transformation Homogenous Coordinates Scale/Rotate/Reflect/Shear: X’ = XT Translate: X’ = X + T Multiple values for the same point e.g., (2, 3, 6)
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
CS 325 Introduction to Computer Graphics 02 / 19 / 2010 Instructor: Michael Eckmann.
End effector End effector - the last coordinate system of figure Located in joint N. But usually, we want to specify it in base coordinates. 1.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Transformations Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Computer Graphic 2 D Transformation.
CSCE 441 Computer Graphics: 2D Transformations
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
Objectives Introduce standard transformations Introduce standard transformations Derive homogeneous coordinate transformation matrices Derive homogeneous.
Transforms.
2D Transformations By: KanwarjeetSingh
Computer Graphics CC416 Week 15 3D Graphics.
2D Transformations y y x x y x.
Transformations.
Using Matrices to Perform Geometric Transformations
Presentation transcript:

1 Computer Graphics Week7 -2D Rotation

3-Rotation A shape can be rotated about any of the three axes. A rotation about the z-axis will actually rotate the shape in the xy-plane, which is what we desire in our 2D world. The points are rotated through an angle about the world origin as shown in figure. 2

3 Rotation of shape

Mathematically, a rotation about the z-axis by an angle Θ would result in point P (x, y) transforming to P' (x', y') as defined below: Where R is the rotation matrix 4

Positive angles are measured counterclockwise from x toward y. Just like scaling, rotation occurs about the world origin. Only points at the origin are unchanged after the rotation transformation. The OpenGL routine for rotation is: 5

It expects the angle of rotation in degrees and a nonzero vector value about which you wish the rotation to occur. For rotations in the xy-plane, we would set vx=vy=O and vz =1 (i.e., the unit vector along the z-axis) 6

Let us go back to our bouncing ball example. Of course, rotating a round ball will have no effect on the ball. Let us redefine the draw-ball routine to draw an elongated ball. 7

To rotate the ball while it's bouncing, we add the following lines of code to our Display function: 8

Homogenous Coordinates and Composition of Matrix Transformations We have seen the different vector/matrix representations for translation, scaling, and rotation. With homogenous coordinates, we add a third coordinate to a (2D) point. Instead of being represented by a pair of numbers (x, y), each point is now represented by a triplet (x, y, W), or in vector notation as: 9

To go from homogenous coordinates back to our original non-homogenous world, we just divide the coordinates by W. So the homogenous point represented by: is equal to the point (x/W, y/W). Two points of homogenous coordinates (x,y, W) and (x ',y ', W') are the same point if one is a multiple of the other. 10

So, for example, (1,2,1) and (2,4,2) are the same points represented by different coordinate triples. The points with W=O are points at infinity and will not appear in our discussions. 11

Because 2D points are now three element column vectors, transformation matrices used to transform a point to a new location must be of cardinality 3x3. In this system, the translation matrix T is defined as: 12

Any point P (x, y, W) that is translated by the matrix T results in the transformed point P' defined by the matrix-vector product of T and P: 13

The Scale transformation matrix (S) in homogenous coordinates is defined as: 14

Each of these matrices can be multiplied successively by the homogenized points of our object to yield the final transformed points. For example, suppose that points on shape P are translated by a translation matrix T1 and then by T2. The net result should be the translation (T1+T2). Verify that the equation: 15

Let us apply the composition principle to the ball shape under discussion. For the example of squashing the ball upon contact with the ground. Remember that the ball seemed to jump when we squashed it. To avoid this jump, we wish to scale the ball about its bottom most point. In other words, we wish the bottommost point to stay at the same place when we squash the ball. 16

Translate shape by TI 17

From our study of transformations, we know how to scale the ball about the world origin (which is where the center of the ball is located). To transform the ball about its base, we can convert this problem into three basic transformations: First, move the ball so that the desired fixed point of scaling (the base in this case) point Pl (x1, y1) is at the origin, by applying translation matrix TI. 18

Second we scale the shape as usual by applying a scaling transform S. The scaling occurs about the origin, which is now where the base of the ball is positioned. Finally, we translate the shape back such that P1 returns to its original point, i.e. we apply a translation transform T2 = -TI. we have scaled the shape keeping the bottommost point P1 (x1,yl) fixed. 19

Translate shape back to original location 20

Effectively, we have scaled the shape about the pivot point PI. Rotating a shape about a point works on the same principle. First translate the shape so that the point of rotation is at the origin. Apply the rotation and translate the shape back to its original location. 21

Translate shape back to original location. 22

The composite matrix to compute this entire transformation can be calculated as: M = T2.S.T1 This composite matrix can be applied to the shape in one step to achieve the desired result. In general, the order of composing the transforms is important. If we change the order, different results will appear. 23