สภาพแวดล้อมการทำงานคอมพิวเตอร์กราฟิกส์ การบรรยายครั้งที่ 7

Slides:



Advertisements
Similar presentations
SI23 Introduction to Computer Graphics
Advertisements

Curves Jim Van Verth Essential Math for Games Animation Problem: want to replay stored set of transformations  Generated by.
CS 445 / 645 Introduction to Computer Graphics Lecture 23 Bézier Curves Lecture 23 Bézier Curves.
CS 445 / 645 Introduction to Computer Graphics Lecture 22 Hermite Splines Lecture 22 Hermite Splines.
COMPUTER GRAPHICS CS 482 – FALL 2014 OCTOBER 8, 2014 SPLINES CUBIC CURVES HERMITE CURVES BÉZIER CURVES B-SPLINES BICUBIC SURFACES SUBDIVISION SURFACES.
March 1, 2009Dr. Muhammed Al-Mulhem1 ICS 415 Computer Graphics Hermite Splines Dr. Muhammed Al-Mulhem March 1, 2009 Dr. Muhammed Al-Mulhem March 1, 2009.
Lecture 10 Curves and Surfaces I
CS 445/645 Fall 2001 Hermite and Bézier Splines. Specifying Curves Control Points –A set of points that influence the curve’s shape Knots –Control points.
CS 445 / 645 Introduction to Computer Graphics Lecture 22 Hermite Splines Lecture 22 Hermite Splines.
1 Introduction Curve Modelling Jack van Wijk TU Eindhoven.
1 Chapter 4 Interpolation and Approximation Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
Dr. S.M. Malaek Assistant: M. Younesi
08/30/00 Dinesh Manocha, COMP258 Hermite Curves A mathematical representation as a link between the algebraic & geometric form Defined by specifying the.
Splines II – Interpolating Curves
1Notes  Assignment 0 is due today!  To get better feel for splines, play with formulas in MATLAB!
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
09/04/02 Dinesh Manocha, COMP258 Bezier Curves Interpolating curve Polynomial or rational parametrization using Bernstein basis functions Use of control.
1cs426-winter-2008 Notes  Ian Mitchell is running a MATLAB tutorial, Tuesday January 15, 5pm-7pm, DMP 110 We won’t be directly using MATLAB in this course,
Modeling of curves Needs a ways of representing curves: Reproducible - the representation should give the same curve every time; Computationally Quick;
Modelling: Curves Week 11, Wed Mar 23
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 24 Regression Analysis-Chapter 17.
RASTER CONVERSION ALGORITHMS FOR CURVES: 2D SPLINES 2D Splines - Bézier curves - Spline curves.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Curves Week 13, Mon 24 Nov 2003.
Bezier and Spline Curves and Surfaces CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Curve Surfaces June 4, Examples of Curve Surfaces Spheres The body of a car Almost everything in nature.
Bresenham’s Algorithm. Line Drawing Reference: Edward Angel’s book: –6 th Ed. Sections 6.8 and 6.9 Assuming: –Clipped (to fall within the window) –2D.
11/19/02 (c) 2002, University of Wisconsin, CS 559 Last Time Many, many modeling techniques –Polygon meshes –Parametric instancing –Hierarchical modeling.
CS 376 Introduction to Computer Graphics 04 / 23 / 2007 Instructor: Michael Eckmann.
Interactive Graphics Lecture 9: Slide 1 Interactive Graphics Lecture 9: Introduction to Spline Curves.
Review of Interpolation. A method of constructing a function that crosses through a discrete set of known data points.
Quadratic Surfaces. SPLINE REPRESENTATIONS a spline is a flexible strip used to produce a smooth curve through a designated set of points. We.
Chapter VI Parametric Curves and Surfaces
INTERPOLATION & APPROXIMATION. Curve algorithm General curve shape may be generated using method of –Interpolation (also known as curve fitting) Curve.
June D Object Representation Shmuel Wimer Bar Ilan Univ., School of Engineering.
CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5.
Splines IV – B-spline Curves based on: Michael Gleicher: Curves, chapter 15 in Fundamentals of Computer Graphics, 3 rd ed. (Shirley & Marschner) Slides.
CS 551/645 Fall 2000 Parameterized Rotations, Curves, and Surfaces.
CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008.
2011 COURSE IN NEUROINFORMATICS MARINE BIOLOGICAL LABORATORY WOODS HOLE, MA Introduction to Spline Models or Advanced Connect-the-Dots Uri Eden BU Department.
Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W Th , F
CS 376 Introduction to Computer Graphics 04 / 25 / 2007 Instructor: Michael Eckmann.
CS 445 / 645 Introduction to Computer Graphics Lecture 23 Bézier Curves Lecture 23 Bézier Curves.
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
Spline Interpolation A Primer on the Basics by Don Allen.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring.
1 Graphics CSCI 343, Fall 2015 Lecture 34 Curves and Surfaces III.
CS 325 Computer Graphics 04 / 30 / 2010 Instructor: Michael Eckmann.
Dan, Phoenix, Carl.  Several ways you can model  Polynomial functions, linear functions, splines.
Curves University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
CS552: Computer Graphics Lecture 19: Bezier Curves.
CS552: Computer Graphics Lecture 18: Representing Cubic Splines.
Object Modeling: Curves and Surfaces CEng 477 Introduction to Computer Graphics.
Slide 1Lecture Fall ‘00 Surface Modeling Types: Polygon surfaces Curved surfaces Volumes Generating models: Interactive Procedural.
Introduction to Parametric Curve and Surface Modeling.
CSCI480/582 Lecture 9 Chap.2.2 Cubic Splines – Hermit and Bezier Feb, 11, 2009.
COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 SPLINES
CS5500 Computer Graphics May 11, 2006
CS 445 / 645 Introduction to Computer Graphics
Chapter 10-2: Curves.
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves
© University of Wisconsin, CS559 Spring 2004
Chapter XVII Parametric Curves and Surfaces
Spline Interpolation Class XVII.
Parametric Line equations
UNIT-5 Curves and Surfaces.
Introduction to Parametric Curve and Surface Modeling
Type to enter a caption. Computer Graphics Week 10 Lecture 1.
Spline representation. ❖ A spline is a flexible strip used to produce a smooth curve through a designated set of points. ❖ Mathematically describe such.
Type to enter a caption. Computer Graphics Week 10 Lecture 2.
Presentation transcript:

