©College of Computer and Information Science, Northeastern UniversityFebruary 21, 20161 CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture.

Slides:



Advertisements
Similar presentations
Software project Gnome Graphics Olga Sorkine Andrei Scharf Office: Schreiber 002, Web:
Advertisements

College of Computer and Information Science, Northeastern UniversityApril 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2007 Lecture.
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.
UBI 516 Advanced Computer Graphics
General Physics (PHYS101)
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
CS 4731: Computer Graphics Lecture 6: Points, Scalars and Vectors Emmanuel Agu.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter Vector Tools for Graphics.
©College of Computer and Information Science, Northeastern UniversityJune 26, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 11.
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.
Vectors.
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
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.
Scalar and Vector Fields
Graphing Complex Numbers AND Finding the Absolute Value of Complex Numbers SPI Compute with all real and complex numbers. Checks for Understanding.
1 Physics 111/121 Mini-Review Notes on Vectors. 2 Right hand rule: - curl fingers from x to y - thumb points along +z.
Chapter 9-Vectors Calculus, 2ed, by Blank & Krantz, Copyright 2011 by John Wiley & Sons, Inc, All Rights Reserved.
Engineering Fundamentals
College of Computer and Information Science, Northeastern UniversitySeptember 7, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2007.
©College of Computer and Information Science, Northeastern UniversitySeptember 9, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture.
Recap of linear algebra: vectors, matrices, transformations, … Background knowledge for 3DM Marc van Kreveld.
ME 2304: 3D Geometry & Vector Calculus
1.1 – 1.2 The Geometry and Algebra of Vectors.  Quantities that have magnitude but not direction are called scalars. Ex: Area, volume, temperature, time,
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.
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.
Properties of Vector Operations: u, v, w are vectors. a, b are scalars. 0 is the zero vector. 0 is a scalar zero. 1. u + v = v + u 2. (u + v) + w = u +
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Vectors CHAPTER 7. Ch7_2 Contents  7.1 Vectors in 2-Space 7.1 Vectors in 2-Space  7.2 Vectors in 3-Space 7.2 Vectors in 3-Space  7.3 Dot Product 7.3.
College of Computer and Information Science, Northeastern UniversityOctober 17, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 5.
©College of Computer and Information Science, Northeastern University CS 4300 Computer Graphics Prof. Harriet Fell Fall 2012 Lecture 12 – October 1, 2012.
©College of Computer and Information Science, Northeastern UniversityOctober 19, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2007.
Creating your own image data files. Simple ASCII file output in Java import java.io.FileOutputStream; import java.io.PrintWriter; … PrintWriter out =
College of Computer and Information Science, Northeastern UniversityOctober 31, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2009.
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.
Lecture 2 Vectors.
CS 551 / 645: Introductory Computer Graphics Mathematical Foundations.
CS 325 Introduction to Computer Graphics 04 / 12 / 2010 Instructor: Michael Eckmann.
11.2 Vectors in Space. A three-dimensional coordinate system consists of:  3 axes: x-axis, y-axis and z-axis  3 coordinate planes: xy -plane, xz -plane.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner Math Basics Week 1, Fri.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 3: Transformations 1
Vectors and Scalars and Their Physical Significance.
©College of Computer and Information Science, Northeastern UniversityFebruary 25, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2009.
College of Computer and Information Science, Northeastern UniversityFebruary 27, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lectures.
Instructor: Mircea Nicolescu Lecture 9
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
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.
Physics 141Mechanics Lecture 3 Vectors Motion in 2-dimensions or 3-dimensions has to be described by vectors. In mechanics we need to distinguish two types.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Introduction to Vectors Section Vectors are an essential tool in physics and a very significant part of mathematics. Their primary application.
CS G140 Graduate Computer Graphics
CS5310 Graduate Computer Graphics
Lecture 03: Linear Algebra
Joshua Barczak CMSC 435 UMBC
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.
Prof. Harriet Fell Spring 2007 Lecture 19 – February 22, 2007
Chapter II Mathematics: Basics
Prof. Harriet Fell Spring 2007 Lecture 19 – February 22, 2007
Prof. Harriet Fell Spring 2007 Lecture 4 - January 17, 2007
CSE 411 Computer Graphics Lecture #2 Mathematical Foundations
2D Graphics Lecture 4 Fri, Aug 31, 2007.
Rayat Shikshan Sanstha’s S.M.Joshi College, Hadapsar -28
PPM file format CSE 681.
Prof. Harriet Fell Spring 2007 Lecture 4 - January 17, 2007
Presentation transcript:

©College of Computer and Information Science, Northeastern UniversityFebruary 21, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 19 – February 12, 2009

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Vectors A vector describes a length and a direction. a b a = b a zero length vector 1 a unit vector

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Vector Operations a a b b b+a -d c-d Vector Sum a -a c Vector Difference d

©College of Computer and Information Science, Northeastern UniversityFebruary 21, 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 = x a x + y a y a =( x a, y a ) or x, y and z form an orthonormal 3D basis. or a =(a x,a y )

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Vector Length Vector a =( x a, y a ) yaya xaxa ||a|| a

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Dot Product a =( x a, y a ) b =( x b, y b ) a  b = x a x b + y a y b a  b =  a    b  cos(  ) a b   x a =  a  cos(  +  ) x b =  b  cos(  ) x a =  a  sin(  +  ) x b =  b  sin(  )

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Projection a =( x a, y a ) b =( x b, y b ) a  b =  a    b  cos(  ) The length of the projection of a onto b is given by a b  abab

©College of Computer and Information Science, Northeastern UniversityFebruary 21, D Vectors This all holds for 3D vectors too. a =( x a, y a, z a ) b =( x b, y b, z b ) a  b = x a x b + y a y b + z a z b a  b =  a    b  cos (  )

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Vector Cross Product axb a b  axb is perpendicular to a and b. Use the right hand rule to determine the direction of axb. Image from

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Cross Product and Area axb a b  a b  ||a|| ||a||x||b|| = area pf the parallelogram.

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Computing the Cross Product

©College of Computer and Information Science, Northeastern UniversityFebruary 21, 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

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Lerp Demo b a L p = (1 – t) a + t b = a + t(b – a) t =.5 t = 1 t =.25 t =.75 t = 0

©College of Computer and Information Science, Northeastern UniversityFebruary 21, 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). Triangles a b c (x,y)

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Triangles a b c b-a c-a p = a +  (b-a) +  (c-a)  = 0  = 1  = 2  = -1  = 0  = 1  = 2  = -1 Barycentric coordinates  = 1-  -  p = p( , ,  ) =  a +  b +  c  = 0 p = (1-  -  )a +  b +  c  = 1

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Computing Barycentric Coordinates a b c (x,y)

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Barycentric Coordinates as Areas a b c (x,y) where A is the area of the triangle.  +  +  = 1

©College of Computer and Information Science, Northeastern UniversityFebruary 21, D Triangles b c (x,y,z) where A is the area of the triangle.  +  +  = 1 This all still works in 3D. But how do we find the areas of the triangles? a

©College of Computer and Information Science, Northeastern UniversityFebruary 21, D Triangles - Areas axb a b   C B A

©College of Computer and Information Science, Northeastern UniversityFebruary 21, Triangle Assignment

©College of Computer and Information Science, Northeastern UniversityFebruary 21, 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. Whitespace. The maximum color value again in ASCII decimal. Whitespace. 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

©College of Computer and Information Science, Northeastern UniversityFebruary 21, ppm Example P3 # feep.ppm

©College of Computer and Information Science, Northeastern UniversityFebruary 21, 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()); }