6. 3D Vectors, Geometry and Transformations

Size: px
Start display at page:

Download "6. 3D Vectors, Geometry and Transformations"

Transcription

1 6. 3D Vectors, Geometr ad Trasformatios 6.1 From 2D to 3D 6.2 Vectors ad Matrices i 3D 6.3 The Cross Product (Vector Product) 6.4 Straight Lies, Lie Segmets ad Ras 6.5 The Geometr of Plaes 6.6 More Commo Graphics Problems 6.7 3D Trasformatios 6.8 Trasformatios i OpeGL 6.9 A Virtual Trackball "It's magic, or geometr, or oe of those thigs Terr Pratchett 2008 Burkhard Wuesche Slide From 2D to 3D 3D poits ad vectors are 3-tuples Coordiate space is defied b three orthogoal uit vectors. Covetio: use upper-case letters for poits, e.g. A, Q, bold lower case letters for vectors, e.g. a, q, ad bold upper-case letters for matrices, e.g. M, R. Additio, scalig, subtractio, magitude ad ormalisatio all as for 2D, but with a etra coordiate. A cove combiatio of poits defies a cove polhedro rather tha a polgo. Products of vectors are ver importat i 3D Dot Product (Scalar Product), Cross Product (Vector Product) 2008 Burkhard Wuesche Slide 2 House3D A simple OpeGL program displaig a 3D object What the program does The code Aspects of the code Ol cosider aspects differet from the 2D eample: Represetig the 3D wireframe house 3D Orthographic Projectio Resiig the displa widow Drawig the picture Eercises Chagig the View (GluLookAt) 2008 Burkhard Wuesche Slide 3 What the program does Defies a simple house shape i wireframe form (i.e. made up of just straight lies represetig the edges) i 3-space. Displas a picture of the house usig a 3D orthographic projectio alog the ais A poit (,,) projects to a poit (,) Much more o this later Note that the -ais is UP The Situatio The Program Output 2008 Burkhard Wuesche Slide 4

2 // A basic OpeGL program displaig a 3D house shape #iclude <widows.h> #iclude <gl/gl.h> #iclude <gl/glu.h> #iclude <gl/glut.h> cost it widowwidth=400; cost it widowheight=400; // defie vertices ad edges of the house cost it umvertices=10; cost it umedges=17; cost float vertices[umvertices][3] = 0,0,0,1,0,0,0,1,0,1,1,0,0,0,2, 1,0,2,0,1,2,1,1,2,0.5f,1.5f,0,0.5f,1.5f,2; cost it edges[umedges][2] = 0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4, 1,5,3,7,2,6,2,8,8,3,6,9,9,7,8,9; void displa(void) glmatrimode(gl_modelview ); // Set the view matri... glloadidetit(); //... to idetit. glclear(gl_color_buffer_bit); // clear all piels i frame buffer glcolor3f (1.0, 0.0, 0.0); // draw subsequet objects i red glbegi(gl_lines); for(it i=0;i<umedges;i++) glverte3fv(vertices[edges[i][0]]); glverte3fv(vertices[edges[i][1]]); gled(); glflush (); 2008 Burkhard Wuesche Slide 5 void iit(void) // select clearig color (for glclear) glclearcolor (1.0, 1.0, 1.0, 0.0); // RGB-value for white // iitialie view (simple 3D orthographic projectio) glmatrimode(gl_projection); glloadidetit(); glortho(-2,2,-2,2,-3,3); void reshape(it width, it height ) it sie = mi(width, height); glviewport(0, 0, sie, sie); // Called at start, ad wheever user resies compoet // Largest possible square // create a sigle buffered colour widow it mai(it argc, char** argv) glutiit(&argc, argv); glutiitdisplamode(glut_single GLUT_RGB); glutiitwidowsie(widowwidth, widowheight); glutiitwidowpositio(100, 100); glutcreatewidow("house3d"); iit (); // iitialise view glutdisplafuc(displa); // Set fuctio to draw scee glutreshapefuc(reshape); // Set fuctio called if widow is resied glutmailoop(); retur 0; 2008 Burkhard Wuesche Slide 6 Represetig the Wireframe House Have a verte table ad a edge table cost float vertices[umvertices][3] = 0,0,0,1,0,0,0,1,0,1,1,0,0,0,2, 1,0,2,0,1,2,1,1,2,0.5f,1.5f,0,0.5f,1.5f,2; cost it edges[umedges][2] = 0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4, 1,5,3,7,2,6,2,8,8,3,6,9,9,7,8,9; Each verte table arra etr is itself a arra of 3 floats, represetig a poit i R 3 [3D-space] Edge table values are idices ito verte table 8 e.g. edge 3,7 is the edge from V 3 (1,1,0) to V (1,1,2) Coordiate sstem is right haded Burkhard Wuesche Slide 7 3D Orthographic Projectio There are tpicall at least four phases to drawig ( rederig ) a scee i OpeGL: (1) Defie required projectio (2) Defie required view (allows ou to to rotate, scale, traslate, etc. the model) (3) Set up scee lightig (4) Output scee primitives (i.e. describe/defie the scee) I this eample we have a simple orthographic projectio [i.e. (,,) (,)], a trivial view ad o lightig. (1) Defie required projectio: glmatrimode(gl_projection); // Iitialise projectio matri... Projectio volume glloadidetit(); //... to the idetit matri [more later]. glortho(-2,2,-2,2,-3,3); // Set orthographic projectio volume [more later] glortho(left, right, bottom, top, ear, far) defies the coordiates of the projectio volume, with ear ad far beig measured from the view poit i the view directio, i.e. the are depths ot -values. View poit (origi) View directio (egative of ais) (-2,-2,-3) Near plae (2,2,-3) Far plae 2008 Burkhard Wuesche Slide 8 (2,2,3)

3 Resiig the Displa Widow The argumet of glutreshapefuc (the fuctio reshape) is called at the start ad wheever the displa widow gets resied Specifies how the scee will be redraw i the resied widow I the previous eamples the viewport was the etire OpeGL widow I this eample, we set the viewport to be the largest square possible. it sie = mi(width, height); The projectio matri maps the scee oto the viewport glviewport(0, 0, sie, sie); The rest (if a) of the widow is uused glviewport parameters are,, width ad height i piel coordiates, with (, ) beig the bottom left corer of the viewport. I OpeGL, coordiates alwas icrease upwards, so (0,0) is the bottom left corer of the widow, ot the top left as is ormal i scree coordiates. Viewport 2008 Burkhard Wuesche Slide 9 Drawig the Picture (2) Defie required view of the model. The two lies glmatrimode(gl_modelview ); glloadidetit(); iitialise the model + view matri to the idetit matri, meaig do t trasform the scee at all. Do t epect to uderstad this just et!! View directio is alog egative ais. (3) Set up scee lightig - ca ot illumiate wireframes (sice there is o surface ormal)! (4) Output scee primitives (as i the 2D eample) glclear(gl_color_buffer_bit); // clear all piels i frame buffer glcolor3f (1.0, 0.0, 0.0); // draw scee i red glbegi(gl_lines); // draw edges as lie segmets (3D vertices) for(it i=0;i<umedges;i++) glverte3fv(vertices[edges[i][0]]); glverte3fv(vertices[edges[i][1]]); gled(); glflush (); 2008 Burkhard Wuesche Slide 10 Eercises Chage the program to use glverte3f everwhere istead of glverte3fv. How could ou cetre the picture i the output widow? [Fid a solutio that ivolves ol adjustig two of the umbers i the program] How could ou icrease the sie of the picture i the output widow? What is the effect of puttig (a) the ear plae, ad (b) the far plae at = 1? What happes if the ear ad far faces of the projectio volume are rectagular rather tha square? 2008 Burkhard Wuesche Slide 11 Chagig the View We ca rotate the house to give a more useful view b chagig step (2) to glmatrimode(gl_modelview ); // Set the view matri.. glloadidetit(); //... to idetit. glrotatef(-40,1,2,-0.3f); // Rotate -40 degrees aroud a ais through the // origi i the directio (1,2,-0.3). Looks vaguel OK, but how ca we determie a suitable ais ad agle, ecept b lots of eperimetatio? Aswers: Either (a) We ca t. Yet. Need some maths! Or (b) Use a GLU fuctio to do it for us Burkhard Wuesche Slide 12