418382 สภาพแวดล้อมการทำงานคอมพิวเตอร์กราฟิกส์ การบรรยายครั้งที่ 7 pramook@gmail.com

CS 445 / 645 Introduction to Computer Graphics Lecture 22 Hermite Splines

Splines – Old School Duck Spline

Representations of Curves Use a sequence of points… Piecewise linear - does not accurately model a smooth line Tedious to create list of points Expensive to manipulate curve because all points must be repositioned Instead, model curve as piecewise-polynomial x = x(t), y = y(t), z = z(t) where x(), y(), z() are polynomials

Specifying Curves (hyperlink) Control Points A set of points that influence the curve’s shape Knots Control points that lie on the curve Interpolating Splines Curves that pass through the control points (knots) Approximating Splines Control points merely influence shape

Parametric Curves Very flexible representation They are not required to be functions They can be multivalued with respect to any dimension

Cubic Polynomials x(t) = axt3 + bxt2 + cxt + dx Similarly for y(t) and z(t) Let t: (0 <= t <= 1) Let T = [t3 t2 t 1] Coefficient Matrix C Curve: Q(t) = T*C

Piecewise Curve Segments One curve constructed by connecting many smaller segments end-to-end Must have rules for how the segments are joined Continuity describes the joint Parametric continuity Geometric continuity

Parametric Continuity C1 is tangent continuity (velocity) C2 is 2nd derivative continuity (acceleration) Matching direction and magnitude of dn / dtn Cn continous

Geometric Continuity If positions match G0 geometric continuity If direction (but not necessarily magnitude) of tangent matches G1 geometric continuity The tangent value at the end of one curve is proportional to the tangent value of the beginning of the next curve

Parametric Cubic Curves In order to assure C2 continuity, curves must be of at least degree 3 Here is the parametric definition of a cubic (degree 3) spline in two dimensions How do we extend it to three dimensions?

Parametric Cubic Splines Can represent this as a matrix too

Coefficients So how do we select the coefficients? [ax bx cx dx] and [ay by cy dy] must satisfy the constraints defined by the knots and the continuity conditions

Parametric Curves Difficult to conceptualize curve as x(t) = axt3 + bxt2 + cxt + dx (artists don’t think in terms of coefficients of cubics) Instead, define curve as weighted combination of 4 well- defined cubic polynomials (wait a second! Artists don’t think this way either!) Each curve type defines different cubic polynomials and weighting schemes

Parametric Curves Hermite – two endpoints and two endpoint tangent vectors Bezier - two endpoints and two other points that define the endpoint tangent vectors Splines – four control points C1 and C2 continuity at the join points Come close to their control points, but not guaranteed to touch them Examples of Splines

Hermite Cubic Splines An example of knot and continuity constraints

Hermite Cubic Splines One cubic curve for each dimension A curve constrained to x/y-plane has two curves:

Hermite Cubic Splines A 2-D Hermite Cubic Spline is defined by eight parameters: a, b, c, d, e, f, g, h How do we convert the intuitive endpoint constraints into these (relatively) unintuitive eight parameters? We know: (x, y) position at t = 0, p1 (x, y) position at t = 1, p2 (x, y) derivative at t = 0, dp/dt (x, y) derivative at t = 1, dp/dt

Hermite Cubic Spline We know: (x, y) position at t = 0, p1

Hermite Cubic Spline We know: (x, y) position at t = 1, p2

Hermite Cubic Splines So far we have four equations, but we have eight unknowns Use the derivatives

Hermite Cubic Spline We know: (x, y) derivative at t = 0, dp/dt

Hermite Cubic Spline We know: (x, y) derivative at t = 1, dp/dt

Hermite Specification Matrix equation for Hermite Curve t3 t2 t1 t0 t = 0 p1 t = 1 p2 t = 0 r p1 r p2 t = 1

Solve Hermite Matrix

Spline and Geometry Matrices MHermite GHermite

Resulting Hermite Spline Equation

Sample Hermite Curves

Blending Functions By multiplying first two matrices in lower-left equation, you have four functions of ‘t’ that blend the four control parameters These are blending functions

Hermite Blending Functions If you plot the blending functions on the parameter ‘t’

Hermite Blending Functions Remember, each blending function reflects influence of P1, P2, DP1, DP2 on spline’s shape

CS 445 / 645 Introduction to Computer Graphics Lecture 23 Bézier Curves

Splines - History Draftsman use ‘ducks’ and strips of wood (splines) to draw curves Wood splines have second- order continuity And pass through the control points A Duck (weight) Ducks trace out curve

Bézier Curves Similar to Hermite, but more intuitive definition of endpoint derivatives Four control points, two of which are knots

Bézier Curves The derivative values of the Bezier Curve at the knots are dependent on the adjacent points The scalar 3 was selected just for this curve

Bézier vs. Hermite We can write our Bezier in terms of Hermite Note this is just matrix form of previous equations

Bézier vs. Hermite Now substitute this in for previous Hermite MBezier

Bézier Basis and Geometry Matrices Matrix Form But why is MBezier a good basis matrix?

Bézier Blending Functions Look at the blending functions This family of polynomials is called order-3 Bernstein Polynomials C(3, k) tk (1-t)3-k; 0<= k <= 3 They are all positive in interval [0,1] Their sum is equal to 1

Bézier Blending Functions Thus, every point on curve is linear combination of the control points The weights of the combination are all positive The sum of the weights is 1 Therefore, the curve is a convex combination of the control points

Convex combination of control points Will always remain within bounding region (convex hull) defined by control points

Why more spline slides? Bezier and Hermite splines have global influence One could create a Bezier curve that required 15 points to define the curve… Moving any one control point would affect the entire curve Piecewise Bezier or Hermite don’t suffer from this, but they don’t enforce derivative continuity at join points B-splines consist of curve segments whose polynomial coefficients depend on just a few control points Local control Examples of Splines

B-Spline Curve (cubic periodic) Start with a sequence of control points Select four from middle of sequence (pi-2, pi-1, pi, pi+1) d Bezier and Hermite goes between pi-2 and pi+1 B-Spline doesn’t interpolate (touch) any of them but approximates going through pi-1 and pi p2 p 6 p1 Q4 t4 Q5 t5 Q3 t6 Q6 p3 t3 t7 p0 p 4 p 5

Uniform B-Splines Approximating Splines Approximates n+1 control points P0, P1, …, Pn, n ¸ 3 Curve consists of n –2 cubic polynomial segments Q3, Q4, … Qn t varies along B-spline as Qi: ti <= t < ti+1 ti (i = integer) are knot points that join segment Qi to Qi+1 Curve is uniform because knots are spaced at equal intervals of parameter, t

Uniform B-Splines First curve segment, Q3, is defined by first four control points Last curve segment, Qm, is defined by last four control points, Pm-3, Pm-2, Pm-1, Pm Each control point affects four curve segments

B-spline Basis Matrix Formulate 16 equations to solve the 16 unknowns The 16 equations enforce the C0, C1, and C2 continuity between adjoining segments, Q

B-Spline Points along B-Spline are computed just as with Bezier Curves

B-Spline By far the most popular spline used C0, C1, and C2 continuous

Nonuniform, Rational B-Splines (NURBS) The native geometry element in Maya Models are composed of surfaces defined by NURBS, not polygons NURBS are smooth NURBS require effort to make non-smooth

Converting Between Splines Consider two spline basis formulations for two spline types

Converting Between Splines We can transform the control points from one spline basis to another

Converting Between Splines With this conversion, we can convert a B-Spline into a Bezier Spline Bezier Splines are easy to render

Rendering Splines Horner’s Method Incremental (Forward Difference) Method Subdivision Methods

