1 2M050: Computer Graphics Jack van Wijk HG6.71.

Slides:



Advertisements
Similar presentations
1GR2-00 GR2 Advanced Computer Graphics AGR Ken Brodlie Lecture 1 - Overview.
Advertisements

Real-Time Rendering 靜宜大學資工研究所 蔡奇偉副教授 2010©.
Computer Graphics An Introduction. What’s this course all about? 05/10/2014 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
COMPUTER GRAPHICS SOFTWARE.
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Graphics Pipeline.
CP411 Computer Graphics, Wilfrid Laurier University Introduction # 1 Welcome to CP411 Computer Graphics 2012 Instructor: Dr. Hongbing Fan Introduction.
INTRODUCTION. Painting with numbers! Aspects Modeling Rendering Animation.
Graphics-1 Gentle Introduction to Computer Graphics Based on: –David Brogan’s “Introduction to Computer Graphics” Course Slides, University of Virginia.
Sep 21, Fall 2005ITCS4010/ Computer Graphics Overview Color Displays Drawing Pipeline.
Graphics-1 Gentle Introduction to Computer Graphics (1) Based on: –David Brogan’s “Introduction to Computer Graphics” Course Slides, University of Virginia.
1 Jinxiang Chai CSCE 441 Computer Graphics. 2 Midterm Time: 10:10pm-11:20pm, 10/20 Location: HRBB 113.
Sep 21, Fall 2006IAT 4101 Computer Graphics Overview Color Displays Drawing Pipeline.
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
Graphics in Java Part I. Lecture Objectives Understand the basic concepts of Computer Graphics Learn about Computer Graphics Applications Learn about.
SWE 423: Multimedia Systems Chapter 4: Graphics and Images.
Computer Graphics Introduction
Ch 1 Intro to Graphics page 1CS 367 First Day Agenda Best course you have ever had (survey) Info Cards Name, , Nickname C / C++ experience, EOS experience.
2IV60 Computer Graphics 2D transformations
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Introduction to Computer Graphics (CS560/CS460) Computer graphics means the art and science of creating images of three dimensional objects. Huge and Fast-moving.
2IV60 Computer Graphics Basic Math for CG
Dr. Sana’a Wafa Al-Sayegh
Graphics Graphics Korea University cgvr.korea.ac.kr Introduction to Computer Graphics.
1 Chapter 1: Graphics Systems and Models. 2 Applications of C. G. – 1/4 Display of information Maps GIS (geographic information system) CT (computer tomography)
1 In the name of God Computer Graphics. 2 Image Mathematical Model Image Analysis (pattern recognition) Image Synthesis (Rendering) ModelingImage processing.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
1 Computer Graphics Week3 –Graphics & Image Processing.
Computer Graphics Computer Graphics is everywhere: Visual system is most important sense: High bandwidth Natural communication Fast developments in Hardware.
3D Computer Graphics An oh so brief introduction.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
Computer Graphics. Requirements Prerequisites Prerequisites CS 255 : Data Structures CS 255 : Data Structures Math 253 Math 253 Experience with C Programming.
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 Going-through.
Institute for Visualization and Perception Research 1 © Copyright 2000 Haim Levkowitz Introduction (Foley & Van Dam Ch 1) Uses of computer graphics … Some.
1 Computer Graphics Week2 –Creating a Picture. Steps for creating a picture Creating a model Perform necessary transformation Lighting and rendering the.
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
INT 840E Computer graphics Introduction & Graphic’s Architecture.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
3D Computer Graphics in a Nutshell Guillaume Caumon, January 2002.
CSE 681 Introduction to 3D Graphics. CSE 681 Computer graphics is “the creation and manipulation of graphics images by means of computer.” (Marc Berger,
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Subject Name: Computer Graphics Subject Code: Textbook: “Computer Graphics”, C Version By Hearn and Baker Credits: 6 1.
Handle By, S.JENILA AP/IT
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
1 Chapter 1: Graphics Systems and Models. 2 Applications of C. G. – 1/4 Display of information Maps GIS (geographic information system) CT (computer tomography)
Lecture 13: Raster Graphics and Scan Conversion
2/28/2016 CS 551 / 645: Introductory Computer Graphics Framebuffer Mathematical Foundations The Rendering Pipeline.
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
Mohammed AM Dwikat CIS Department Digital Image.
AUTUMN Asst. Prof. Dr. Gazi Erkan BOSTANCI Slides by Robert Thomson, Süleyman Tosun and Kurtuluş Küllü.
1 Chapter 1: Introduction to Graphics. 2 What is computer graphics.
Applications and Rendering pipeline
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Computer Graphics Overview
- Introduction - Graphics Pipeline
Computer Graphics.
2M050: Computer Graphics Jack van Wijk HG6.71.
2M050: Computer Graphics Jack van Wijk HG6.71.
Introduction to Graphics Modeling
3D Graphics Rendering PPT By Ricardo Veguilla.
Computer Graphics : Introduction
The Graphics Rendering Pipeline
Interactive Computer Graphics
COMP 388: Computer Graphics Raster Images & Vector Images
Type to enter a caption. Computer Graphics Week 1Lecture 1.
Introduction to 3D Graphics
Presentation transcript:

1 2M050: Computer Graphics Jack van Wijk HG6.71

2 Aims Introduce basic graphics concepts and terminology Base for development of 2D interactive computer graphics programmes (OGO 2.3)

3 Literature Computer Graphics - Principles and Practice Foley - van Dam - Feiner - Hughes 2nd edition in C - Addison and Wesley Computer Graphics - C Version Donald Hearn - M. Pauline Baker 2nd edition - international edition Prentice Hall

4 Overview Introduction Geometry Interaction Raster graphics

5 Introduction What is Computer Graphics? Applications Computer Graphics in Eindhoven Raster/vector graphics Hardware

6 Computer Graphics Computer Graphics is ubiquitous: Visual system is most important sense: –High bandwidth –Natural communication Fast developments in –Hardware –Software

7 Computer Graphics Image Mathematical Model Image Analysis (pattern recognition) Image Synthesis (Rendering) ModelingImage processing

8 Supporting Disciplines Computer science (algorithms, data structures, software engineering, …) Mathematics (geometry, numerical, …) Physics (Optics, mechanics, …) Psychology (Colour, perception) Art and design

9 Applications Computer Aided Design (CAD) Computer Aided Geometric Design (CAGD) Entertainment (animation, games, …) Geographic Information Systems (GIS) Visualization (Scientific Vis., Inform. Vis.) Medical Visualization …

10 Computer Graphics Eindhoven Current: Information visualisation Interactive 3D design Virtual reality Past: Rasterization, Animation Jack van Wijk Kees Huizing Arjan Kok Robert van Liere Wim Nuij Alex Telea Huub van de Wetering

11 Interactive Computer Graphics User Application Screen input image

12 Graphics pipeline User Screen Model Geometry, colour Map Display Edit

13 Representations in graphics Vector Graphics Image is represented by continuous geometric objects: lines, curves, etc. Raster Graphics Image is represented as an rectangular grid of coloured squares

14 Vector graphics Graphics objects: geometry + colour Complexity ~ O(number of objects) Geometric transformation possible without loss of information (zoom, rotate, …) Diagrams, schemes,... Examples: PowerPoint, CorelDraw,...

15 Raster graphics Generic Image processing techniques Geometric Transformation: loss of information Complexity ~ O(number of pixels) Jagged edges, anti-aliasing Realistic images, textures,... Examples: Paint, PhotoShop,...

16 Conversion Vector graphics Rasterization, Pattern recognition Scan conversion Raster graphics

17 Hardware Vector graphics Raster graphics Colour lookup table 3D rendering hardware

18 Vector Graphics Hardware V E C T O R Display Controller move line char O char R Display list continuous & smooth lines no filled objects random scan refresh speed depends on complexity of the scene

19 Raster Graphics Hardware Video Controller jaggies (stair casing) filled objects (anti)aliasing R A S T E R refresh speed independent of scene complexity pixel scan conversion resolution bit planes Frame buffer

20 Colour Lookup Table Frame buffer R G B colour index CLUT: pixel = code True colour: pixel = R,G,B

21 3D rendering hardware Geometric representation: Triangles Viewing: Transformation Hidden surface removal: z-buffer Lighting and illumination: Gouraud shading Realism: texture mapping Special effects: transparency, antialiasing

22 2D geometric modelling Coordinates Transformations Parametric and implicit representations Algorithms

23 Coordinates Point: position on plane p = (p x, p y ) x = (x, y) x = (x 1, x 2 ) x = x 1 e 1 + x 2 e 2, e 1 = (1, 0), e 2 = (0, 1) Vector: direction and magnitude v = (v x, v y ), etc. x y p v

24 Vector arithmetic Addition of two vectors: v + w = (v x + w x, v y + w y ) Multiplication vector-scalar:  v = (  v x,  v y ) x y w v v+wv+w x y v 2v2v

25 Coordinate systems image wheel train world

26 Why transformations? Model of objects world coordinates: km, mm, etc. hierarchical models: human = torso + arm + arm + head + leg + leg arm = upperarm + lowerarm + hand … Viewing zoom in, move drawing, etc.

27 Transformation types Translate according to vector v: t = p + v Scale with factor s: s = sp Rotate over angle  r x = cos(  )p x - sin(  )p y r y = sin(  )p x + cos(  )p y x y p t s r v 

28 Homogeneous coordinates Unified representation of rotation, scaling, translation Unified representation of points and vectors Compact representation for sequences of transformations Here: convenient notation, much more to it

29 Homogeneous coordinates Extra coordinate added: p = (p x, p y, p w ) or x = (x, y, w) Cartesian coordinates: divide by w x = (x/w, y/w) Here: for a point w = 1, for a vector w = 0

30 Matrices for transformation

31 Direct interpretation x’ y’ (x, y) y a b t x (x’,y’)

32 Translation matrix

33 Scaling matrix

34 Rotation matrix

35 Sequences of transformations x y x’ y’ x’’ y’’ y’’’ x’’’ Sequences of transformations can be described with a single transformation matrix, which is the result of concatenation of all transformations.

36 Order of transformations x y x’ y’ x’’ y’’ x y x’ y’ x’’ y’’ Matrix multiplication is not commutative. Different orders of multiplication give different results.

37 Order of transformations Pre-multiplication: x’ = M n M n-1 …M 2 M 1 x Transformation M n in global coordinates Post-multiplication: x’ = M 1 M 2 …M n-1 M n x Transformation M n in local coordinates, i.e., the coordinate system that results from application of M 1 M 2 …M n-1

38 Window and viewport Viewport: Area on screen to be used for drawing. Unit: pixels (screen coordinates) Note: y-axis often points down Window: Virtual area to be used by application Unit: km, mm,… (world coordinates) (0,0) (800,600) (200,200) (600,400) (-2,-1) (2,1)

39 Window/viewport transform Determine a matrix M, such that the window (w x1, w x2, w y1, w y2 ) is mapped on the viewport (v x1, v x2, v y1, v y2 ): A = T(-w x1, -w y1 ) B = S(1/(w x2 -w x1 ), 1/(w y2 -w y1 )) A C = S(v x2 -v x1,v y2 -v y1 )B M = T(v x1, v y1 ) C

40 Forward and backward Drawing: (meters to pixels) Use x’ = Mx Picking:(pixels to meters) Use x = M -1 x’ (w x1, w y1 ) (w x2, w y2 ) Window: x: user coordinates (v x1, v y1 ) (v x2, v y2 ) Viewport x’:screen coordinates DrawingPicking

41 Implementation example Suppose, basic library supports two functions: –MoveTo(x, y: integer); –LineTo(x, y: integer); –x and y in pixels. How to make life easier?

42 State variables Define state variables: Viewport: array[1..2, 1..2] of integer; Window: array:[1..2, 1..2] of real; Mwv, Mobject: array[1..3, 1..3] of real; Mwv: transformation from world to view Mobject: extra object transformation

43 Procedures Define coordinate system: SetViewPort(x1, x2, y1, y2): Update Viewport and Mwv SetWindow(x1, x2, y1, y2): Update Window and Mwv

44 Procedures (continued) Define object transformation: ResetTrans: Mobject := IdentityMatrix Translate(tx, ty): Mobject := T(tx,ty)* Mobject Rotate(alpha): Mobject := R(tx,ty)* Mobject Scale(sx, sy): Mobject := S(sx, sy)* Mobject

45 Procedures (continued) Handling hierarchical models: –PushMatrix(); Push an object transformation on a stack; –PopMatrix() Pop an object transformation from the stack. Or: –GetMatrix(M); –SetMatrix(M);

46 Procedures (continued) Drawing procedures: MyMoveTo(x, y): (x’, y’) = Mwv*Mobject*(x,y); MoveTo(x’, y’) MyLineTo(x,y): (x’, y’) = Mwv*Mobject*(x,y); LineTo(x’, y’)

47 Application DrawUnitSquare: MyMoveTo(0, 0); MyLineTo(1, 0); MyLineTo(1, 1); MyLineTo(0, 1); MyLineTo(0, 0); Initialize: SetViewPort(0, 100, 0, 100); SetWindow(0, 1, 0, 1); Main program: Initialize; Translate(-0.5, -0.5); for i := 1 to 10 do begin Rotate(pi/20); Scale(0.9, 0.9); DrawUnitSquare; end;

48 Puzzles Modify the window/viewport transform for a display y-axis pointing downwards. How to maintain aspect-ratio world->view? Which state variables? Define a transformation that transforms a unit square into a “wybertje”, centred around the origin with width w and height h.

49 Geometry Dot product, determinant Representations Line Ellipse Polygon

50 Good and bad Good: symmetric in x and y Good: matrices, vectors Bad: y = f(x) Good: dot product, determinant Bad: arcsin, arccos

51 Dot product v w  |w| cos 

52 Dot product properties

53 Determinant v w  Det(v, w): signed area of parallellogram Det(v, w) = 0 iff v and w are parallel v w 

54 Curve representations Parametric: x(t) = (x(t), y(t)) Implicit: f(x) = 0

55 Parametric line representation Given point p and vector v: x(t) = p + vt Given two points p and q: x(t) = p + (q-p)t, or = pt + q(1-t) x y p v t q

56 Parametric representation x(t) = (x(t), y(t)) Trace out curve: MoveTo(x(0)); for i := 1 to N do LineTo(x(i*  t)); Define segment:  t min  t  t max

57 Implicit line representation (x-p).n = 0 with n.v = 0 n is normal vector: n = [-v y, v x ] Also: ax+by+c=0 x y p v n

58 Implicit representation f >0 f <0 f = 0 f =-1 f = 1 f =-2

59 Circle x y r

60 Ellipse x y a b

61 Generic ellipse x y a b c

62 Some standard puzzles Conversion of line representation Projection of point on line Line/Line intersection Position points/line Line/Circle intersection

63 Conversion line representations a u s

64 Projection point on line a u s q q-a q’  w

65 Intersection of line segments a u b v t s

66 Solving for s and t a u b v t s

67 Position points/line c u b sa

68 Line/circle intersection a u t x y r

69 Polygons Sequence of points p i, i = 1,…, N, connected by straight lines Index arithmetic: modulo N p 0 = p N, p N+1 = p 1, etc. p1p1 p2p2 pNpN pipi

70 Regular N-gon triangle square pentagon hexagon octagon

71 Convex and concave Convex: –each line between two arbitrary points inside the polygon does not cross its boundary Concave: –not convex

72 Convexity test p i-1 pipi p i+1 p i-1 pipi p i+1 ConvexConcave

73 Polygon area and orientation pipi p i+1 c

74 Point/polygon test 2 3 1

75 Point/polygon test (cntd.) Beware of special cases: –Point at boundary –v parallel to edge –c + vt through vertex

76 Puzzles Define a procedure to clip a line segment against a rectangle. Define a procedure to calculate the intersection of two polygons. Define a procedure to draw a star. Same, with the constraint that the edges p i-1 p i and p i+2 p i+3 are parallel.