2M050: Computer Graphics Jack van Wijk vanwijk@win.tue.nl HG6.71.

Slides:



Advertisements
Similar presentations
COMPUTER GRAPHICS SOFTWARE.
Advertisements

1 2M050: Computer Graphics Jack van Wijk HG6.71.
Computer Graphics (Spring 2008) COMS 4160, Lecture 6: Curves 1
Graphics Pipeline.
3D Graphics Rendering and Terrain Modeling
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
1 Introduction Curve Modelling Jack van Wijk TU Eindhoven.
HCI 530 : Seminar (HCI) Damian Schofield.
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.
Chapter 4 Digital Multimedia, 2nd edition Vector Graphics.
Graphics-1 Gentle Introduction to Computer Graphics (1) Based on: –David Brogan’s “Introduction to Computer Graphics” Course Slides, University of Virginia.
Sep 21, Fall 2006IAT 4101 Computer Graphics Overview Color Displays Drawing Pipeline.
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
Computer Graphics Introduction
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
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.
Curve Modeling Bézier Curves
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)
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
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.
Computer Graphics Computer Graphics is everywhere: Visual system is most important sense: High bandwidth Natural communication Fast developments in Hardware.
A D V A N C E D C O M P U T E R G R A P H I C S CMSC 635 January 15, 2013 Spline curves 1/23 Curves and Surfaces.
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.
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.
Digital Media Dr. Jim Rowan ITEC Vector Graphics Elegant way to construct digital images that –have a compact representation –are scalable –are.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
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
Digital Media Dr. Jim Rowan ITEC Vector Graphics Elegant way to construct digital images that –have a compact representation –are scalable –are.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
CS559: Computer Graphics Final Review Li Zhang Spring 2010.
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.
1 Chapter 1: Introduction to Graphics. 2 What is computer graphics.
Introduction to Parametric Curve and Surface Modeling.
Applications and Rendering pipeline
Computer Graphics Overview
Rendering Pipeline Fall, 2015.
- Introduction - Graphics Pipeline
© University of Wisconsin, CS559 Spring 2004
Computer Graphics.
Constructing Objects in Computer Graphics
2M050: Computer Graphics Jack van Wijk HG6.71.
Three Dimensional Object Representation
Dr. Jim Rowan ITEC 2110 Wednesday, September 12
3D Graphics Rendering PPT By Ricardo Veguilla.
Constructing Objects in Computer Graphics By Andries van Dam©
3D Object Representations
CSE 167 [Win 17], Lecture 9: Curves 1 Ravi Ramamoorthi
Computer Graphics : Introduction
The Graphics Rendering Pipeline
Real-time Computer Graphics Overview
© University of Wisconsin, CS559 Fall 2004
WINDOWING AND CLIPPING
© University of Wisconsin, CS559 Spring 2004
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.
WINDOWING AND CLIPPING
COMP 388: Computer Graphics Raster Images & Vector Images
Introduction to Parametric Curve and Surface Modeling
SUBJECT : COMPUTER GRAPHICS
Presentation transcript:

2M050: Computer Graphics Jack van Wijk vanwijk@win.tue.nl HG6.71

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

Literature Computer Graphics - C Version Donald Hearn - M. Pauline Baker 2nd edition - international edition Prentice Hall

Overview Introduction Geometry Interaction Raster graphics

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

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

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

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

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

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

Interactive Computer Graphics User input Application Screen image

Graphics pipeline User Edit Model Map Geometry, colour Screen Display

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

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, ...

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, ...

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

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

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

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

Colour Lookup Table 0 0 0 102 255 53 255 255 204 255 102 153 102 0 51 R G B 1 2 4 7 ... colour index 7 6 Frame buffer CLUT: pixel = code True colour: pixel = R,G,B

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

2D geometric modelling Coordinates Transformations Parametric and implicit representations Algorithms

Coordinates Point: position on plane p = (px , py) x = (x, y) x = (x1 , x2) x = x1 e1 + x2 e2, e1 = (1, 0), e2 = (0, 1) Vector: direction and magnitude v = (vx , vy), etc. y p v x

Vector arithmetic Addition of two vectors: v + w = (vx + wx , vy + wy) Multiplication vector-scalar: av = (avx , avy) y v+w w v x y 2v v x

Coordinate systems world train wheel image

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

Transformation types Translate according to vector v: t = p + v Scale with factor s: s = sp Rotate over angle a: rx = cos(a)px - sin(a)py ry = sin(a)px + cos(a)py y s t r v p a x

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

Homogeneous coordinates Extra coordinate added: p = (px , py , pw) 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

Matrices for transformation

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

Translation matrix

Scaling matrix

Rotation matrix

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

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.

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

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) (800,600) (600,400) (200,200) (0,0) (2,1) (-2,-1)

Window/viewport transform Determine a matrix M, such that the window (wx1, wx2, wy1, wy2) is mapped on the viewport (vx1, vx2, vy1, vy2): A = T(-wx1, -wy1) B = S(1/(wx2-wx1), 1/(wy2-wy1)) A C = S(vx2-vx1 ,vy2-vy1)B M = T(vx1, vy1) C

