Prof. Harriet Fell Spring 2007 Lecture 19 – February 22, 2007

Slides:



Advertisements
Similar presentations
CS 450: COMPUTER GRAPHICS LINEAR ALGEBRA REVIEW SPRING 2015 DR. MICHAEL J. REALE.
Advertisements

Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
1 Introduction to Computer Graphics with WebGL Prof. John Gauch CSCE Department Spring 2015 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley.
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Vector Calculus Mengxia Zhu Fall Objective Review vector arithmetic Distinguish points and vectors Relate geometric concepts to their algebraic.
College of Computer and Information Science, Northeastern UniversityApril 17, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 9.
©College of Computer and Information Science, Northeastern UniversityApril 22, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 4.
General Physics (PHYS101)
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
CS 4731: Computer Graphics Lecture 6: Points, Scalars and Vectors Emmanuel Agu.
Exercise 1 - Poisson Image completion using Discrete Poisson Linear Systems.
CS 376b Introduction to Computer Vision 03 / 04 / 2008 Instructor: Michael Eckmann.
CS 376b Introduction to Computer Vision 03 / 04 / 2008 Instructor: Michael Eckmann.
1 Computer Graphics Chapter 5 Vector Based Algorithms.
PHYS 218 sec Review Chap. 1. Caution This presentation is to help you understand the contents of the textbook. Do not rely on this review for.
Area of Rectangles, Squares, Parallelograms, Triangles, and Trapezoids.
1 Physics 111/121 Mini-Review Notes on Vectors. 2 Right hand rule: - curl fingers from x to y - thumb points along +z.
Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003.
College of Computer and Information Science, Northeastern UniversitySeptember 7, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2007.
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
Patrick Nichols Thursday, September 18, Linear Algebra Review.
ME 2304: 3D Geometry & Vector Calculus
Section 13.4 The Cross Product. Torque Torque is a measure of how much a force acting on an object causes that object to rotate –The object rotates around.
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
1 CS 430/536 Computer Graphics I Line Drawing Week 1, Lecture 2 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory.
College of Computer and Information Science, Northeastern UniversityOctober 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006.
©College of Computer and Information Science, Northeastern UniversityOctober 19, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2007.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
©College of Computer and Information Science, Northeastern UniversityMay 27, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2012 Lecture 4 – September.
Scan Conversion. Last step in the graphics pipeline Efficiency is a central issue Common primitives – Lines (done last class) – Polygons (fill polygons,
College of Computer and Information Science, Northeastern UniversityNovember 16, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 31.
Presented by: S. K. Pandey PGT Physics K. V. Khandwa Kinematics Vectors.
©College of Computer and Information Science, Northeastern UniversityNovember 29, CS 5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.
CS 325 Introduction to Computer Graphics 04 / 12 / 2010 Instructor: Michael Eckmann.
©College of Computer and Information Science, Northeastern UniversityFebruary 21, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture.
©College of Computer and Information Science, Northeastern UniversityFebruary 25, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2009.
Instructor: Mircea Nicolescu Lecture 9
Chapter 3 Lecture 5: Vectors HW1 (problems): 1.18, 1.27, 2.11, 2.17, 2.21, 2.35, 2.51, 2.67 Due Thursday, Feb. 11.
Orthonormal Basis Cartesian Coordinate System – Unit vectors: i, j, k – Normalized to each other – Unique representation for each position!! – Convenient!
Linear Algebra Review Tuesday, September 7, 2010.
LINEAR EQUATIONS FOLDABLE. Title Page Put a title on the top tab. Unit 2: Linear Equations and Their Graphs Put your name in one corner of this layer.
Area of Rectangles, Squares, Parallelograms, Triangles, and Trapezoids
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
CS G140 Graduate Computer Graphics
CSE 455 HW 1 Notes.
Outline Addition and subtraction of vectors Vector decomposition
Forces Classification of Forces Force System
Reading Netpbm Images.
Scalars A scalar is any physical quantity that can be completely characterized by its magnitude (by a number value) Mathematical operations involving scalars.
CS5310 Graduate Computer Graphics
Lecture 03: Linear Algebra
Joshua Barczak CMSC 435 UMBC
Prof. Harriet Fell Spring 2007 Lecture 9 – January 29, 2007
Color Values All colors in computer images are a combination of red, green and blue Each component is encoded as a number means the color is.
P.5 The Cartesian Plane Our goals are to learn
Prof. Harriet Fell Spring 2007 Lecture 19 – February 22, 2007
Chapter II Mathematics: Basics
Joshua Barczak* CMSC 435 UMBC
Prof. Harriet Fell Spring 2007 Lecture 4 - January 17, 2007
CSE 411 Computer Graphics Lecture #2 Mathematical Foundations
Plotting Signals in MATLAB
2D Graphics Lecture 4 Fri, Aug 31, 2007.
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Exercise 1 2 Evaluate xy when x = 7 and y =
Window to Viewport Transformations
Coordinate system Vector Matrix
PPM file format CSE 681.
Prof. Harriet Fell Spring 2007 Lecture 4 - January 17, 2007
Presentation transcript:

Prof. Harriet Fell Spring 2007 Lecture 19 – February 22, 2007 CS U540 Computer Graphics Prof. Harriet Fell Spring 2007 Lecture 19 – February 22, 2007 December 31, 2018

Adding R, G, and B Values http://en.wikipedia.org/wiki/RGB December 31, 2018

RGB Color Cube (0, 0, 1) (0, 1, 1) (1, 0, 1) (1, 1, 1) (1, 0, 0) (1, 1, 0) (0, 0, 1) (0, 1, 1) (0, 1, 0) (1, 0, 1) (1, 0, 0) December 31, 2018

RGB Color Cube The Dark Side (0, 0, 0) (1, 1, 0) (0, 0, 1) (0, 1, 1) (0, 1, 0) (1, 0, 1) (1, 0, 0) December 31, 2018

Doug Jacobson's RGB Hex Triplet Color Chart December 31, 2018

Making Colors Darker (1, 0, 0) (.5, 0, 0) (0, 0, 0) (0, 1, 0) (0, .5, 0) (0, 0, 0) (0, 0, 1) (0, 0, .5) (0, 0, 0) (1, 1, 0) (0, .5, .5) (0, 0, 0) (1, 0, 1) (.5, 0, .5) (0, 0, 0) (1, 1, 0) (.5, .5, 0) (0, 0, 0) December 31, 2018

Getting Darker, Left to Right for (int b = 255; b >= 0; b--){ c = new Color(b, 0, 0); g.setPaint(c); g.fillRect(800+3*(255-b), 50, 3, 150); c = new Color(0, b, 0); g.setPaint(c); g.fillRect(800+3*(255-b), 200, 3, 150); c = new Color(0, 0, b); g.setPaint(c); g.fillRect(800+3*(255-b), 350, 3, 150); c = new Color(0, b, b); g.setPaint(c); g.fillRect(800+3*(255-b), 500, 3, 150); c = new Color(b, 0, b); g.setPaint(c); g.fillRect(800+3*(255-b), 650, 3, 150); c = new Color(b, b, 0); g.setPaint(c); g.fillRect(800+3*(255-b), 800, 3, 150); } December 31, 2018

Gamma Correction Gamma half black half red (127, 0, 0) December 31, 2018

Making Pale Colors (1, 0, 0) (1, .5, .5) (1, 1, 1) (0, 1, 0) (.5, 1, .5) (1, 1, 1) (0, 0, 1) (.5, .5, 1) (1, 1, 1) (1, 1, 0) (.5, 1, 1) (1, 1, 1) (1, 0, 1) (1, .5, 1) (1, 1, 1) (1, 1, 0) (1, 1, .5) (1, 1, 1) December 31, 2018

Getting Paler, Left to Right for (int w = 0; w < 256; w++){ c = new Color(255, w, w); g.setPaint(c); g.fillRect(3*w, 50, 3, 150); c = new Color(w, 255, w); g.setPaint(c); g.fillRect(3*w, 200, 3, 150); c = new Color(w, w, 255); g.setPaint(c); g.fillRect(3*w, 350, 3, 150); c = new Color(w, 255, 255); g.setPaint(c); g.fillRect(3*w, 500, 3, 150); c = new Color(255,w, 255); g.setPaint(c); g.fillRect(3*w, 650, 3, 150); c = new Color(255, 255, w); g.setPaint(c); g.fillRect(3*w, 800, 3, 150); } December 31, 2018

Portable Pixmap Format (ppm) A "magic number" for identifying the file type. A ppm file's magic number is the two characters "P3". Whitespace (blanks, TABs, CRs, LFs). A width, formatted as ASCII characters in decimal. Whitespace. A height, again in ASCII decimal. The maximum color value again in ASCII decimal. Width * height pixels, each 3 values between 0 and maximum value. start at top-left corner; proceed in normal English reading order three values for each pixel for red, green, and blue, resp. 0 means color is off; maximum value means color is maxxed out characters from "#" to end-of-line are ignored (comments) no line should be longer than 70 characters December 31, 2018

ppm Example P3 # feep.ppm 4 4 15 0 0 0 0 0 0 0 0 0 15 0 15 0 0 0 0 15 7 0 0 0 0 0 0 0 0 0 0 0 0 0 15 7 0 0 0 15 0 15 0 0 0 0 0 0 0 0 0 December 31, 2018

private void saveImage() { String outFileName = “my.ppm"; File outFile = new File(outFileName); int clrR, clrG, clrB; try { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outFile))); out.println("P3"); out.print(Integer.toString(xmax-xmin+1)); System.out.println(xmax-xmin+1); out.print(" "); out.println(Integer.toString(ymax-ymin+1)); System.out.println(ymax-ymin+1); out.println("255"); for (int y = ymin; y <= ymax; y++){ for (int x = xmin; x <= xmax; x++) { // compute clrR, clrG, clrB out.print(" "); out.print(clrR); out.print(" "); out.print(clrG); out.print(" "); out.println(clrB); } out.close(); } catch (IOException e) { System.out.println(e.toString()); December 31, 2018

Vectors A vector describes a length and a direction. a b a = b a zero length vector a b 1 a unit vector a = b December 31, 2018

Vector Operations b a b+a a b Vector Sum Vector Difference c d -d c-d December 31, 2018

Cartesian Coordinates Any two non-zero, non-parallel 2D vectors form a 2D basis. Any 2D vector can be written uniquely as a linear combination of two 2D basis vectors. x and y (or i and j) denote unit vectors parallel to the x-axis and y-axis. x and y form an orthonormal 2D basis. a = xax + yay a =( xa, ya) or x, y and z form an orthonormal 3D basis. or a =(ax,ay) December 31, 2018

Vector Length Vector a =( xa, ya ) ||a|| a ya xa December 31, 2018

Dot Product Dot Product a =( xa, ya ) b =( xb, yb ) ab = xa xb + ya yb ab = abcos() xa = acos(+) xb = bcos() xa = asin(+) xb = bsin() a b   December 31, 2018

Projection a =( xa, ya ) b =( xb, yb ) ab = abcos() The length of the projection of a onto b is given by a b  ab December 31, 2018

3D Vectors This all holds for 3D vectors too. a =( xa, ya, za ) b =( xb, yb, zb ) ab = xa xb + ya yb + za zb ab = abcos() December 31, 2018

Vector Cross Product axb axb is perpendicular to a and b. Use the right hand rule to determine the direction of axb. b  a Image from www.physics.udel.edu December 31, 2018

Cross Product and Area axb b b   ||a|| a a ||a||x||b|| = area pf the parallelogram. December 31, 2018

Computing the Cross Product December 31, 2018

Linear Interpolation LERP: /lerp/, vi.,n. Quasi-acronym for Linear Interpolation, used as a verb or noun for the operation. “Bresenham's algorithm lerps incrementally between the two endpoints of the line.” p = (1 – t) a + t b = a + t(b – a) a b L tL (1-t)L December 31, 2018

p = (1 – t) a + t b = a + t(b – a) b t = 1 t = .75 t = .5 t = .25 L a December 31, 2018

Triangles a If (x, y) is on the edge ab, (x, y) = (1 – t) a + t b = a + t(b – a). Similar formulas hold for points on the other edges. If (x, y) is in the triangle: (x, y) =  a +  b +  c  +  +  = 1 ( ,  ,  ) are the Barycentric coordinates of (x, y). (x,y) c b December 31, 2018

Triangles p = a + (b-a) + (c-a) p = (1-  - )a + b + c  = 2  = 0  = 1  = -1  = 2 p = (1-  - )a + b + c  = 1-  -  p = p(, , ) = a + b + c  = 1 c c-a  = 0 b a b-a Barycentric coordinates  = -1  = 0  = 1 December 31, 2018

Computing Barycentric Coordinates (x,y) (x,y) b c December 31, 2018

Barycentric Coordinates as Areas (x,y) where A is the area of the triangle.  +  +  = 1 c b December 31, 2018

3D Triangles a where A is the area of the triangle. c  +  +  = 1 b This all still works in 3D. (x,y,z) where A is the area of the triangle.  +  +  = 1 c b But how do we find the areas of the triangles? December 31, 2018

3D Triangles - Areas axb b B C   a A December 31, 2018

Triangle Assignment http://www.ccs.neu.edu/home/fell/CSU540/programs/CSU540ColorTriangle.html December 31, 2018