1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.

Slides:



Advertisements
Similar presentations
Lecture 7 2D Transformation. What is a transformation? Exactly what it says - an operation that transforms or changes a shape (line, shape, drawing etc.)
Advertisements

Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
1 Computer Graphics Chapter 8 3D Transformations.
1 3D modelling with OpenGL Brian Farrimond Robina Hetherington.
CS 376 Introduction to Computer Graphics 02 / 26 / 2007 Instructor: Michael Eckmann.
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
OpenGL (II). How to Draw a 3-D object on Screen?
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
CAP4730: Computational Structures in Computer Graphics
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.
UNIT - 5 3D transformation and viewing. 3D Point  We will consider points as column vectors. Thus, a typical point with coordinates (x, y, z) is represented.
CS324e - Elements of Graphics and Visualization Java2D Graphics.
Basic graphics. ReviewReview Viewing Process, Window and viewport, World, normalized and device coordinates Input and output primitives and their attributes.
UniS CS297 Graphics with Java and OpenGL Viewing, the model view matrix.
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.
1 CMT Fundamentals of Computer Graphics Revision Dr. Xiaohong Gao BG---Room 2C23 Week 11.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Week 2 - Wednesday CS361.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Lecture 3 Transformations.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Part7: Geometric Transformations
Geometric transformations The Pipeline
 2D Transformations 2D Transformations  Translation Translation  Rotation Rotation  Scaling Scaling.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
1 Computer Graphics Week9 -3D Geometric Transformation.
CS 376 Introduction to Computer Graphics 02 / 23 / 2007 Instructor: Michael Eckmann.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
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.
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
2D Geometric Transformation Translation A translation is applied to an object by repositioning it along a straight-line path from one coordinate location.
CISC 110 Day 3 Introduction to Computer Graphics.
Introduction to Computer Graphics: Viewing Transformations Rama C
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Computer Graphics Matrices
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
MOHR'S CIRCLE The formulas developed in the preceding article may be used for any case of plane stress. A visual interpretation of them, devised by the.
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.
Homogeneous Coordinates and Matrix Representations Cartesian coordinate (x, y, z) Homogeneous coordinate (x h, y h, z h, h) Usually h = 1. But there are.
Computer Graphics I, Fall 2010 Transformations.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Revision Sheet Computer Graphics and Human Interaction By Dr. HANY ELSALAMONY1.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
OpenGL LAB III.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
CSCE 441 Computer Graphics: 2D Transformations
Computer Graphics Lecture 41 Viewing Using OpenGL Taqdees A. Siddiqi
Computer Graphics Lecture 42 Viewing Using OpenGL II Taqdees A. Siddiqi
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Objectives Introduce standard transformations Introduce standard transformations Derive homogeneous coordinate transformation matrices Derive homogeneous.
Geometric Transformations
Summary of Properties of 3D Affine Transformations
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Computer Graphics Imaging
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Viewing/Projections I Week 3, Fri Jan 25
Transformations Translation Reflection The FRAME Routine
Presentation transcript:

1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling

2D Object Transformations The functions used for modifying the size, location, and orientation of objects or of the camera in a CG world are called geometric transformations. Transformations are applied within a particular space domain, be it an object space or the camera space or a texture space. We shall mainly be discussing transformations applied in the object space, also called object transformations or model transformations. 2

Object Space Usually, objects are defined in a default coordinate system convenient to the modeler. This coordinate system is called the object coordinate system or object space. 3

The object coordinate system can be transformed, in order to transform the object within the world coordinate system. An object transformation sets the state of the object space. Internally, this state is represented as a matrix. 4

All the objects drawn on the screen after this state is set are drawn with the new transformations applied. Transformations make it convenient to move objects within the world, without actually having to model the object again! 5

Object space is transformed within the world coordinate system. 6

There are three kinds of transformations most commonly in CG: translation, rotation, and scaling. 7