Forward and backward Drawing: (meters to pixels) Use x’ = Mx (vx2, vy2) Viewport x’:screen coordinates Drawing: (meters to pixels) Use x’ = Mx Picking:(pixels to meters) Use x = M-1x’ (vx1, vy1) Drawing Picking (wx2, wy2) Window: x: user coordinates (wx1, wy1)

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?

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

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

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

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);

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

Application DrawUnitSquare: Main program: MyMoveTo(0, 0); Initialize; 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;

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.

Geometry Dot product, determinant Representations Line Ellipse Polygon

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

Dot product w q v |w| cos q

Dot product properties

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

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

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) y t q p x v

Parametric representation x(t) = (x(t), y(t)) Trace out curve: MoveTo(x(0)); for i := 1 to N do LineTo(x(i*Dt)); Define segment: tmin £ t £ tmax

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

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

Circle y r x

Ellipse y b a x

Generic ellipse a b y c x

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

Conversion line representations u a

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

Intersection of line segments u v a b

Solving for s and t s t u v a b

Position points/line u a s c b

Line/circle intersection y u r x t a

Polygons Sequence of points pi, i = 1,…, N, connected by straight lines Index arithmetic: modulo N p0 = pN , pN+1 = p1 , etc. p1 p2 pN pi

Regular N-gon triangle square pentagon hexagon octagon

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

Convexity test pi+1 pi+1 pi pi pi-1 pi-1 Convex Concave

Polygon area and orientation pi pi+1 c

Point/polygon test 2 1 3

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

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 pi-1 pi and pi+2 pi+3 are parallel.

Introduction Curve Modelling Jack van Wijk TU Eindhoven

Overview curve modelling Parametric curves Requirements Concepts Lagrangian interpolation Bézier curve B-spline Cubic splines

Parametric curves t p(t) p’(t)

Tangent line to curve t s q(s) p(t) p’(t)

Example q(s) s p’(t) t p(t)

Curve modelling Problem: How to define a smooth curve? Solution: Specify a sequence of points pi , i = 1,…, N, (control-points); Generate a smooth curve that interpolates or approximates these control-points.

Requirements Smooth Local control Intuitive and easy to use no discontinuities in direction and curvature; Local control Change of a point should have only local effect; Intuitive and easy to use no oscillations, variation diminishing Approximate or interpolate?

Parametric interpolation

Linear interpolation of two points

Linear interpolation of N points 1 wi 1 2 3 4 5 t

Linear interpolation Not Smooth Local control Intuitive and easy to use Interpolate

Lagrangian interpolation - 1

Lagrangian interpolation - 2

Lagrangian interpolation - 3

Lagrangian interpolation - 4 Smooth no discontinuities in direction and curvature; NO local control Wild oscillations, not variation diminishing! Interpolating

Bézier curve - 1 Puzzle: Define a smooth curve that interpolates the first and last point and approximates the others. p4 p3 p1 p2

Bézier curve - 2 Solution for N=3: p2 p(t) q2 q1 p1 p3

Bézier curve - 3 Solution for N=4: p2 p3 p(t) p1 p4

Bézier curve - 4

Bézier curve - 5

Bézier curve - 6 General Bézier curve: Degree = #points-1 Smooth no discontinuities in direction and curvature; NO local control Variation diminishing, convex hull property Interpolates first and last, further approximating

Convex hull property

Convex hull property example Curve outside convex hull Curve inside convex hull

B-splines Piecewise polynomial, locally non-zero Degree: user definable Continuity: degree-1 first degree: continuous in position second degree: continuous in tangent third degree: continuous in curvature

Quadratic B-spline

Cubic B-spline

B-splines - 3 General B-spline: Degree: from 1 to N-1 Smooth (if degree > 1) Local control Variation diminishing, convex hull property Approximating

Cubic splines - 1 Most popular in Computer Graphics: powerful simple inflection points, continuity simple low degree polynomials local control Many versions: Bézier, B-spline, Catmull-Rom,...

Cubic splines - 2

Cubic splines - 2

Cubic splines - 3

Tangent vector p’(t) p(t) t

Significant values p(0) : startpoint segment p’(0) : tangent through startpoint p(1) : endpoint segment p’(1) : tangent through endpoint p’(0) p(1) t p’(1) p(0)

Cubic Bézier curve p1 p2 p0 p3

Joining two Bezier segments Positional continuity: p3 = q0 Tangential continuity: p3- p2 // q1- q0 p1 p2 p3 p0 q0 q3 q1 q2

Cubic B-spline curve p1 p2 p0 p3

Conversion - 1

Conversion - 2

Puzzle 1: Hermite spline

Puzzle 2: Limit on interpolation Find out why a curve that interpolates the control points, stays within the convex hull, and is smooth cannot exist, both graphically and mathematically.

Puzzle 3: Split Bezier curve Find a recipe to split a cubic Bezier curve segment into two segments: p1 p2 q2 q3 q4 q1 q5 p0 p3 q0 q6

Finally... Curves: interpolation of points Demo program: Interpolation is generally applicable, f.i. surfaces: interpolation of curves Demo program: www.win.tue.nl/~vanwijk/2M050/spline.exe

B-splines - 2