4 GLULookAt Remember: GLU is a package of utilit fuctios o top of GL. Replace start of displa() with: glmatrimode( GL_MODELVIEW ); glloadidetit(); glulookat(-1,2,5, 0.5f,0.75f,1, 0,1,0); Replace start of iit() with: glmatrimode(gl_projection); glloadidetit(); glortho(-2,2,-2,2,0,7); NB: projectio volume coords are w.r.t. camera The commad glulookat( camerax, cameray, cameraz, lookatx, lookaty, lookatz, UpX, UpY, UpZ) specifies where the virtual camera is, where it s poitig to, ad how we re orietig (rotatig) it Burkhard Wuesche Slide 13 GLULookAt (cot d) What's happeig? Camera coordiate sstem (u, v, aes) has origi at camera poit, amel (-1, 2, 5). vector from camera to lookat defies the NEGATIVE ais House image is projected oto viewplae, which is defied to be perpedicular to ais Projectio of up oto viewplae is v ais. Projectio volume is defied b glortho, i camera coordiates viewplae UpX camerax lookatx Let w = UpY, e= cameray lookaty u UpZ cameraz lookatz e w ( w ) the =, v=, ad u= v e w ( w ) projectio volume 2008 Burkhard Wuesche Slide 14 v GLULookAt (cot d) Output of program is: 6.2 Vectors ad Matrices i 3D Vector ad matri operatios as i 2D Determiat det M (also writte M ) of a 33 matri M m m m m m m m m m m m m m m m = m32 m33 m31 m33 m31 m m m m Iverse of a matri: The matri M -1 is called the iverse of M if M -1 M=MM -1 =I Each verte has bee projected i directio oto the viewplae. But to uderstad eactl what s happeig here we eed to uderstad 3D vectors, trasformatios ad other miscellaeous geometr Burkhard Wuesche Slide 15 m11 m12 m i+ j ji M = m21 m22 m23 M = A where aij = ( 1 ) A, 1 i, j 3 m31 m32 m M 33 kl ad A is the 2 2 matri formed b deletig the kth row ad lth colum of M Burkhard Wuesche Slide 16

5 The Dot Product Defiitio The dot product (or ier product, or scalar product) of two 3D vectors v = (v 1,v 2,v 3 ) ad w = (w 1,w 2,w 3 ) is: v w = v 1 w 1 + v 2 w 2 + v 3 w 3. Properties (same as i 2D) Smmetr: a b = b a Liearit: (a+b) c = a c + b c Homogeeit: (sa) b = s(a b) b 2 = b b Eample: Prove a - b 2 = a a -2a b + b b Applicatios (same as i 2D, ecept where 2D Perp Vector is used) Agle betwee two vectors The sig of a b ad perpedicularit Projectig vectors Ra reflectio 2008 Burkhard Wuesche Slide 17 Coordiate Trasformatios The compoet of a vector v i a directio represeted b a uit vector i is the perpedicular projectio of v oto the directio of i. Give b (v i) i (formula from Chapter 5, slide 12) Let P be a poit ad E be the camera locatio give i,,-coordiates The compoets of the poit P epressed i the (u,v,) coordiate sstem are: (r u), (r v) ad (r ) where r = P E 2008 Burkhard Wuesche Slide 18 E v u r P 6.3 The Cross Product Let i, j, ad k be uit vectors alog the, ad aes respectivel. Defie the cross product (or vector product) operator such that: It's a liear operator, i.e. a (b+c) = a b + a c a b = a b si θ where θ is the agle betwee a ad b i rage [0,2π] It's homogeeous, i.e. (sa) b = s (a b) i j = k, j k = i, k i = j j i = -k, k j = -i, i k = -j i i = j j = k k = 0 Ca show from this (UDOO) that if a = a 1 i + a 2 j + a 3 k ad b = b 1 i + b 2 j + b 3 k ab 2 3 ab 3 2 i j k the a b = ab 3 1 ab 1 3 = a1 a2 a3 ab 1 2 ab 2 1 b1 b2 b Burkhard Wuesche Slide 19 Properties of Cross Product Ke properties (UDOO proofs): a b is a vector perpedicular to both a ad b Directio of a b is give b "right-had rule" a b = b a a b is area of parallelogram defied b a ad b Hece area of triagle defied b a ad b is 0.5 * a b 2008 Burkhard Wuesche Slide 20 a b a b a b

6 6.4 Straight Lies, Lie Segmets ad Ras Use a parametric form for lies. Straight lie through two poits P 1 ad P 2 is P( α) = (1 α) P1+ αp2 = P1+ α( P2 P1) = P + α v where v = P 2 P 1 is the displacemet vector from P 1 to P 2. If α costraied to the rage [0,1] we have a lie segmet all poits betwee P 1 ad P 2. If α costraied to the rage [0, ] we have a ra. If α is a real umber, we have a full lie i -space Burkhard Wuesche Slide The Geometr of Plaes The Poit-Normal Form of a Plae Equatio Distace of a Plae from the Origi Distace of a Poit from a Plae Iside-Outside Half-Space Test Itersectio Lie-Plae 2008 Burkhard Wuesche Slide 22 The Poit-Normal Form of a Plae Ca defie a plae b givig oe poit o it, S sa, ad its uit ormal. The for a poit P o the plae, S (P-S) is perpedicular to. s P i.e. (P-S) = 0. p ["Poit-ormal" form of plae equatio] If p ad s are the vectors to P ad S the ca write this as (p - s) = 0 i.e. p = s or p = d where d = s If is (a,b,c) ad p is (,,), the this is the familiar equatio a + b + c =d Burkhard Wuesche Slide 23 O Distace of plae from origi Let Q be a poit o the plae such that q is parallel to. The the legth of q is the "shortest distace" to the plae from the origi. We have the plae equatio p = d for a poit P o the plae. Hece q = d. But sice is parallel to q, q = q. Q Thus q = d. S q Hece, i the equatios p = d ad O a + b + c = d d is the distace to the plae from the origi provided = (a,b,c) is a uit vector. UDOO: How far is the plae = 5 from the origi? 2008 Burkhard Wuesche Slide 24

7 Distace of Poit from Plae How far is a poit Q from the plae p = d? Let P be the earest poit o the plae to Q, Q so that (Q-P) is parallel to. The the required aswer δ is δ δ = Q-P = (q - p) Sice q - p is parallel to, ca write as δ = (q - p) = q - p = q - d = aq 1 + bq 2 + cq 3 - d where = (a,b,c) is the uit ormal ad q = (q 1, q 2, q 3 ) δ is positive if Q is outside the plae, egative if Q is iside. WARNING: Alwas scale plae equatio a+b+c=d so that (a 2 +b 2 +c 2 )= Burkhard Wuesche Slide 25 P Iside-Outside Half-Space Tests (cot d) If plae defied i poit-ormal form, ca b covetio take to be the outward ormal ad poits "o that side" of the plae are said to be "outside", while poits o the other side are "iside". Hece, if S is a poit o the plae ad Q is a poit to be tested: (Q-S) >0 Q is outside (Q-S) =0 Q is o the plae Q (Q-S) <0 Q is iside (see chapter 5, slide 11) 2008 Burkhard Wuesche Slide 26 S Iside-Outside Half-Space Tests NOTE: Above plae equatios assume 3D vectors. If all vectors are 2D, the plae becomes a lie, ad the equatios give the distace of a lie from the origi, the distace of a poit from a lie, ad categorise a 2D poit as iside or outside a lie. Itersectio Lie-Plae Give is a lie p(t) = p 0 + tc ad a plae p=d where c is the lie s directio The lie itersects the plae whe d p0 t = c Q: What happes if c = 0? 2008 Burkhard Wuesche Slide Burkhard Wuesche Slide 28

8 6.6. More Commo Graphics Problems The Area of a Triagle use magitude of a cross product see "Properties of Cross Product" The Robust Normal to a Polgo 2008 Burkhard Wuesche Slide 29 The Normal to a Polgo I priciple, get ormal from the cross product of a two adjacet edge vectors, e.g. = (D-C) (B-C) E But this is o-robust gives erroeous or A urepresetative value whe: B 3 vertices co-liear C 2 adjacet vertices ver close together Magitude of cross product teds to ero ad directio is sesitive to slight movemet i either poit Polgo ot coplaar e.g. (B-A) (E-A), above, ot represetative Warig: I computer graphics, eceptioal coditios occur all the time! 2008 Burkhard Wuesche Slide 30 D A Robust Normal Algorithm A E B C D Polgo ABCDE NOTE: The orietatio of the resultig ormal is such that the vertices are listed i couterclockwise order aroud it. Just add together all the cross products of adjacet edge vectors i.e. (B A) (E A) + (C B) (A B) + (D C) (B C) + (E D) (C D) + (A-E) (D E) Normalise the result. Robust. Short edges or earl co-liear verte triples give egligible cross product cotributio Log earl-perpedicular edges give biggest cotributio 2008 Burkhard Wuesche Slide D Trasformatios Natural etesio of 2D. We will use the homogeeous coordiate form for all trasformatios. To covert betwee ordiar 3D coordiates ad homogeous 3D coordiates: 3D ordiar 3D homogeeous (,, ) T (,,, 1) T 3D homogeeous 3D ordiar (,,,w) T (/w, /w, /w) T 2008 Burkhard Wuesche Slide 32