1-Translation Translation is the transform applied when we wish to move an object. In a 2D world, we can move the object from left to right (translate along the x-axis) or up and down (translate along the y-axis). The abbreviations for these translations are Tx and Ty. 8

Translation along the x- and y-axes 9

As in previous figure, If we wish to move P by a distance of (tx, ty) then all points P(x, y) on this shape will move to a new location. If we define the vector for a given points P(x, y) as: and the translation vector as 10

then the resultant transformed point P‘ is the vector represented as: Or more precisely 11

Mathematically, we can translate an object by applying this equation to every point on the object. Usually, we can get away with just applying the translation to the vertices of the shape and then recalculating the translated shape. 12

an example of a bouncing ball First you may recall how to draw a circle: 13

we use this function to draw a brown ball centered at the origin with the radius of the ball set to be 15 units in our world coordinate system: 14

We want to bounce this ball up and down in our display window. That is, we wish to translate it along the y-axis. The floating-point routine for performing translations in OpenGL is 15

It accepts three arguments for translation along the x-, y-, and z-axes respectively. The z-axis is used for 3D worlds, and we can ignore it for now by setting the Tz value to be 0. Before we apply a new translation, we need to set the transformation state in the object space to be an identity matrix (i.e., no transformation is being applied).The command 16

clears out the current transformation state with the identity matrix. We do this because we do not wish to reuse old transformation states. Then, we constantly add (or subtract) to the ty component along the y-axis, and draw the ball in this newly transformed position. 17

The sub code to translate an object in a window with the maximum extent of the world coordinates set to (160,120) is shown below. A ydir variable is used to define whether the ball is bouncing up or down (and hence whether we should increment or decrement ty). 18

19

Camera (or viewing) and object transformations are combined into a single matrix in OpenGL, called the model-view matrix (GL_MODELVIEW). The command: specifies the space where the transformations are being applied. The mode is normally set in the reshape function where we also set the clipping area of the window. 20

Double Buffering Double buffering provides two frame buffers for use in drawing. One buffer, called the foreground buffer is used to display on the screen. The other buffer, called the background buffer, is used to draw into. 21

When the drawing is complete, the two buffers are swapped so that the one that was being viewed is now being used for drawing and vice versa. The swap is almost instantaneous. Since the image is already drawn when we display it on screen, it makes the resulting animation look smooth, and we don't see incomplete images. 22

The only change in the required to activate double buffering is to specify the display mode to be This call is made in the main function of last example of ball. By default, in double buffer mode, OpenGL renders all drawing commands into the background buffer. 23

A call to will cause the two buffers to be swapped. After they are swapped, we need to inform OpenGL to redraw the window (using the new contents of the foreground buffer). The function forces a re-draw of the window. The code required to display the bouncing ball is as follows: 24

25

2- Scaling 26

we show the circular shape being scaled by (1/2,2) and by (2,1/2). Notice from the coming figure that scaling changes the bottom (base) position of the shape. This is because the scaling equation we defined occurs around the origin of the world coordinate system. 27

Scaling of a circle 28

That is, only points at the origin remain unchanged. Many times it is more desirable to scale the shape about some other predefined point. In the case of a bouncing ball, we may prefer to scale about the bottommost point of the ball because we want the base of the shape to remain unchanged. 29

When the ball hits the ground we want it to squash on impact and then stretch back up again into its original shape. This is what we expect from a real (soft) ball bouncing on the ground. The floating point command to scale an object is 30

which accepts three arguments for scaling along the x-, y- and z-axes. Scaling has no effect when Sx=Sy=Sz=l. For now, we will set the Sz to be 1. When the ball hits the ground, and for some time afterwards, we stop translating and squash the shape. 31

That is, we scale down the shape along the y- axis and proportionately scale up along the x- axis. When we reach a predetermined squash, we stretch back up again and restart the translation. Shown below is the code to perform this transformation: 32

33