#7: Cubic CurvesCSE167: Computer GraphicsInstructor: Ronen BarzelUCSD, Winter 20061Outline for todayInverses of Transforms Curves overview Bézier curves2Graphics pipeline transformations Remember the series of transforms in the graphics pipe: M - model: places object in world space C - camera: places camera in world space P - projection: from camera space to normalized view space D - viewport: remaps to image coordinates And remember about C: handy for positioning the camera as a modelbackwards for the pipeline:• we need to get from world space to camera space So we need to use C-1 You’ll need it for project 4: OpenGL wants you to load C-1 as thebase of the MODELVIEW stack3How do we get C-1? Could construct C, and use a matrix-inverse routine Would work. But relatively slow. And we didn’t give you one :) Instead, let’s construct C-1 directly based on how we constructed C based on shortcuts and rules for affine transforms4Inverse of a translation Translate back, i.e., negate the translation vector Easy to verify: T (!v) =1 0 0 vx0 1 0 vy0 0 1 vz0 0 0 1!"####$%&&&&!!!!!!!!!!!!!!!!!T'1(!v) = T ('!v) =1 0 0 'vx0 1 0 'vy0 0 1 'vz0 0 0 1!"####$%&&&& T(!!v)!T(!v) =1 0 0 !vx0 1 0 !vy0 0 1 !vz0 0 0 1"#$$$$%&''''1 0 0 vx0 1 0 vy0 0 1 vz0 0 0 1"#$$$$%&''''=1 0 0 vx! vx0 1 0 vy! vy0 0 1 vz! vz0 0 0 1"#$$$$%&''''=1 0 0 00 1 0 00 0 1 00 0 0 1"#$$$$%&''''= I5Inverse of a scale Scale by the inverses Easy to verify:S(sx, sy, sz) =sx0 0 00 sy0 00 0 sz00 0 0 1!"####$%&&&&!!!!!!!!!!S'1(sx, sy, sz) = S(1sx,1sy,1sz) =1 sx0 0 00 1 sy0 00 0 1 sz00 0 0 1!"####$%&&&&S(1sx,1sy,1sz)!S(sx, sy, sz)!=1 sx0 0 00 1 sy0 00 0 1 sz00 0 0 1!"####$%&&&&sx0 0 00 sy0 00 0 sz00 0 0 1!"####$%&&&&=sxsx0 0 00 sysy0 00 0 szsz00 0 0 1!"####$%&&&&=1 0 0 00 1 0 00 0 1 00 0 0 1!"####$%&&&&= I6Inverse of a rotation Rotate about the same axis, with the oppose angle: Inverse of a rotation is the transpose:• Columns of a rotation matrix are orthonormal• ATA produces all columns’ dot-product combinations as matrix• Dot product of a column with itself = 1 (on the diagonal)• Dot product of a column with any other column = 0 (off the diagonal) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!R!1(!a,") = R(!a,!")For example:Rz(") =cos(") !sin(") 0 0sin(") cos(") 0 00 0 1 00 0 0 1#$%%%%&'((((!!Rz!1(") = Rz(!") =cos(") !sin(!") 0 0sin(!") cos(") 0 00 0 1 00 0 0 1#$%%%%&'((((! =cos(") sin(") 0 0!sin(") cos(") 0 00 0 1 00 0 0 1#$%%%%&'((((= RzT(") R!1(!a,") = RT(!a,")7Inverses of composition If you have a series of transforms composed together M =!A!B!C!DTo invert, compose inverses in the reverse orderM!1= D!1!C!1!B!1!A!1Easy to verify:M!1!M = (D!1!C!1!B!1!A!1)(A!B!C!D)= D!1!C!1!B!1!A!1!AI!"#!B!C!D= D!1!C!1!B!1!BI$!C!D= D!1!C!1!CI$!D= D!1!D= I8Composing with inverses, pictorially To go from one space to another, compose along arrows Backwards along arrow: use inverse transformLamp in world coords = Mtable1!Mtop1!MlampPlant in Tabletop1 coords = Mtop1!1!Mtable1!1!Mtable2!Mtop2!Mplant9Model-to-Camera transformxyzCamera SpaceCamera-to-worldCModel-to-Camera = C-1M10The look-at transformation Remember, we constructed C using the look-at idiom: Given: eye point e, target point t, and up vector !uConstruct: columns of camera matrix Cd = e!c =e ! te ! t!a =!u "!c!u "!c!b =!c "!aImportant: !a,!b,!c!are orthonormal11C-1 from a,b,c,d columns • If we construct a transform using !a,!!b,!!c,!!d columns, it's the same as a composition.!!!!• First rotate/scale using !a,!!b,!!c, then translate by !d:!!!!!!!!!!!!!!!!C =axbxcxdxaybycydyazbzczdz0 0 0 1!"####$%&&&&=1 0 0 dx0 1 0 dy0 0 1 dz0 0 0 1!"####$%&&&&axbxcx0aybycy0azbzcz00 0 0 1!"####$%&&&&= T(!d)!M!!!!!• If !a,!!b,!!c are orthonormal, they define a pure rotation:!!!!!!!!!!!!!!!C = T(!d)!R• To take the inverse:!!!!!!!!!!!!!!!C'1= T(!d)!R( )'1= R'1!T'1(!d)!!!!!!!!!!!!!!!C'1= RT!T('!d)!!!!!!!!!!!!!!!C'1=axayaz0bxbybz0cxcycz00 0 0 1!"####$%&&&&1 0 0 'dx0 1 0 'dy0 0 1 'dz0 0 0 1!"####$%&&&&!!• Build RT using !a,!!b,!!c as rows, build T ('!d), compose them!!• Notice, this does the translation first, then the rotation. !!! Exercise:!what does the final matrix look like?12Outline for today Inverses of TransformsCurves overview Bézier curves13Usefulness of curves in modeling Surface of revolution14Usefulness of curves in modeling Extruded/swept surfaces15Usefulness of curves in modeling Surface patches16Usefulness of curves in animation Provide a “track” for objectshttp://www.f-lohmueller.de/17Usefulness of curves in animation Specify parameter values over time: 2D curve edtior18How to represent curves Specify every point along a curve? Used sometimes as “freehand drawing mode” in 2D applications Hard to get precise results Too much data, too hard to work with generally Specify a curve using a small number of “control points” Known as a spline curve or just spline19Interpolating Splines Specify points, the curve goes through all the points Seems most intuitive Surprisingly, not usually the best choice. Hard to predict behavior• Overshoots• Wiggles Hard to get “nice-looking” curves20Approximating Splines “Influenced” by control points but not necessarily go through them. Various types & techniques Most common: (Piecewise) Polynomial Functions Most common of those:• Bézier• B-spline Each has good properties We’ll focus on Bézier splines21What is a curve, anyway? We draw it, think of it as a thing existing in space But mathematically we treat it as a function, x(t) Given a value of t, computes a point x Can think of the function as moving a point along the curvexyzx(0.0)yx(0.5) x(1.0)x(t)22"The tangent to the curve Vector points in the direction of movement (Length is the speed in the direction of movement) Also a function of t,xyzx’(0.0)yx’(0.5) x’(1.0)x(t)written !x (t ) or ddtx(t ) or dxdt(t )23Polynomial Functions Linear:(1st order) Quadratic:(2nd order) Cubic:(3rd order)f t( )= at + bf t( )= at2+ bt + cf t( )= at3+ bt2+ ct + d24Point-valued Polynomials (Curves) Linear:(1st order) Quadratic:(2nd order) Cubic:(3rd order) Each is 3 polynomials “in parallel”: We usually define the curve for 0 ≤ t ≤ 1x t( )= at + bx t( )= at2+ bt + cx t( )= at3+ bt2+ ct + dxx(t) = axt + bx!!!!!!!!!! xy(t) = ayt + by!!!!!!!!!! xz(t) = azt +
View Full Document