9 Traslatio The matri for a traslatio b a vector t = (t, t, t ) is: t t T = t Burkhard Wuesche Slide 33 Scalig The matri for a scalig b factors of S, S, S i, ad respectivel is: S S 0 0 S = 0 0 S A egative S gives a reflectio about the = 0 plae. Similarl for egative S or S Burkhard Wuesche Slide 34 Shearig The geeral shear matri is: 1 h h 0 h 1 h 0 H = h h D shearig i its most geeral form is ver rare. Occasioall meet horiotal shearig e.g. a pile of paper pushed to oe side so that the sides of the pile are still straight but ot vertical. UDOO: What would the matri for that look like? Rotatio Rotatios are b far the most cofusig of the trasformatios Most tets cover rotatios aroud the three coordiate aes ad tr to build all other rotatios from those But some cases ver difficult We will cosider three differet rotatio situatios: Rotatio aroud the three coordiate aes Rotatio to alig a object with a ew coordiate sstem Rotatio aroud a arbitrar ais 2008 Burkhard Wuesche Slide Burkhard Wuesche Slide 36

10 Rotatio aroud Coordiate Aes Have three aes to rotate about, so three differet matrices. Let C = cos θ ad S = si θ. The the three matrices for positive (right haded) rotatio are: Rotatio about the -ais: C S 0 R = 0 S C Rotatio about the ais: C 0 S R = S 0 C 0 R : UDOO Note o 3 3 rotatio matrices: Row ad colum correspodig to ais of rotatio are as for idetit I Other elemets are C o diagoal, ± S off diagoal, so that R I if θ 0. Sig of S ca be iferred from the fact that rotatio aroud,, b θ=90 ο trasforms,,, respectivel Burkhard Wuesche Slide 37 Rotatig to Alig with New Coordiate Aes Ofte we have some object ad wat it at a ew positio ad with a ew orietatio Geerall ivolves both rotatio ad traslatio Traslatio trivial -- focus ol o rotatio here Problem: what is the rotatio matri R that rotates a coordiate sstem (,,) to alig with a ew coordiate sstem (a,b,c) with the same origi, where a,b,c are uit vectors alog the ew aes. (0,1,0) (0,0,1) (1,0,0) R*(,,)= 2008 Burkhard Wuesche Slide 38 c b a Rotatig to Alig with New Coordiate Aes (cot'd) To get R: we have R (1 0 0) T = a R (0 1 0) T = b R (0 0 1) T = c Above 3 eqs equivalet to: a b c = a b c a b c R a b c = a b c R a b c or R HC.. a b c 0 a b c 0 = a b c SO IMPORTANT GENERAL RESULT: Colums of a 3 3 rotatio matri are uit vectors alog the rotated coordiate ais directios UDOO derive R, R, R from this rule Burkhard Wuesche Slide 39 Rotatio about a arbitrar ais Ofte, whe buildig a 3D scee or object, eed to rotate a compoet about some arbitrar ais through a referece poit o it. [e.g. forearm of robot rotatig aroud a ais through the elbow]. Ivolves three steps: (1) Traslate referece poit to origi (2) Do the rotatio (3) Traslate referece poit back agai Three approaches for step (2) [et 3 slides]: Tetbook method Decompose rotatio ito primitive rotatios about,, aes Nice eercise, but hard to get right i practice Coordiate sstem aligmet method Geeralised rotatio matri A aside: Quaterios provide a elegat wa of maipulatig (ais, agle) rotatios directl Burkhard Wuesche Slide 40

11 Tetbook Method Rotate the object so that the required ais of rotatio r lies alog the ais [R aligz ] Do the rotatio about ais Udo origial rotatio [R aligz -1 ] How to get R aligz? Measure aimuth, θ, as a right haded rotatio about the ais, startig at the ais. Measure elevatio, ø (or "latitude") as agle above plae =0. R aligz = R (φ) R ( θ) 2008 Burkhard Wuesche Slide 41 φ = ta 1 u u 2 + u 2 θ r φ U = (u, u, u) θ = ata2 (u, u ) i.e. a 4 - quadrat ta 1 u u Coordiate Sstem Aligmet Method Assume we have a coordiate sstem (a,b,c) attached to the object ad wat to rotate it to a ew kow orietatio (a',b',c') Slightl differet problem from previous oe Etesio of "Rotate to alig" problem Solutio: Traslate object to origi Rotate (a,b,c) to alig with world coord aes The iverse of the "rotate to alig" case Rotate coord aes to alig with (a',b',c') Same as "rotate to alig" case Traslate back agai TR R T Full matri is: 1 O abc ' ' ' abc O 2008 Burkhard Wuesche Slide 42 O c b a b' O c' a' The Iverse of a Rotatio Matri [eeded o previous slide] Remember: colums of a rotatio matri are uit vectors alog the rotated coordiate ais directios So colums are orthogoal, i.e dot products = 0 So: a a a a b c b b b a b c = c c c a b c i.e. T RR= I ad hece R 1 T = R So the iverse of a rotatio matri is its traspose (Note: a matri with this propert is called orthogoal.) 2008 Burkhard Wuesche Slide 43 Geeralised Rotatio Matri Matri for a arbitrar rotatio is: 2 t + c t s t + s 2 R= t+ s t + c t s 2 t s t + s t + c where the ais of rotatio (ormalised) is (,,), c ad s are resp. the cosie ad sie of the agle of rotatio, ad t=(1-c). Proof outlie [for ethusiasts ol] see Maillot, Graphics Gems I, P498 for details Rotatio ais, P (poit to rotate) (ormalised) P (= P rotated θ) O (origi) 2008 Burkhard Wuesche Slide 44 H Not eam relevat! θ V (= P rotated 90º)

12 6.8 Trasformatios i OpeGL OpeGL rederig has two 4 4 trasformatio matrices: The Projectio matri, P The Model-View matri, M All vertices (i.e. poits, polgo vertices, etc) are multiplied b M the P before the (,,) (,) projectio is doe Trasformatios i OpeGL (cot d) The P matri hadles perspective projectios (see later) ad scalig from world coordiates to scree coordiates. The M matri hadles both modellig operatios i.e. the trasformatios that are part of the process of specifig a scee, e.g. positioig some geeric chair to a certai poit i the scee) the viewig trasformatio i.e. the rotatio ad traslatio required to allow us to view the scee from somewhere other tha alog the -ais Burkhard Wuesche Slide Burkhard Wuesche Slide 46 Trasformatios i OpeGL (cot d) To set the value of oe of the two matrices: Select the oe of iterest, e.g. glmatrimode( GL_MODELVIEW ) Set it to the idetit, or load it with a specific matri glloadidetit(), or glloadmatrif(cost GLfloat *m ) Multipl it o the right b oe or more primitive matrices, e.g. gltraslatef(glfloat d, GLfloat d, GLfloat d) glscalef(glfloat Factor, GLfloat Factor, GLfloat Factor) glrotatef(glfloat agleidegrees, GLfloat aisx, GLfloat aisy, GLfloat aisz) glmultmatrif(cost GLfloat *m) // geeral purpose matri // Matri is 16 floats, columwise, i.e. m 00, m 10, m 20, m 30,m 01, m 11,... m 33 Note: sice matrices are multiplied o the right the last matri multiplied i is the first to be applied to the vertices Sice (P Q R)v = P (Q (R v)) 2008 Burkhard Wuesche Slide 47 Eample MODEL_VIEW Trasformatios I the displa method of the House3D program... glloadidetit(); glloadidetit(); gltraslatef(-0.5f,-0.5f,-1.0f); glrotatef(90,0,0,1); glloadidetit(); glrotatef(90,0,0,1); glloadidetit(); glrotatef(90,0,0,1); gltraslatef(-0.5f,-0.5f,-1.0f); glloadidetit(); gltraslatef(-0.5f,-0.5f,-1.0f); glloadidetit(); glscalef(2,0.5f,1); 2008 Burkhard Wuesche Slide 48