Horner’s Method Three multiplications Three additions

Forward Difference But this still is expensive to compute Solve for change at k (Dk) and change at k+1 (Dk+1) Boot strap with initial values for x0, D0, and D1 Compute x3 by adding x0 + D0 + D1

Subdivision Methods Bezier

Rendering Bezier Spline public void spline(ControlPoint p0, ControlPoint p1, ControlPoint p2, ControlPoint p3, int pix) { float len = ControlPoint.dist(p0,p1) + ControlPoint.dist(p1,p2) + ControlPoint.dist(p2,p3); float chord = ControlPoint.dist(p0,p3); if (Math.abs(len - chord) < 0.25f) return; fatPixel(pix, p0.x, p0.y); ControlPoint p11 = ControlPoint.midpoint(p0, p1); ControlPoint tmp = ControlPoint.midpoint(p1, p2); ControlPoint p12 = ControlPoint.midpoint(p11, tmp); ControlPoint p22 = ControlPoint.midpoint(p2, p3); ControlPoint p21 = ControlPoint.midpoint(p22, tmp); ControlPoint p20 = ControlPoint.midpoint(p12, p21); spline(p20, p12, p11, p0, pix); spline(p3, p22, p21, p20, pix); }

ควอเทอเนียน ควอเทอเนียนที่แทนการหมุนเป็นมุม  รอบแกน (x,y,z) คือ

ตัวอย่าง จงหาควอเทอเนียนที่แทนการหมุนเป็นมุม 60 องศารอบแกน (1,1,1) เวกเตอร์หนึ่งหน่วยของแกนคือ คำนวณค่า cos และ sin และจะได้ว่าควอเทอเนียนคือ

ตัวอย่าง ควอเทอเนียนต่อไปนี้แทนการหมุนกี่องศา รอบแกนอะไร? เราได้ว่า ฉะนั้น แกนที่หมุนรอบคือ

การคูณควอเทอเนียน หลีกเลี่ยงการคูณควอเทอเนียนตรงๆ เพราะการคำนวณยุ่งยากและมีสิทธิ์ผิดมาก ใช้ความเข้าใจความหมายของควอเทอเนียนทำการคำนวณดีกว่า

ตัวอย่าง ให้ จงคำนวณ

ตัวอย่าง q1 คือการหมุนเป็นมุม 90 องศา รอบแกน (3/5, 0, 4/5) ฉะนั้น q1q2 คือการหมุนเป็นมุม 60 องศาแล้วจึงหมุน 90 องศา รวมแล้วเป็นการหมุน 150 องศารอบแกน (3/5, 0, 4/5) ฉะนั้น

Slerp อย่าคำนวณ slerp โดยตรงเช่นกัน สมมติว่าเราจะคำนวณ slerp(q0,q1,) โดยให้ค่า  มีค่าเพิ่มขึ้นเรื่อยๆ จาก 0 ถึง 1 ถ้าเรา plot quaternion ค่าต่างๆ ที่เกิดขึ้น เราจะได้ว่ามันเรียงตัวกันเป็นเส้น geodesic ซึ่งคือเส้นบนทรงกลม 4 มิติที่สั้นที่สุดที่ผ่าน q0 และ q1 ค่า  เป็นตัวบอกตำแหน่งบนเส้น geodesic นี้ กล่าวคือ ถ้า  = 0 จะอยู่ที่ q0 ถ้า  = 1 จะอยู่ที่ q1 ถ้า  = 0.5 จะอยู่ตรงกลางระหว่าง q0 กับ q1 พอดี ฯลฯ

Slerp

ตัวอย่าง ให้ จงคำนวณ

ตัวอย่าง สังเกตว่า x component และ z component เป็น 0 ดังนั้นที่ผลลัพธ์ x และ z ก็จะต้องมีค่าเป็น 0 ด้วย เนื่องจากเส้น geodesic จะไม่ผ่านบริเวณที่ x และ z ไม่เป็น 0 (ถ้าผ่านมันจะไม่สั้นสุด) ดังนั้นเราสามารถคิดว่าเส้น geodesic เป็นเส้นรอบวงของวงกลมใน 2 มิติ โดยที่แกนของระนาบสองมิตินั้นคือแกน w และแกน y

ตัวอย่าง มุมระหว่าง q0 และ q1 คือ 90 องศา slerp(q0,q1,1/3) คือตำแหน่งที่ทำมุมกับ q0 เป็น 1/3 เท่าของมุม 90 องศา กล่าวคือทำมุม 30 องศากับ q0 ฉะนั้น slerp(q0,q1,1/3) จึงมีพิกัด (w,y) เท่ากับ กล่าวคือ

ตัวอย่าง y q1 2/3 slerp(q0,q1,1/3) 1/3 w q0