Composite Transformation: Composite objects are several objects and scripts bundled together exposed to the application as a single object. There are number.

Slides:



Advertisements
Similar presentations
Computer Graphics 2D & 3D Transformation.
Advertisements

What is shape function ? shape function is a function that will give the displacements inside an element if its displacement at all the node locations.
Graohics CSC 171 FALL 2001 LECTURE 16. History: COBOL Conference on Data System Languages (CODASYL) - led by Joe Wegstein of NBS developed the.
Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce.
1 Powers of Two: Trace Ex. Print powers of 2 that are  2 N. Increment i from 0 to N. Double v each time. int i = 0; int v = 1; while (i
Linear Algebra and SVD (Some slides adapted from Octavia Camps)
1 3D modelling with OpenGL Brian Farrimond Robina Hetherington.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
Flowcharts Remember that a solution to a problem is called an algorithm. Algorithms are often a series of steps required to solve the problem. A flowchart.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 OpenGL Transformations Ed Angel Professor of Computer Science, Electrical and Computer.
1 Geometrical Transformation Tong-Yee Lee. 2 Modeling Transform Specify transformation for objects Allow definitions of objects in own coordinate systems.
Math for CSLecture 11 Mathematical Methods for Computer Science Lecture 1.
Math for CSTutorial 11 Matrix Multiplication Rule Matrices make linear transformations of vectors.
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.
2D Transformation of Graphics
Lecture Notes: Computer Graphics.
Mathematics for Computer Graphics. Lecture Summary Matrices  Some fundamental operations Vectors  Some fundamental operations Geometric Primitives:
Lecture 3 Transformations.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
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.
C++ Programming: Basic Elements of C++.
1 Computer Graphics Week9 -3D Geometric Transformation.
Chapter 9 Transformations.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Review Inheritance Overloading and overriding. example1.pde.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
Computer Graphics I, Fall 2010 OpenGL Transformations.
Computer Graphics 3D Transformations. Translation.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
LESSON 5-1 I can draw reflected images. I can recognize and draw lines of symmetry.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Chapter 9 - Transformations. 90 degree rotation (x 1, y 1 ) 180 degree rotation (x 2, y 2 ) 270 degree rotation (x 3, y 3 )
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
Sum of Arithmetic Sequences. Definitions Sequence Series.
 An image is the new figure, and the preimage is the original figure  Transformations-move or change a figure in some way to produce an image.
1 OpenGL Transformations. 2 Objectives Learn how to carry out transformations in OpenGL ­Rotation ­Translation ­Scaling Introduce OpenGL matrix modes.
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
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.
1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
Computer Graphic 2 D Transformation.
COMPUTER GRAPHICS AND LINEAR ALGEBRA AN INTRODUCTION.
Robotic Arms and Matrices By Chris Wong and Chris Marino.
FCC Graficación CAD/CAM 3D Transformations. Contents 1. Translation 2. Scaling 3. Rotation 4. Other Transformations.
Input, Output and Variables GCSE Computer Science – Python.
TRANSFORMATIONS.
Transforms.
OpenGL Transformations
Geometric Transformations Hearn & Baker Chapter 5
2D Geometric Transformations
3D Transformation.
3D Geometric Transformations
Computing Fundamentals
OpenGL Transformations
Computer Graphics OpenGL Transformations
Lecture 7 Geometric Transformations (Continued)
Computer Graphics Transformations
Line and Character Attributes 2-D Transformation
مساق: خوارزميات ومبادئ البرمجة الفصل الدراسي الثاني 2016/2015
Computer Graphics Lecture 20
Transformations in OpenGL
Translate, Rotate, Matrix
OpenGL Transformations
Question 29.
OpenGL Transformations
Presentation transcript:

Composite Transformation: Composite objects are several objects and scripts bundled together exposed to the application as a single object. There are number of transformations performed on any object. The object undergoes sequence of transformation in series and the points of every transformation become input to the next transformation. For example, a line can be scaled in the beginning then it is translated to a new position and subsequently rotated about origin. Then such a transformation can be represented by_ x1’, y1’, 1 x1, y1, 1 [Tr1] [Tr2] [Tr3] x2’, y2’, 1 x2, y2, 1 Where, [Tr1] = [S ] = scaling matrix [Tr2] = [T] = translation matrix [Tr3] = [R] = rotation matrix In this transformation a line is drawn between the two points by using ‘line_draw’ function. This line is scaled by using [b] matrix the scaling matrix and the operation of multiplication of [a]*[b] is performed by ‘matmult’ and ‘change’ functions resubstitite [c] matrix into [a] matrix and then line is redrawn by using the same ‘line_draw’ function.

Then, further the line is translated by using ‘trans’ function and the operation is performed similarly by ‘matmult’ and ‘change’ function. The ‘line_draw’ function draws the line. The line is further rotated by an angle of ’25 degree ’ using ‘rotate’ function and similar way operation is performed by ‘matmult’ and ‘change’ function. Composite Transformations: A composite transformation is a sequence of transformations, one followed by the other. Consider the matrices and transformations in the following list: Matrix A Rotate by an angle Matrix B Scale by a factor of sx and sy Matrix C Translate in the x,y direction

FLOWCHART: TO DRAW COMPOSIT OBJECT. Start float pi=22.0/7.0,l=3,m=2,n=3,a[2][3]={{115,80,1}{140,140,1}}, b[20,20],c[20][20]; float i,j,k,sum=0.0;double x,y,h=50,v=100,sx=1,sy=2; float theta=25; double atheta=pi*theta/180.0; line(a[0][0],a[0][1],a[1][0],a[1][1]); outtextxy(400,300,”press any key to scale”); b[0][0]=sx;b[0][1]=0.0;b[0][2]=0.0; b[1][0]=0.0;b[1][1]=sy;b[1][2]=0.0; b[2][0]=0.0;b[2][1]=0.0;b[2][2]=1.0; getch(); for(i=0.0;i<m;++i) for(k=0;k<l;++k) for(j=0;j<n;++j) sum+=(a[i][j]*b[j][k]); false true c[i][k]=sum; false true false

Continue… for(i=0.0;i<m;++i) for(k=0.0;k<l;++k) a[i][k]=c[i][k]; false true false line(a[0][0],a[0][1],a[1][0],a[1][1]); outtextxy(400,360,”press any key to translate”); b[0][0]=1.0;b[0][1]=0.0;b[0][2]=0.0; b[1][0]=0.0;b[1][1]=1.0;b[1][2]=0.0; b[2][0]=h;b[2][1]=v;b[2][2]=1.0; getch(); for(i=0.0;i<m;++i) for(k=0;k<l;++k) c[i][k]=sum; for(j=0;j<n;++j) sum+=(a[i][j]*b[j][k]); false true

for(i=0.0;i<m;++i) for(k=0.0;k<l;++k) a[i][k]=c[i][k]; false true false line(a[0][0],a[0][1],a[1][0],a[1][1]); outtextxy(400,370,”press any key to rotate”); x=sin(atheta); y=cos(atheta); b[0][0]=y;b[0][1]=x;b[0][2]=0.0; b[1][0]=-x;b[1][1]=y;b[1][2]=0.0; b[2][0]=0.0;b[2][1]=0.0;b[2][2]=1.0; getch(); for(i=0.0;i<m;++i) for(k=0;k<l;++k) c[i][k]=sum; for(j=0;j<n;++j) sum+=(a[i][j]*b[j][k]); false true Continue…

for(i=0.0;i<m;++i) for(k=0.0;k<l;++k) a[i][k]=c[i][k]; false true false line(a[0][0],a[0][1],a[1][0],a[1][1]); outtextxy(400,380,”press any key to close”); Output stop Continue…

Explanation: Start of program Define data type, initialize variables Draw a line according to coordinates Print this message on given position a and b are two matrix and c is resultant matrix, h and v are translating factors corresponding to x and y direction increments, sx and sy are scaling factors in x and y direction, theta and atheta are rotation angle Define Scaling matrix matrix a and b is multiplied and c holds result Change the position of line and the value of c is assigned to a Draw a scaled line on given position Print this message on given position Define translation matrix matrix a and b is multiplied and c holds result

connector Change the position of line and the value of c is assigned to a Draw a translated line on given position Print this message on given position x and y are rotation angle Define rotation matrix matrix a and b is multiplied and c holds result Change the position of line and the value of c is assigned to a Draw a rotated line on given position Print this message on given position Display a translated, scaled and rotated line on screen. End of program Continue…

Program: /*composite transformation*/ /*program to scaling,translation,rotate a line about origin*/ //include header files #include #define pi(22.0/7.0) int driver,mode; /*data type defined that must be integer type variable*/ /*define variables that is used in program*/ float pi=22.0/7.0; float l=3,m=2,n=3; float a[2][3]={{115,80,1},{140,140,1}}; float b[20][20],c[20][20]; double x,y,h,v,sx,sy; /*define prototype of functions*/ void line_draw(void); void scale(void); void matmult(void); void change(void); void trans(void); void rotate(void); //main program void main() { float theta; double atheta; detectgraph(&driver,&mode); /*driver and modes are set*/ initgraph(&driver,&mode,"\\BGI"); /*graphic mode is initialized*/ line_draw(); //calling function call to line_draw function outtextxy(400,350,"press any key to scale"); sx=1,sy=2; /*scaling factor in x,y direction*/

//calling functing scale(); matmult(); change(); line_draw(); outtextxy(400,360,"press any key to translate"); h=50;v=100; /*h and v are x and y direction increments*/ //calling functions trans(); matmult(); change(); line_draw(); outtextxy(400,370,"press any key to rotate"); /*rotation angle*/ theta=25; atheta=pi*theta/180.0; x=sin(atheta); y=cos(atheta); //calling functions rotate(); matmult(); change(); line_draw(); outtextxy(400,380,"press any key to close"); getch(); /*display output*/ restorecrtmode(); /*restore the screen to the mode */ } /*closing braces*/ /*line function, to draw aline*/ void line_draw() { line(a[0][0],a[0][1],a[1][0],a[1][1]); }

/*scale function, to increase the size of line */ void scale() { b[0][0]=sx;b[0][1]=0.0;b[0][2]=0.0; b[1][0]=0.0;b[1][1]=sy;b[1][2]=0.0; b[2][0]=0.0;b[2][1]=0.0;b[2][2]=1.0; getch(); } /*translate function, to change the position of line in x and y direction*/ void trans() { b[0][0]=1.0;b[0][1]=0.0;b[0][2]=0.0; b[1][0]=0.0;b[1][1]=1.0;b[1][2]=0.0; b[2][0]=h;b[2][1]=v;b[2][2]=1.0; getch(); } /*rotate function, to rotate a line by an angle*/ void rotate() { b[0][0]=y;b[0][1]=x;b[0][2]=0.0; b[1][0]=-x;b[1][1]=y;b[1][2]=0.0; b[2][0]=0.0;b[2][1]=0.0;b[2][2]=1.0; getch(); } /*matrix multiplication function*/ void matmult() { float i,j,k,sum; for(i=0.0;i<m;++i) { for(k=0;k<l;++k) { sum=0.0; for(j=0;j<n;++j) { sum+=(a[i][j]*b[j][k]); }

c[i][k]=sum; } /*change function, to change the position of line*/ void change() { float i,k; for(i=0.0;i<m;++i) { for(k=0.0;k<l;++k) { a[i][k]=c[i][k]; }