13 6.9 A Virtual Trackball (from Agel, sectio ) A wa of usig the mouse to rotate the scee Imagie the scee is ecased i a freel rotateable trasparet sphere. Half of sphere is "stickig out" of scree widow Clickig ad draggig the mouse over the widow is like rotatig the sphere to a ew positio. To compute rotatio: 1. Map mouse drag ed-poits (e 1 ad e 2 ) from 2D widow coordiates to 3D coordiates (p 1 ad p 2 ) o surface of virtual sphere. If widow coords p 2 (,) are i rage -1 to +1, ad sphere is uit p 1 sphere, mappig is widow 2 2 ( ) (, ),, 1 2. Compute the rotatio reqd to move p 1 to p 2 [et slide] 2008 Burkhard Wuesche Slide 49 e 1 e 2 A Virtual Trackball (cot'd) Sphere rotatio is about a ais θ 1 = cos v1 v2 = v v v v where v 1 ad v 2 are positio vectors of p 1 ad p 2 [NB: the have uit legth. Wh?] Rotatio agle is 2008 Burkhard Wuesche Slide 50 v 2 v 1 θ Trackball.h class CTrackball public: CTrackball(); Code ot eam relevat! virtual ~CTrackball(); void tbiit(gluit butto); void tbmatri(); void tbreshape(it width, it height); void tbmouse(it butto, it state, it, it ); void tbkeboard(it ke); void tbmotio(it, it ); private: GLuit tb_lasttime; GLfloat tb_lastpositio[3]; GLfloat tb_agle; GLfloat tb_ais[3]; // rotatio ais ad agle GLfloat tb_trasform[4][4]; // curret rotatio matri for GL_MODEL_VIEW GLuit tb_width; GLuit tb_height; // width ad height of widow GLit tb_butto; GLboolea tb_trackig; void _tbpoittovector(it, it, it width, it height, float v[3]); void _tbstartmotio(it, it, it butto, it time); void _tbstopmotio(it butto, usiged time); ; 2008 Burkhard Wuesche Slide 51 #iclude <math.h> #iclude "Trackball.h" #iclude <gl/glut.h> CTrackball::CTrackball() tb_agle = 0.0; tb_ais[0]=0.0;tb_ais[1]=0.0;tb_ais[2]=0.0; tb_trackig = GL_FALSE; CTrackball::~CTrackball() Trackball.cpp void CTrackball::_tbPoitToVector(it, it, it width, it height, float v[3]) float d, a; // project, oto a hemi-sphere cetered withi width, height. v[0] = (float) ((2.0 * - width) / width); v[1] = (float) ((height * ) / height); d = (float) (sqrt(v[0] * v[0] + v[1] * v[1])); v[2] = (float) (cos(( / 2.0) * ((d < 1.0)? d : 1.0))); a = (float) (1.0 / sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2])); v[0] *= a; v[1] *= a; v[2] *= a; 2008 Burkhard Wuesche Slide 52

14 void CTrackball::_tbStartMotio(it, it, it butto, it time) tb_trackig = GL_TRUE; tb_lasttime = time; _tbpoittovector(,, tb_width, tb_height, tb_lastpositio); void CTrackball::_tbStopMotio(it butto, usiged time) tb_trackig = GL_FALSE; tb_agle=0.0; void CTrackball::tbIit(GLuit butto) tb_butto = butto; tb_agle = 0.0; // put the idetit i the trackball trasform for(it i=0;i<4;i++) for(it j=0;j<4;j++) tb_trasform[i][j]=0.0; tb_trasform[i][i]=1.0; Trackball.cpp (cot d) 2008 Burkhard Wuesche Slide 53 Trackball.cpp (cot d) void CTrackball::tbMatri() glpushmatri(); glloadidetit(); glrotatef(tb_agle, tb_ais[0], tb_ais[1], tb_ais[2]); glmultmatrif((glfloat *)tb_trasform); glgetfloatv(gl_modelview_matrix, (GLfloat *)tb_trasform); glpopmatri(); glmultmatrif((glfloat *)tb_trasform); void CTrackball::tbReshape(it width, it height) tb_width = width; tb_height = height; void CTrackball::tbMouse(it butto, it state, it, it ) if (state == GLUT_DOWN && butto == tb_butto) _tbstartmotio(,, butto, glutget(glut_elapsed_time)); else if (state == GLUT_UP && butto == tb_butto) _tbstopmotio(butto, glutget(glut_elapsed_time)); 2008 Burkhard Wuesche Slide 54 Trackball.cpp (cot d) void CTrackball::tbKeboard(it ke) it i,j; for(i=0;i<4;i++) for(j=0;j<4;j++) tb_trasform[i][j]=0.0; tb_trasform[3][3]=1.0; switch (ke) case (it) '': tb_trasform[0][0]=tb_trasform[1][1]=tb_trasform[2][2]=1.0; break; case (it) '': tb_trasform[0][1]=tb_trasform[1][2]=tb_trasform[2][0]=1.0; break; case (it) '': tb_trasform[0][2]=tb_trasform[1][0]=tb_trasform[2][1]=1.0; break; default:; // remember to draw ew positio glutpostredispla(); 2008 Burkhard Wuesche Slide 55 void CTrackball::tbMotio(it, it ) GLfloat curret_positio[3], d, d, d; if (tb_trackig == GL_FALSE) retur; _tbpoittovector(,, tb_width, tb_height, curret_positio); // calculate the agle to rotate b (directl proportioal to the // legth of the mouse movemet d = curret_positio[0] - tb_lastpositio[0]; d = curret_positio[1] - tb_lastpositio[1]; d = curret_positio[2] - tb_lastpositio[2]; tb_agle = (float) (90.0 * sqrt(d * d + d * d + d * d)); Trackball.cpp (cot d) // calculate the ais of rotatio (cross product) tb_ais[0] = tb_lastpositio[1] * curret_positio[2] - tb_lastpositio[2] * curret_positio[1]; tb_ais[1] = tb_lastpositio[2] * curret_positio[0] - tb_lastpositio[0] * curret_positio[2]; tb_ais[2] = tb_lastpositio[0] * curret_positio[1] - tb_lastpositio[1] * curret_positio[0]; // reset for et time tb_lasttime = glutget(glut_elapsed_time); tb_lastpositio[0] = curret_positio[0]; tb_lastpositio[1] = curret_positio[1]; tb_lastpositio[2] = curret_positio[2]; // remember to draw ew positio glutpostredispla(); 2008 Burkhard Wuesche Slide 56

15 #iclude <widows.h> #iclude <gl/gl.h> #iclude <gl/glu.h> #iclude <gl/glut.h> #iclude <iostream> usig amespace std; #iclude "Trackball.h" cost it widowwidth=400; House3DWithTrackball cost it widowheight=400; House3DWithTrackball (cot d) void displa(void) glclear(gl_color_buffer_bit); glcolor3f (1.0, 0.0, 0.0); // clear all piels i frame buffer // (red,gree,blue) colour compoets glmatrimode( GL_MODELVIEW ); // Set the view matri... glloadidetit(); //... to idetit trackball.tbmatri(); // defie vertices ad edges of the house cost it umvertices=10; cost it umedges=18; cost float vertices[umvertices][3] = 0,0,0,1,0,0,0,1,0,1,1,0,0,0,2, 1,0,2,0,1,2,1,1,2,0.5f,1.5f,0,0.5f,1.5f,2; cost it edges[umedges][2] = 0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4, 1,5,3,7,2,6,2,8,8,3,6,9,9,7,8,9; CTrackball trackball; // Add a trackball to our OpeGL program void hadlemousemotio(it, it ) trackball.tbmotio(, ); void hadlemouseclick(it butto, it state, it, it ) trackball.tbmouse(butto, state,, ); void hadlekeboardevet(usiged char ke, it, it ) trackball.tbkeboard(ke); 2008 Burkhard Wuesche Slide 57 // Rest is the same as i House3D void iit(void) // Rest of iitialisatio same as i House3D trackball.tbiit(glut_left_button); void reshape(it width, it height ) // Rest of reshape is the same as i House3D trackball.tbreshape(width, height); 2008 Burkhard Wuesche Slide 58 House3DWithTrackball (cot d) it mai(it argc, char** argv) glutiit(&argc, argv); glutiitdisplamode(glut_single GLUT_RGB); glutiitwidowsie(widowwidth, widowheight); glutiitwidowpositio(100, 100); glutcreatewidow("house3d"); iit (); // iitialise view glutmousefuc(hadlemouseclick); // Set fuctio to hadle mouse clicks glutmotiofuc(hadlemousemotio); // Set fuctio to hadle mouse motio glutkeboardfuc(hadlekeboardevet); // Set fuctio to hadle keboard iput Notes o House3DWithTrackball The mai class is almost idetical to House3D ecept: Add a global trackball variable Pass callback fuctios to GLUT for mouse click evets, mouse motio evets ad keboard evets. I more comple programs we have to decide which evets appl to the trackball ad which evets are related to other parts of the program. Iitialise trackball ad specif the associated mouse butto. Update trackball if the widow is reshaped. Add trackball rotatio matri to the MODEL_VIEW matri stack. glutdisplafuc(displa); glutreshapefuc(reshape); glutmailoop(); retur 0; // Set fuctio to draw scee // Set fuctio called if widow gets resied The CTrackball class cotais fuctios for hadlig trackball evets. Mouse positios are trasformed ito rotatios. Trackball accumulates rotatios Use glutpostredispla() to redraw the widow Burkhard Wuesche Slide Burkhard Wuesche Slide 60

Pattern Recognition Systems Lab 1 Least Mean Squares

Pattern Recognition Systems Lab 1 Least Mean Squares Patter Recogitio Systems Lab 1 Least Mea Squares 1. Objectives This laboratory work itroduces the OpeCV-based framework used throughout the course. I this assigmet a lie is fitted to a set of poits usig

More information

Why Do We Care About Lighting? Computer Graphics Lighting. The Surface Normal. Flat Shading (Per-face) Setting a Surface Normal in OpenGL

Why Do We Care About Lighting? Computer Graphics Lighting. The Surface Normal. Flat Shading (Per-face) Setting a Surface Normal in OpenGL Lightig Why Do We Care About Lightig? Lightig dis-ambiguates 3D scees This work is licesed uder a Creative Commos Attributio-NoCommercial- NoDerivatives 4.0 Iteratioal Licese Mike Bailey mjb@cs.oregostate.edu

More information

A Resource for Free-standing Mathematics Qualifications

A Resource for Free-standing Mathematics Qualifications Ope.ls The first sheet is show elow. It is set up to show graphs with equatios of the form = m + c At preset the values of m ad c are oth zero. You ca chage these values usig the scroll ars. Leave the

More information

Alpha Individual Solutions MAΘ National Convention 2013

Alpha Individual Solutions MAΘ National Convention 2013 Alpha Idividual Solutios MAΘ Natioal Covetio 0 Aswers:. D. A. C 4. D 5. C 6. B 7. A 8. C 9. D 0. B. B. A. D 4. C 5. A 6. C 7. B 8. A 9. A 0. C. E. B. D 4. C 5. A 6. D 7. B 8. C 9. D 0. B TB. 570 TB. 5

More information

The Platonic solids The five regular polyhedra

The Platonic solids The five regular polyhedra The Platoic solids The five regular polyhedra Ole Witt-Hase jauary 7 www.olewitthase.dk Cotets. Polygos.... Topologically cosideratios.... Euler s polyhedro theorem.... Regular ets o a sphere.... The dihedral

More information

The isoperimetric problem on the hypercube

The isoperimetric problem on the hypercube The isoperimetric problem o the hypercube Prepared by: Steve Butler November 2, 2005 1 The isoperimetric problem We will cosider the -dimesioal hypercube Q Recall that the hypercube Q is a graph whose

More information

Projection Transformations. and

Projection Transformations. and 3D Viewig Projectio Trasormatios a Viewig i Pipelie Implemetatio o 3D Viewig 3-D worl cooriate output primitives Apply ormalizig i trasormatio Clip agaist caoical View Volume 2D evice cooriates Trasorm

More information

Parabolic Path to a Best Best-Fit Line:

Parabolic Path to a Best Best-Fit Line: Studet Activity : Fidig the Least Squares Regressio Lie By Explorig the Relatioship betwee Slope ad Residuals Objective: How does oe determie a best best-fit lie for a set of data? Eyeballig it may be

More information

Section 4. Imaging and Paraxial Optics

Section 4. Imaging and Paraxial Optics 4-1 Sectio 4 Imagig ad Paraxial Optics Optical Sstems A optical sstem is a collectio of optical elemets (leses ad mirrors). While the optical sstem ca cotai multiple optical elemets, the first order properties

More information

COMP 558 lecture 6 Sept. 27, 2010

COMP 558 lecture 6 Sept. 27, 2010 Radiometry We have discussed how light travels i straight lies through space. We would like to be able to talk about how bright differet light rays are. Imagie a thi cylidrical tube ad cosider the amout

More information

IMP: Superposer Integrated Morphometrics Package Superposition Tool

IMP: Superposer Integrated Morphometrics Package Superposition Tool IMP: Superposer Itegrated Morphometrics Package Superpositio Tool Programmig by: David Lieber ( 03) Caisius College 200 Mai St. Buffalo, NY 4208 Cocept by: H. David Sheets, Dept. of Physics, Caisius College

More information

EVALUATION OF TRIGONOMETRIC FUNCTIONS

EVALUATION OF TRIGONOMETRIC FUNCTIONS EVALUATION OF TRIGONOMETRIC FUNCTIONS Whe first exposed to trigoometric fuctios i high school studets are expected to memorize the values of the trigoometric fuctios of sie cosie taget for the special

More information

Assignment 5; Due Friday, February 10

Assignment 5; Due Friday, February 10 Assigmet 5; Due Friday, February 10 17.9b The set X is just two circles joied at a poit, ad the set X is a grid i the plae, without the iteriors of the small squares. The picture below shows that the iteriors

More information

Normals. In OpenGL the normal vector is part of the state Set by glnormal*()

Normals. In OpenGL the normal vector is part of the state Set by glnormal*() Ray Tracig 1 Normals OpeG the ormal vector is part of the state Set by glnormal*() -glnormal3f(x, y, z); -glnormal3fv(p); Usually we wat to set the ormal to have uit legth so cosie calculatios are correct

More information

Lenses and Imaging (Part I) Parabloid mirror: perfect focusing

Lenses and Imaging (Part I) Parabloid mirror: perfect focusing Leses ad Imagig (Part I) eview: paraboloid reflector, focusig Why is imagig ecessary: Huyges priciple Spherical & parallel ray budles, poits at ifiity efractio at spherical surfaces (paraial approimatio)

More information

CS Polygon Scan Conversion. Slide 1

CS Polygon Scan Conversion. Slide 1 CS 112 - Polygo Sca Coversio Slide 1 Polygo Classificatio Covex All iterior agles are less tha 180 degrees Cocave Iterior agles ca be greater tha 180 degrees Degeerate polygos If all vertices are colliear

More information

Transform into 3D world coordinate system. Illuminate according to lighting and reflectance. Transform into 3D camera coordinate system

Transform into 3D world coordinate system. Illuminate according to lighting and reflectance. Transform into 3D camera coordinate system Projetios Trasformatios! 3D Geometri Primities Modelig Trasformatio Trasform ito 3D world oordiate sstem Lightig Illumiate aordig to lightig ad refletae Viewig Trasformatio Trasform ito 3D amera oordiate

More information

Light and shading. Source: A. Efros

Light and shading. Source: A. Efros Light ad shadig Source: A. Efros Image formatio What determies the brightess of a image piel? Sesor characteristics Light source properties Eposure Surface shape ad orietatio Optics Surface reflectace

More information

Derivation of perspective stereo projection matrices with depth, shape and magnification consideration

Derivation of perspective stereo projection matrices with depth, shape and magnification consideration Derivatio of perspective stereo projectio matrices with depth, shape ad magificatio cosideratio Patrick Oberthür Jauary 2014 This essay will show how to costruct a pair of stereoscopic perspective projectio

More information

Counting Regions in the Plane and More 1

Counting Regions in the Plane and More 1 Coutig Regios i the Plae ad More 1 by Zvezdelia Stakova Berkeley Math Circle Itermediate I Group September 016 1. Overarchig Problem Problem 1 Regios i a Circle. The vertices of a polygos are arraged o

More information

Intro to Scientific Computing: Solutions

Intro to Scientific Computing: Solutions Itro to Scietific Computig: Solutios Dr. David M. Goulet. How may steps does it take to separate 3 objects ito groups of 4? We start with 5 objects ad apply 3 steps of the algorithm to reduce the pile

More information

Rendering. Ray Tracing

Rendering. Ray Tracing CS475m - Compter Graphics Lectre 16 : 1 Rederig Drawig images o the compter scree. We hae see oe rederig method already. Isses: Visibility What parts of a scee are isible? Clippig Cllig (Backface ad Occlsio)

More information

OCR Statistics 1. Working with data. Section 3: Measures of spread

OCR Statistics 1. Working with data. Section 3: Measures of spread Notes ad Eamples OCR Statistics 1 Workig with data Sectio 3: Measures of spread Just as there are several differet measures of cetral tedec (averages), there are a variet of statistical measures of spread.

More information

Lenses and Imaging (Part I)

Lenses and Imaging (Part I) Leses ad Imagig (Part I) Why is imagig ecessary: Huyge s priciple Spherical & parallel ray budles, poits at ifiity efractio at spherical surfaces (paraial approimatio) Optical power ad imagig coditio Matri

More information

EECS 442 Computer vision. Multiple view geometry Affine structure from Motion

EECS 442 Computer vision. Multiple view geometry Affine structure from Motion EECS 442 Computer visio Multiple view geometry Affie structure from Motio - Affie structure from motio problem - Algebraic methods - Factorizatio methods Readig: [HZ] Chapters: 6,4,8 [FP] Chapter: 2 Some

More information

Section 7.2: Direction Fields and Euler s Methods

Section 7.2: Direction Fields and Euler s Methods Sectio 7.: Directio ields ad Euler s Methods Practice HW from Stewart Tetbook ot to had i p. 5 # -3 9-3 odd or a give differetial equatio we wat to look at was to fid its solutio. I this chapter we will

More information

A Very Simple Approach for 3-D to 2-D Mapping

A Very Simple Approach for 3-D to 2-D Mapping A Very Simple Approach for -D to -D appig Sadipa Dey (1 Ajith Abraham ( Sugata Sayal ( Sadipa Dey (1 Ashi Software Private Limited INFINITY Tower II 10 th Floor Plot No. - 4. Block GP Salt Lake Electroics

More information

1. Sketch a concave polygon and explain why it is both concave and a polygon. A polygon is a simple closed curve that is the union of line segments.

1. Sketch a concave polygon and explain why it is both concave and a polygon. A polygon is a simple closed curve that is the union of line segments. SOLUTIONS MATH / Fial Review Questios, F5. Sketch a cocave polygo ad explai why it is both cocave ad a polygo. A polygo is a simple closed curve that is the uio of lie segmets. A polygo is cocave if it

More information

Section 4. Imaging and Paraxial Optics

Section 4. Imaging and Paraxial Optics Sectio 4 Imagig ad Paraxial Optics 4- Optical Sstems A optical sstem is a collectio of optical elemets (leses ad mirrors). While the optical sstem ca cotai multiple optical elemets, the first order properties

More information

EECS 442 Computer vision. Multiple view geometry Affine structure from Motion

EECS 442 Computer vision. Multiple view geometry Affine structure from Motion EECS 442 Computer visio Multiple view geometry Affie structure from Motio - Affie structure from motio problem - Algebraic methods - Factorizatio methods Readig: [HZ] Chapters: 6,4,8 [FP] Chapter: 2 Some

More information

PLEASURE TEST SERIES (XI) - 04 By O.P. Gupta (For stuffs on Math, click at theopgupta.com)

PLEASURE TEST SERIES (XI) - 04 By O.P. Gupta (For stuffs on Math, click at theopgupta.com) wwwtheopguptacom wwwimathematiciacom For all the Math-Gya Buy books by OP Gupta A Compilatio By : OP Gupta (WhatsApp @ +9-9650 350 0) For more stuffs o Maths, please visit : wwwtheopguptacom Time Allowed

More information

Learning to Shoot a Goal Lecture 8: Learning Models and Skills

Learning to Shoot a Goal Lecture 8: Learning Models and Skills Learig to Shoot a Goal Lecture 8: Learig Models ad Skills How do we acquire skill at shootig goals? CS 344R/393R: Robotics Bejami Kuipers Learig to Shoot a Goal The robot eeds to shoot the ball i the goal.

More information

Lenses and imaging. MIT 2.71/ /10/01 wk2-a-1

Lenses and imaging. MIT 2.71/ /10/01 wk2-a-1 Leses ad imagig Huyges priciple ad why we eed imagig istrumets A simple imagig istrumet: the pihole camera Priciple of image formatio usig leses Quatifyig leses: paraial approimatio & matri approach Focusig

More information

SD vs. SD + One of the most important uses of sample statistics is to estimate the corresponding population parameters.

SD vs. SD + One of the most important uses of sample statistics is to estimate the corresponding population parameters. SD vs. SD + Oe of the most importat uses of sample statistics is to estimate the correspodig populatio parameters. The mea of a represetative sample is a good estimate of the mea of the populatio that

More information

Computers and Scientific Thinking

Computers and Scientific Thinking Computers ad Scietific Thikig David Reed, Creighto Uiversity Chapter 15 JavaScript Strigs 1 Strigs as Objects so far, your iteractive Web pages have maipulated strigs i simple ways use text box to iput

More information

Computational Geometry

Computational Geometry Computatioal Geometry Chapter 4 Liear programmig Duality Smallest eclosig disk O the Ageda Liear Programmig Slides courtesy of Craig Gotsma 4. 4. Liear Programmig - Example Defie: (amout amout cosumed

More information

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4

More information

Extended Space Mapping with Bézier Patches and Volumes

Extended Space Mapping with Bézier Patches and Volumes Eteded Space Mappig with Béier Patches ad Volumes Bejami Schmitt 1, 2 Aleader Pasko 1 Vladimir Savcheko 1 Abstract We eplore a geeral eteded space mappig as a framework for trasformig a hypersurface i

More information

Lighting and Shading. Outline. Raytracing Example. Global Illumination. Local Illumination. Radiosity Example

Lighting and Shading. Outline. Raytracing Example. Global Illumination. Local Illumination. Radiosity Example CSCI 480 Computer Graphics Lecture 9 Lightig ad Shadig Light Sources Phog Illumiatio Model Normal Vectors [Agel Ch. 6.1-6.4] February 13, 2013 Jerej Barbic Uiversity of Souther Califoria http://www-bcf.usc.edu/~jbarbic/cs480-s13/

More information

Mathematics and Art Activity - Basic Plane Tessellation with GeoGebra

Mathematics and Art Activity - Basic Plane Tessellation with GeoGebra 1 Mathematics ad Art Activity - Basic Plae Tessellatio with GeoGebra Worksheet: Explorig Regular Edge-Edge Tessellatios of the Cartesia Plae ad the Mathematics behid it. Goal: To eable Maths educators

More information

Math 10C Long Range Plans

Math 10C Long Range Plans Math 10C Log Rage Plas Uits: Evaluatio: Homework, projects ad assigmets 10% Uit Tests. 70% Fial Examiatio.. 20% Ay Uit Test may be rewritte for a higher mark. If the retest mark is higher, that mark will

More information

The Closest Line to a Data Set in the Plane. David Gurney Southeastern Louisiana University Hammond, Louisiana

The Closest Line to a Data Set in the Plane. David Gurney Southeastern Louisiana University Hammond, Louisiana The Closest Lie to a Data Set i the Plae David Gurey Southeaster Louisiaa Uiversity Hammod, Louisiaa ABSTRACT This paper looks at three differet measures of distace betwee a lie ad a data set i the plae:

More information

Chapter 18: Ray Optics Questions & Problems

Chapter 18: Ray Optics Questions & Problems Chapter 18: Ray Optics Questios & Problems c -1 2 1 1 1 h s θr= θi 1siθ 1 = 2si θ 2 = θ c = si ( ) + = m = = v s s f h s 1 Example 18.1 At high oo, the su is almost directly above (about 2.0 o from the

More information

EE123 Digital Signal Processing

EE123 Digital Signal Processing Last Time EE Digital Sigal Processig Lecture 7 Block Covolutio, Overlap ad Add, FFT Discrete Fourier Trasform Properties of the Liear covolutio through circular Today Liear covolutio with Overlap ad add

More information

The Nature of Light. Chapter 22. Geometric Optics Using a Ray Approximation. Ray Approximation

The Nature of Light. Chapter 22. Geometric Optics Using a Ray Approximation. Ray Approximation The Nature of Light Chapter Reflectio ad Refractio of Light Sectios: 5, 8 Problems: 6, 7, 4, 30, 34, 38 Particles of light are called photos Each photo has a particular eergy E = h ƒ h is Plack s costat

More information

Accuracy Improvement in Camera Calibration

Accuracy Improvement in Camera Calibration Accuracy Improvemet i Camera Calibratio FaJie L Qi Zag ad Reihard Klette CITR, Computer Sciece Departmet The Uiversity of Aucklad Tamaki Campus, Aucklad, New Zealad fli006, qza001@ec.aucklad.ac.z r.klette@aucklad.ac.z

More information

Texture Mapping. Jian Huang. This set of slides references the ones used at Ohio State for instruction.

Texture Mapping. Jian Huang. This set of slides references the ones used at Ohio State for instruction. Texture Mappig Jia Huag This set of slides refereces the oes used at Ohio State for istructio. Ca you do this What Dreams May Come Texture Mappig Of course, oe ca model the exact micro-geometry + material

More information

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3

More information

INCI 4022 STRUCTURAL ANALYSIS II

INCI 4022 STRUCTURAL ANALYSIS II INCI 0 STRUCTURAL ANALYSIS II PART I DEINITIONS Node: Itersectio of two or more members, supports, member eds Degrees of freedom (at a ode): Number of possible displacemets for a ode The umber of degrees

More information

Lecture 1: Introduction and Strassen s Algorithm

Lecture 1: Introduction and Strassen s Algorithm 5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access

More information

1.2 Binomial Coefficients and Subsets

1.2 Binomial Coefficients and Subsets 1.2. BINOMIAL COEFFICIENTS AND SUBSETS 13 1.2 Biomial Coefficiets ad Subsets 1.2-1 The loop below is part of a program to determie the umber of triagles formed by poits i the plae. for i =1 to for j =

More information

Numerical Methods Lecture 6 - Curve Fitting Techniques

Numerical Methods Lecture 6 - Curve Fitting Techniques Numerical Methods Lecture 6 - Curve Fittig Techiques Topics motivatio iterpolatio liear regressio higher order polyomial form expoetial form Curve fittig - motivatio For root fidig, we used a give fuctio

More information

South Slave Divisional Education Council. Math 10C

South Slave Divisional Education Council. Math 10C South Slave Divisioal Educatio Coucil Math 10C Curriculum Package February 2012 12 Strad: Measuremet Geeral Outcome: Develop spatial sese ad proportioal reasoig It is expected that studets will: 1. Solve

More information

APPLICATION NOTE PACE1750AE BUILT-IN FUNCTIONS

APPLICATION NOTE PACE1750AE BUILT-IN FUNCTIONS APPLICATION NOTE PACE175AE BUILT-IN UNCTIONS About This Note This applicatio brief is iteded to explai ad demostrate the use of the special fuctios that are built ito the PACE175AE processor. These powerful

More information

Eigenimages. Digital Image Processing: Bernd Girod, 2013 Stanford University -- Eigenimages 1

Eigenimages. Digital Image Processing: Bernd Girod, 2013 Stanford University -- Eigenimages 1 Eigeimages Uitary trasforms Karhue-Loève trasform ad eigeimages Sirovich ad Kirby method Eigefaces for geder recogitio Fisher liear discrimat aalysis Fisherimages ad varyig illumiatio Fisherfaces vs. eigefaces

More information

The number n of subintervals times the length h of subintervals gives length of interval (b-a).

The number n of subintervals times the length h of subintervals gives length of interval (b-a). Simulator with MadMath Kit: Riema Sums (Teacher s pages) I your kit: 1. GeoGebra file: Ready-to-use projector sized simulator: RiemaSumMM.ggb 2. RiemaSumMM.pdf (this file) ad RiemaSumMMEd.pdf (educator's

More information

Orientation. Orientation 10/28/15

Orientation. Orientation 10/28/15 Orietatio Orietatio We will defie orietatio to mea a object s istataeous rotatioal cofiguratio Thik of it as the rotatioal equivalet of positio 1 Represetig Positios Cartesia coordiates (x,y,z) are a easy

More information

Parametric curves. Reading. Parametric polynomial curves. Mathematical curve representation. Brian Curless CSE 457 Spring 2015

Parametric curves. Reading. Parametric polynomial curves. Mathematical curve representation. Brian Curless CSE 457 Spring 2015 Readig Required: Agel 0.-0.3, 0.5., 0.6-0.7, 0.9 Parametric curves Bria Curless CSE 457 Sprig 05 Optioal Bartels, Beatty, ad Barsy. A Itroductio to Splies for use i Computer Graphics ad Geometric Modelig,

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 6 Defiig Fuctios Pytho Programmig, 2/e 1 Objectives To uderstad why programmers divide programs up ito sets of cooperatig fuctios. To be able to

More information

Bezier curves. Figure 2 shows cubic Bezier curves for various control points. In a Bezier curve, only

Bezier curves. Figure 2 shows cubic Bezier curves for various control points. In a Bezier curve, only Edited: Yeh-Liag Hsu (998--; recommeded: Yeh-Liag Hsu (--9; last updated: Yeh-Liag Hsu (9--7. Note: This is the course material for ME55 Geometric modelig ad computer graphics, Yua Ze Uiversity. art of

More information

Recursive Procedures. How can you model the relationship between consecutive terms of a sequence?

Recursive Procedures. How can you model the relationship between consecutive terms of a sequence? 6. Recursive Procedures I Sectio 6.1, you used fuctio otatio to write a explicit formula to determie the value of ay term i a Sometimes it is easier to calculate oe term i a sequece usig the previous terms.

More information

Ones Assignment Method for Solving Traveling Salesman Problem

Ones Assignment Method for Solving Traveling Salesman Problem Joural of mathematics ad computer sciece 0 (0), 58-65 Oes Assigmet Method for Solvig Travelig Salesma Problem Hadi Basirzadeh Departmet of Mathematics, Shahid Chamra Uiversity, Ahvaz, Ira Article history:

More information

Convex hull ( 凸殻 ) property

Convex hull ( 凸殻 ) property Covex hull ( 凸殻 ) property The covex hull of a set of poits S i dimesios is the itersectio of all covex sets cotaiig S. For N poits P,..., P N, the covex hull C is the give by the expressio The covex hull

More information

Eigenimages. Digital Image Processing: Bernd Girod, Stanford University -- Eigenimages 1

Eigenimages. Digital Image Processing: Bernd Girod, Stanford University -- Eigenimages 1 Eigeimages Uitary trasforms Karhue-Loève trasform ad eigeimages Sirovich ad Kirby method Eigefaces for geder recogitio Fisher liear discrimat aalysis Fisherimages ad varyig illumiatio Fisherfaces vs. eigefaces

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists

More information

Image Segmentation EEE 508

Image Segmentation EEE 508 Image Segmetatio Objective: to determie (etract) object boudaries. It is a process of partitioig a image ito distict regios by groupig together eighborig piels based o some predefied similarity criterio.

More information

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence _9.qxd // : AM Page Chapter 9 Sequeces, Series, ad Probability 9. Sequeces ad Series What you should lear Use sequece otatio to write the terms of sequeces. Use factorial otatio. Use summatio otatio to

More information

condition w i B i S maximum u i

condition w i B i S maximum u i ecture 10 Dyamic Programmig 10.1 Kapsack Problem November 1, 2004 ecturer: Kamal Jai Notes: Tobias Holgers We are give a set of items U = {a 1, a 2,..., a }. Each item has a weight w i Z + ad a utility

More information

Graphics (Output) Primitives. Chapters 3 & 4

Graphics (Output) Primitives. Chapters 3 & 4 Graphics (Output) Primitives Chapters 3 & 4 Graphic Output ad Iput Pipelie Sca coversio coverts primitives such as lies, circles, etc. ito pixel values geometric descriptio Þ a fiite scee area Clippig

More information

A Taste of Maya. Character Setup

A Taste of Maya. Character Setup This tutorial goes through the steps to add aimatio cotrols to a previously modeled character. The character i the scee below is wearig clothes made with Cloth ad the sceery has bee created with Pait Effects.

More information

Module 8-7: Pascal s Triangle and the Binomial Theorem

Module 8-7: Pascal s Triangle and the Binomial Theorem Module 8-7: Pascal s Triagle ad the Biomial Theorem Gregory V. Bard April 5, 017 A Note about Notatio Just to recall, all of the followig mea the same thig: ( 7 7C 4 C4 7 7C4 5 4 ad they are (all proouced

More information

Descriptive Statistics Summary Lists

Descriptive Statistics Summary Lists Chapter 209 Descriptive Statistics Summary Lists Itroductio This procedure is used to summarize cotiuous data. Large volumes of such data may be easily summarized i statistical lists of meas, couts, stadard

More information

INSCRIBED CIRCLE OF GENERAL SEMI-REGULAR POLYGON AND SOME OF ITS FEATURES

INSCRIBED CIRCLE OF GENERAL SEMI-REGULAR POLYGON AND SOME OF ITS FEATURES INTERNATIONAL JOURNAL OF GEOMETRY Vol. 2 (2013), No. 1, 5-22 INSCRIBED CIRCLE OF GENERAL SEMI-REGULAR POLYGON AND SOME OF ITS FEATURES NENAD U. STOJANOVIĆ Abstract. If above each side of a regular polygo

More information

Factor. 8th Grade Math. 2D Geometry: Transformations. 3 Examples/ Counterexamples. Vocab Word. Slide 3 / 227. Slide 4 / 227.

Factor. 8th Grade Math. 2D Geometry: Transformations. 3 Examples/ Counterexamples. Vocab Word. Slide 3 / 227. Slide 4 / 227. Slide / Slide / th Grade Math Geoetry: Trasforatios 0-0- www.jctl.org Slide / Slide / Table of otets Lis to PR saple questios No-alculator # No- alculator # lic o a topic to go to that sectio Trasforatios

More information

27 Refraction, Dispersion, Internal Reflection

27 Refraction, Dispersion, Internal Reflection Chapter 7 Refractio, Dispersio, Iteral Reflectio 7 Refractio, Dispersio, Iteral Reflectio Whe we talked about thi film iterferece, we said that whe light ecouters a smooth iterface betwee two trasparet

More information

Octahedral Graph Scaling

Octahedral Graph Scaling Octahedral Graph Scalig Peter Russell Jauary 1, 2015 Abstract There is presetly o strog iterpretatio for the otio of -vertex graph scalig. This paper presets a ew defiitio for the term i the cotext of

More information

Overview Chapter 12 A display model

Overview Chapter 12 A display model Overview Chapter 12 A display model Why graphics? A graphics model Examples Bjare Stroustrup www.stroustrup.com/programmig 3 Why bother with graphics ad GUI? Why bother with graphics ad GUI? It s very

More information

Lecturers: Sanjam Garg and Prasad Raghavendra Feb 21, Midterm 1 Solutions

Lecturers: Sanjam Garg and Prasad Raghavendra Feb 21, Midterm 1 Solutions U.C. Berkeley CS170 : Algorithms Midterm 1 Solutios Lecturers: Sajam Garg ad Prasad Raghavedra Feb 1, 017 Midterm 1 Solutios 1. (4 poits) For the directed graph below, fid all the strogly coected compoets

More information

FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD)

FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) FINIT DIFFRNC TIM DOMAIN MTOD (FDTD) The FDTD method, proposed b Yee, 1966, is aother umerical method, used widel for the solutio of M problems. It is used to solve ope-regio scatterig, radiatio, diffusio,

More information

. Written in factored form it is easy to see that the roots are 2, 2, i,

. Written in factored form it is easy to see that the roots are 2, 2, i, CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or

More information

9 x and g(x) = 4. x. Find (x) 3.6. I. Combining Functions. A. From Equations. Example: Let f(x) = and its domain. Example: Let f(x) = and g(x) = x x 4

9 x and g(x) = 4. x. Find (x) 3.6. I. Combining Functions. A. From Equations. Example: Let f(x) = and its domain. Example: Let f(x) = and g(x) = x x 4 1 3.6 I. Combiig Fuctios A. From Equatios Example: Let f(x) = 9 x ad g(x) = 4 f x. Fid (x) g ad its domai. 4 Example: Let f(x) = ad g(x) = x x 4. Fid (f-g)(x) B. From Graphs: Graphical Additio. Example:

More information

Consider the following population data for the state of California. Year Population

Consider the following population data for the state of California. Year Population Assigmets for Bradie Fall 2016 for Chapter 5 Assigmet sheet for Sectios 5.1, 5.3, 5.5, 5.6, 5.7, 5.8 Read Pages 341-349 Exercises for Sectio 5.1 Lagrage Iterpolatio #1, #4, #7, #13, #14 For #1 use MATLAB

More information

Performance Plus Software Parameter Definitions

Performance Plus Software Parameter Definitions Performace Plus+ Software Parameter Defiitios/ Performace Plus Software Parameter Defiitios Chapma Techical Note-TG-5 paramete.doc ev-0-03 Performace Plus+ Software Parameter Defiitios/2 Backgroud ad Defiitios

More information

A New Morphological 3D Shape Decomposition: Grayscale Interframe Interpolation Method

A New Morphological 3D Shape Decomposition: Grayscale Interframe Interpolation Method A ew Morphological 3D Shape Decompositio: Grayscale Iterframe Iterpolatio Method D.. Vizireau Politehica Uiversity Bucharest, Romaia ae@comm.pub.ro R. M. Udrea Politehica Uiversity Bucharest, Romaia mihea@comm.pub.ro

More information

Polynomial Functions and Models. Learning Objectives. Polynomials. P (x) = a n x n + a n 1 x n a 1 x + a 0, a n 0

Polynomial Functions and Models. Learning Objectives. Polynomials. P (x) = a n x n + a n 1 x n a 1 x + a 0, a n 0 Polyomial Fuctios ad Models 1 Learig Objectives 1. Idetify polyomial fuctios ad their degree 2. Graph polyomial fuctios usig trasformatios 3. Idetify the real zeros of a polyomial fuctio ad their multiplicity

More information

Using the Keyboard. Using the Wireless Keyboard. > Using the Keyboard

Using the Keyboard. Using the Wireless Keyboard. > Using the Keyboard 1 A wireless keyboard is supplied with your computer. The wireless keyboard uses a stadard key arragemet with additioal keys that perform specific fuctios. Usig the Wireless Keyboard Two AA alkalie batteries

More information

1. Introduction o Microscopic property responsible for MRI Show and discuss graphics that go from macro to H nucleus with N-S pole

1. Introduction o Microscopic property responsible for MRI Show and discuss graphics that go from macro to H nucleus with N-S pole Page 1 Very Quick Itroductio to MRI The poit of this itroductio is to give the studet a sufficietly accurate metal picture of MRI to help uderstad its impact o image registratio. The two major aspects

More information

. Perform a geometric (ray-optics) construction (i.e., draw in the rays on the diagram) to show where the final image is formed.

. Perform a geometric (ray-optics) construction (i.e., draw in the rays on the diagram) to show where the final image is formed. MASSACHUSETTS INSTITUTE of TECHNOLOGY Departmet of Electrical Egieerig ad Computer Sciece 6.161 Moder Optics Project Laboratory 6.637 Optical Sigals, Devices & Systems Problem Set No. 1 Geometric optics

More information

Computer Graphics Hardware An Overview

Computer Graphics Hardware An Overview Computer Graphics Hardware A Overview Graphics System Moitor Iput devices CPU/Memory GPU Raster Graphics System Raster: A array of picture elemets Based o raster-sca TV techology The scree (ad a picture)

More information

Our Learning Problem, Again

Our Learning Problem, Again Noparametric Desity Estimatio Matthew Stoe CS 520, Sprig 2000 Lecture 6 Our Learig Problem, Agai Use traiig data to estimate ukow probabilities ad probability desity fuctios So far, we have depeded o describig

More information

Fundamentals of Media Processing. Shin'ichi Satoh Kazuya Kodama Hiroshi Mo Duy-Dinh Le

Fundamentals of Media Processing. Shin'ichi Satoh Kazuya Kodama Hiroshi Mo Duy-Dinh Le Fudametals of Media Processig Shi'ichi Satoh Kazuya Kodama Hiroshi Mo Duy-Dih Le Today's topics Noparametric Methods Parze Widow k-nearest Neighbor Estimatio Clusterig Techiques k-meas Agglomerative Hierarchical

More information

Elementary Educational Computer

Elementary Educational Computer Chapter 5 Elemetary Educatioal Computer. Geeral structure of the Elemetary Educatioal Computer (EEC) The EEC coforms to the 5 uits structure defied by vo Neuma's model (.) All uits are preseted i a simplified

More information

Lecture 18. Optimization in n dimensions

Lecture 18. Optimization in n dimensions Lecture 8 Optimizatio i dimesios Itroductio We ow cosider the problem of miimizig a sigle scalar fuctio of variables, f x, where x=[ x, x,, x ]T. The D case ca be visualized as fidig the lowest poit of

More information

Name Date Hr. ALGEBRA 1-2 SPRING FINAL MULTIPLE CHOICE REVIEW #1

Name Date Hr. ALGEBRA 1-2 SPRING FINAL MULTIPLE CHOICE REVIEW #1 Name Date Hr. ALGEBRA - SPRING FINAL MULTIPLE CHOICE REVIEW #. The high temperatures for Phoeix i October of 009 are listed below. Which measure of ceter will provide the most accurate estimatio of the

More information

The Magma Database file formats

The Magma Database file formats The Magma Database file formats Adrew Gaylard, Bret Pikey, ad Mart-Mari Breedt Johaesburg, South Africa 15th May 2006 1 Summary Magma is a ope-source object database created by Chris Muller, of Kasas City,

More information

CS 111: Program Design I Lecture # 7: First Loop, Web Crawler, Functions

CS 111: Program Design I Lecture # 7: First Loop, Web Crawler, Functions CS 111: Program Desig I Lecture # 7: First Loop, Web Crawler, Fuctios Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago September 18, 2018 What will this prit? x = 5 if x == 3: prit("hi!")

More information

Visualization of Gauss-Bonnet Theorem

Visualization of Gauss-Bonnet Theorem Visualizatio of Gauss-Boet Theorem Yoichi Maeda maeda@keyaki.cc.u-tokai.ac.jp Departmet of Mathematics Tokai Uiversity Japa Abstract: The sum of exteral agles of a polygo is always costat, π. There are

More information

Two View Geometry Part 2 Fundamental Matrix Computation

Two View Geometry Part 2 Fundamental Matrix Computation 3D Computer Visio II Two View Geometr Part Fudametal Matri Computatio Nassir Navab based o a course give at UNC b Marc Pollefes & the book Multiple View Geometr b Hartle & Zisserma November 9, 009 Outlie

More information

CSI 3140 WWW Structures, Techniques and Standards. Cascading Style Sheets (CSS)

CSI 3140 WWW Structures, Techniques and Standards. Cascading Style Sheets (CSS) CSI 3140 WWW Structures, Techiques ad Stadards Cascadig Style Sheets (CSS) Motivatio whtml markup ca be used to represet Sematics: h1 meas that a elemet is a top-level headig Presetatio: h1 elemets look

More information

Math 3201 Notes Chapter 4: Rational Expressions & Equations

Math 3201 Notes Chapter 4: Rational Expressions & Equations Learig Goals: See p. tet.. Equivalet Ratioal Epressios ( classes) Read Goal p. 6 tet. Math 0 Notes Chapter : Ratioal Epressios & Equatios. Defie ad give a eample of a ratioal epressio. p. 6. Defie o-permissible

More information