Download Presentation
## Computer Graphics

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

**Computer Graphics**Andreas Savva Lecture Notes 1**Computer Graphics**Definition • Computer Graphics is concerned with all aspects of producing pictures or images using a computer.**Rabbit Change**1960s • Display of data on hardcopy plotters and cathode ray tube (CRT) screens. Today • Creation, storage, and manipulation of models and images of objects. These models include physical, mathematical, engineering, architectural, conceptual (abstract) structures, natural phenomena, etc.**Interactive Computer Graphics**• Today Computer Graphics are largely interactive: • the user control the contents, structure, and appearance of objects and their displayed images by using input devises.**CG Vs Image Processing**• Until recently they have been quite separate disciplines. However, the overlap between the two is growing. Computer Graphics task: • to synthesize pictures and images on the basis of some description, or model, in a computer. Image (Picture) Processing task: • to reconstruct models of 2D or 3D objects from their pictures. • to improve or alter images that where created elsewhere (digitized from photographs or captured by a video recorder).**Examples of Image Processing**• aerial photographs • X-ray images • computerized axial tomography (CAT) scans • fingerprint analysis • improving image quality by eliminating noise (extraneous or missing pixel data) or by enhancing contrast • scan images, typewritten or even hand-printed characters • reconstruction of 3D models from several 2D images**History of Computer Graphics**1960 • The first computer graphics software “Sketchpad” was created by Evan Sutherland on his doctoral thesis at MIT. • A graph could be drawn on a digital computer. The computer had its own air-conditioning environment and it read in its program and data from hole punched paper tapes and output the results either to tape or a plotter. The capital cost of the equipment was about £1M + running cost. • Most applications were scientific, pure research funded by governments, universities, the army and international corporations, with no thought of recovering the cost of development. • There were rabid advances in display technology and in the algorithms used to manage pictorial information. 1970 • Large corporations like Fort, Boeing and General Motors could draw drafting productivity improvements of their products and costs were recovered in about 3 years. • Random-scan graphics displays used were very expensive. • Computer graphics was a small specialized field, because the hardware was still expensive and there were not any easy-to-use and cost-effective graphics-based application programs.**History (continue)**1980 - Today • After the production of low-cost personal computers with build-in raster graphics displays, easy-to-use and inexpensive graphics-based applications such as the Xerox Star and later the mass-produced, even less expensive Apple Macintosh and IBM PC and its clones followed, which made good quality high-speed graphics available to all. • Computer technology is rapidly spreading in all areas because the hardware/software system “pays for itself” by • speeding up operations • significantly increasing productivity • giving organizations a competitive edge • The direct-view storage tube greatly reduced the capital cost, and modern high-resolutions raster displays have made good quality high-speed graphics available to ALL. • Today, it is hard to find an area of human activity for which there are no Computer Graphics applications, i.e. • games, photography, animation, newspaper, Magazine, television, scientific research, computer-aided design and manufacture, image enlargement. Charting, e-commerce.**Applications of Computer Graphics**• Science • Engineering • Medicine • Business • Industry & Government • Art • CAD (cars, airplanes) • Cinema and TV • Advertising • Education & Training • Flight simulators • Space exploration • Entertainment • Computer Interfaces • e-Commerce • Home**Why are graphics so popular?**• A picture is worth ten thousand words. • A moving picture (animation) is worth ten thousand static ones.**Mathematical Background**• Pythagoras theorem • Trigonometry • Natural logarithms • Coordinate geometry • Matrices • Differentiation**Matrices**• Applications in many areas • Rectangular array – 2D array**Definitions**• A matrix is a rectangular array of elements (usually numbers) arranged in rows and columns enclosed in brackets. • Order of the matrix is the number of rows and columns. A is a 3×2 matrix, B is a 3×3 matrix C is a 4×1 matrix . • Matrices are denoted by capital letters while their elements are written as lower case letters as in example C above. • We refer to a particular element by using notation that refers to the row and column containing the element, i.e. a21=-1, b32 = 1, c21 = b. • Two matrices A and B are said to be equal, written A = B, if they have the same order and aij = bij for every i and j.**Exercises**• Write the elements d23 and d42 of matrix D. • Find x, y, and z so that • Write down the 3×4 matrix A, where**Type of Matrices**• Square matrix – a matrix with an equal number of rows and columns. • Diagonal matrix – a square matrix with zeros everywhere except down the leading diagonal. • Unit matrix (identity matrix) – a diagonal matrix with ones down the leading diagonal. The identity matrix is denoted with the letter I.**Type of Matrices (continue)**• Zero matrix – a matrix with zeros everywhere, denoted by O. • Symmetric matrix – a square matrix whose (ij)th element is the same as the (ji)th element for all i and j. • Row matrix (row vector) – a matrix with only one row, i.e. its order is 1×m. • Column matrix (column vector) – a matrix with only one column, i.e. an n×1 matrix.**Matrix Addition and Subtraction**• If A and B are two n×m matrices then • their sum C = A + B is the n×m matrix with cij = aij + bij • their difference C = A - B is the n×m matrix with cij = aij - bij Examples:**Scalar Multiplication of Matrices**• If A is an n×m matrix and k is a real number, then the scalar multiple C = kA is the n×m matrix where cij = kaij .**The Transpose of a Matrix**• If A is a matrix then the transpose of A is the matrix At where atij = aji.**Matrix Multiplication**• If A is an n×m matrix and B is an m×p matrix then the product of A and B, C = AB, is an n×p matrix Cij = (row i of A) × (column j of B) = ai1b1j + ai2b2j + ai3b3j + … ainbjp**Properties**• If a, b are scalars and A, B, C are matrices of the same dimension (order) then A + B = B + A A + (B + C) = (A + B) + C a(bA) = (ab)A (a + b)A = aA + bA a(A + B) = aA + aB a(A - B) = aA - aB A + OA = A, and aO = O (A + B)t = At + Bt (A - B)t = At - Bt**Properties**• If a, b are scalars and A, B, C are matrices of the same dimension (order) then assuming that the matrix dimensions are such that the products in each of the following are defined, then we have: AB ≠ BA A(BC) = (AB)C (A + B)C = AC + BC A(B + C) = AB + AC OA = O, AO = O (aA)(bB) = abAB IA = AI = A (AB)T = BTAT**Inverse of a 2×2 Matrix**• Not all Matrices have an inverse. • The Determinant – determines if a matrix has an inverse or not. If the determinant of a matrix A is zero then the matrix has no inverse. Example:**Inverse of a 2×2 Matrix**• If A is a matrix then it is possible to find another matrix, called A-1, such that AA-1 = I or A-1A = I . Example:**Ax = b**Solution of Systems ofSimultaneous Equations Ax = b A-1Ax = A-1b x = A-1b**Exercises**• A + B • B – A • AB • BA • AI • IA • Consider the above matrices and complete the following operations: • BC • CB • C(A + B) • BCt • (AB)t • At Bt**Exercises**• Solve the following pairs of simultaneous equations using matrices. d) a) e) b) c) f)**Exercises**• Find the inverse of the following matrix: • Solve the following simultaneous equations using matrices.**Row Operations**• Solve any system of equations (that has a solution) • Find the inverse of an n×n matrix Rules • Can interchange any two rows of a matrix. • Can replace any row by a non zero multiple of the same row. • Can replace any row by the sum of that row and a multiple ofsome other row.**Solution:**• By using the rules transform the matrix into the form Row Operations Solve the system of equations**Solution**R2 = -r2 R2 = r2 – 2r1 R1 = r1 + r2**0**0 a 0 0 0 0 b 0 c 0 0 0 0 0 d Algorithm n×n 1 1 1 1**Solve the system of equations:**R2 = (-1)r2 R3 = r3 / 7 R2 = r2 – 3r1 R3 = r3 – 3r1 R1 = r1 – r2 R3 = r3 + 2r2 R1 = r1 + 3r3 R2 = r2 - 4r3 x = 1, y = 2, z = 3**Third row:**• 0x1 + 0x2 + 0x3 = -1 or 0 = -1 • meaningless, so the system has no solution Thus the system has infinitely many solutions There is always a solution?**Exercises**1. Solve the system of equations: a) b) 2. Find a matrix A such that: 2. For what number x will the following be true?**Finding the Inverse using the row operation**R1 = r1 - (1/2) r2 R1 = r1 / 2**Example**Find the inverse of the matrix R2 = -r2 R2 = r2 - 2r1 R3 = r3 - r1 R1 = r1 - r2 R3 = r3 –r2**Example (continue)**R3 = (-1/4)r3 R1 = r1 + 2r3 R2 = r2 - 4r3 • Verify: • AA-1 = I3**Exercises**• Find the inverse of the following matrices using the row operations method:**0D**1D x 2D y 3D y x x z Dimension of a Space • is the amount of freedom of movement that objects within the space have.**y**y z x x z 3D Coordinate Systems Left-handed system (z goes in) Right-handed system (z comes out)**Distance**1D P1 P2 y P2 2D P1 x y 3D P2 x P1 z**5**3 ? ? ? 20º 10 Trigonometry**(x2,y2)**(x1,y1) c Equation of the Line y x**(x,y)**r (0, 0) Equation of a circle at (0,0) Polar form Cartesian form**(x,y)**r r (xc,yc) Equation of a circle at (xc ,yc) Polar form Cartesian form**Exercises**• Find the equation of the straight line which passes from the two points (2,8) and (8,26). • Draw the graph y = x3 – x. • Draw the graph y = x / (x2– 1). • Find the Cartesian coordinates x, y for the circle with center (0,0) and radius 4, when = 0º, 45º, 90º, 150º, 215º, and 340º. • Find the Cartesian coordinates x, y for the circle with center (4,3) and radius 10, when = 30º, 190º, and 325º. • Find the radius of the circle with center (4,6) and passes from point (-2,10).