curves - inf.ed.ac.uk
TRANSCRIPT
Curves
Hakan Bilen
University of Edinburgh
Computer Graphics
Fall 2017
Some slides are courtesy of Steve Marschner and Taku Komura
How to create a virtual world?
To compose scenes
We need to define objects
- Characters
- Terrains
- Objects (trees, furniture, buildings etc)
Geometric representations
β’ Meshes
β’ Triangle, quadrilateral,
polygon
β’ Implicit surfaces
β’ Blobs, metaballs
β’ Parametric surfaces / curves
β’ Polynomials
β’ Bezier curves, B-splines
Smoothness
Motivation
Many applications require smooth surfaces
Can produce smooth surfaces with less parameters
β’ Easier to design β’ Can efficiently preserve complex structures
[sce
ne
36
0.c
om
]
From draftsmanship to CG
β’ Control
β’ user specified control points
β’ analogy: ducks
β’ Smoothness
β’ smooth functions
β’ usually low order polynomials
β’ analogy: physical constraints, optimization
What is a curve?
A set of points that the pen traces over an interval of time
What is the dimensionality?
Implicit form: f x, y = π₯2 + π¦2 β 1 = 0
β’ Find the points that satisfy the equation
Parametric form: x, y = f t = πππ π‘, π πππ‘ , π‘ β [0,2π)
β’ Easier to draw
in this context
What is a spline curve?
π π‘ is a
β’ parametric curve
β’ piecewise polynomial function that switches between different
functions for different t intervals
Example:
π π‘ = ΰ΅π‘3, if 0 β€ π‘ < 1
1 β π‘ β 1 3, if 1 β€ π‘ < 20, otherwise
Defining spline curves
β’ Discontinuities at the integers [t=k]
β’ Each spline piece is defined over [k,k+1] (e.g. a cubic spline)
π π‘ = ππ‘3 + ππ‘2 + ππ‘ + π
β’ Different coefficients for every interval
β’ Control of spline curves
β’ Interpolate
β’ Approximate
Today
β’ Spline segments
β’ Linear
β’ Quadratic
β’ Hermite
β’ Bezier
β’ Chaining splines
β’ Notation
β’ vectors bold and lowercase π
β’ points as column vector π = ππ₯ ππ¦
β’ matrices bold and uppercase π΄
Linear Segment
Spline segments
A line segment connecting point ππ to ππ
Such that π 0 = ππ and π 1 = ππ
ππ₯ π‘ = 1 β π‘ ππ + π‘ππ
ππ¦ π‘ = 1 β π‘ ππ + π‘ππ
Vector formulation
π π‘ = 1 β π‘ ππ + π‘ππ
Matrix formulation
π π‘ = π‘ 1? ?? ?
ππππ
π π‘ = π‘ 1β1 11 0
ππππ
ππ
ππ
1 β π‘
π‘
1 β π‘ ππ + π‘ππ
Matrix form of spline
π π‘ = π‘ 1β1 11 0
ππππ
Blending functions π π‘ specify how to blend the values of the control point vector
π π‘ = ππ π‘ ππ + ππ π‘ ππ
ππ π‘ = 1 β π‘
ππ π‘ = π‘
ππ π‘ ππ π‘
Quadratic
Beyond line segment
A quadratic (π π‘ = π0 + π1π‘ + π2π‘2) passes through ππ, ππ, ππ s.t.
ππ = π 0 = π0 + 0 π1 + 02 π2
ππ = π 0.5 = π0 + 0.5 π1+0.52 π2
ππ = π 1 = π0 + 1 π1 + 12 π2
Points can be written in terms of constraint matrix πͺ
ππππππ
= πͺπ β
ππππππ
=1 0 01 0.5 0.251 1 1
π0π1π2
β
π0π1π2
= πͺβπππππππ
π π‘ can be written in terms of basis matrix π© = πͺβπ and points π
π π‘ = ππ©π = ππͺβ1π = π‘2 π‘ 12 β4 2β3 4 β11 0 0
ππππππ
Blending functions
Matrix form of spline
π π‘ = π‘2 π‘ 12 β4 2β3 4 β11 0 0
ππππππ
Blending functions π π‘ specify how to blend the values of the control
point vector
π π‘ = ππ π‘ ππ + ππ π‘ ππ + ππ π‘ ππ
ππ π‘ = 2π‘2 β 3π‘ + 1
ππ π‘ = β4π‘2 β 4π‘
ππ π‘ = 2π‘2 β 1
Hermite spline
β’ Piecewise cubic (π π‘ = π0 + π1π‘ + π2π‘2 + π3π‘
3)
β’ Additional constraint on tangents (derivatives)
β’ π π‘ = π0 + π1π‘ + π2π‘2 + π3π‘
3
β’ πβ² π‘ = π1 + 2π2π‘ + 3π3π‘2
β’ ππ = π 0 = π0β’ ππ = π 1 = π0 + π1 + π2 + π3β’ π1 = πβ²(0) = π1β’ π2 = πβ² 1 = π1 + 2π2 + 3π3
β’ Simpler matrix form
π π‘ = π‘3 π‘2 π‘ 1
2 β2 1 1β3 3 β2 β10 0 1 02 0 0 2
ππππππππ
ππ
ππππ
ππ
Hermite to BΓ©zier
Specify tangents as points
β’ π0 = π0, π1 = π3, π£0 = 3 π1 β π0 , π£1 = 3 π3 β π2
β’
ππππππππ
=
1 0 0 00 0 0 1β3 3 1 00 0 β3 3
ππππππππ
β’ Update Hermite eq. (from previous slide)
π π‘ = π‘3 π‘2 π‘ 1
2 β2 1 1β3 3 β2 β10 0 1 02 0 0 2
1 0 0 00 0 0 1β3 3 1 00 0 β3 3
ππππππππ
βππ
ππ
ππ
ππ
ππ
ππ
ππ ππ
ππ
BΓ©zier matrix
π π‘ = π‘3 π‘2 π‘ 1
β1 3 β3 13 β6 3 0β3 3 0 02 0 β6 6
ππππππππ
β’ π π‘ = Οπ=0π ππ,πππ
β’ Blending functions π π‘ has a special name in this case:
β’ Bernstein polynomials
ππ,π =ππ
π‘π 1 β π‘ πβπ
and that defines BΓ©zier curves for any degree
BΓ©zier blending functions
β’ The functions sum to 1 at
any point along the curve.
β’ Endpoints have full weight
10/10/2008
q0 q3
q1 q2
de Casteljau algorithm
Another view to BΓ©zier segments
Blend each linear spline with πΌ and π½ = 1 β πΌ
ππ
ππ
πΌ
π½
πΌππ + π½ππ
ππ
ππ
πΌ
π½
πΌ2ππ + 2πΌπ½ππ + π½2ππ
ππ
π½
πΌ
Review
http://www.inf.ed.ac.uk/teaching/courses/cg/d3/hermite.html
http://www.inf.ed.ac.uk/teaching/courses/cg/d3/bezier.html
http://www.inf.ed.ac.uk/teaching/courses/cg/d3/Casteljau.html
Today
β’ Spline segments
β’ Linear
β’ Quadratic
β’ Hermite
β’ Bezier
β’ Chaining splines
β’ Continuity and local control
β’ Hermite curves
β’ Bezier curves
β’ Catmull-Rom curves
β’ B-splines
Putting segments together
β’ Limited degree of freedom with a single polynomial
β’ Will it be smooth enough?
Continuity
Measuring smoothness
Smoothness as degree of continuity
β’ zero-order (πΆ0): position match
β’ first-order (πΆ1): tangent match
β’ second-order (πΆ2): curvature match
β’ πΆπ π£π πΊπ
Putting segments together
β’ Limited degree of freedom with a single polynomial
β’ Will it be smooth enough?
β’ Local control
Local control
β’ changing control point only affects a limited part of spline
β without this, splines are very difficult to use
β’ overshooting
β’ fixed computation
β many likely formulations lack this
β’ natural spline
β’ polynomial fits (matlab demo)
Piecewise linear
Putting segments together
Blending functions for a linear segment (0<t<1)
π π‘ = 1 β π‘ ππ + π‘ππ
ππ
ππ
π π‘
ππ ππ
Piecewise linear
Putting segments together
ππ π‘ = 1 β π‘ ππ + π‘ππ (0 < π‘ < 1)
ππ π‘ = ? ππ + ? ππ (1 < π‘ < 2)
ππ π‘ = 2 β π‘ ππ + π‘ β 1 ππ (1 < π‘ < 2)
ππ
ππ
ππ π‘
ππ
ππ π‘
ππ ππ ππ ππ
Putting segments together
How can we chain these segments to a longer curve?
β’ Use first segment between t=0 to t=1
β’ Use second segment between t=1 to t=2
π π‘ = ππ π‘ β π for π β€ π‘ β€ π + 1
β’ Shift blending functions
π0 π‘ = π0 π‘ ππ + π1 π‘ ππ
π1 π‘ = π0 π‘ β 1 ππ + π1 π‘ β 1 ππ
β’ Match derivatives at end points to avoid discontinuity
Hermite basis
Slide credit: S. Marschner
β’ How many segments for n control points?
(n-2)/2
β’ Continuity?
πΆ1
Can we add blending functions as in Hermite?
β’ If π3 β π2 is collinear with π4 β π3 , it is
πΊ1 continuous
β’ π3 β π2 = π(π4 β π3), π > 0
β’ If tangents match, it is πΆ1 continuous
β’ π3 β π2 = π(π4 β π3), k = 1
Chaining BΓ©zier Splines
ππ
ππ
ππ
ππ
Chaining segments
β’ Hermite curves are convenient because they can be made long
easily
β’ BΓ©zier curves are convenient because their controls are all points
β but it is fussy to maintain continuity constraints
β and they interpolate every 3rd point, which is a little odd
β’ We derived BΓ©zier from Hermite by defining tangents from control
points
β a similar construction leads to the interpolating Catmull-Rom
spline
Catmull-Rom
Would like to define tangents automatically
β use adjacent control points
ππ
ππ ππ
ππ
Hermite to Catmull-Rom
β’ π0 = π 0
β’ π1 = π 1
β’ π£1 = πβ²(0)
β’ π£2 = πβ² 1
β’ π π‘ =
π‘3 π‘2 π‘ 1
2 β2 1 1β3 3 β2 β10 0 1 02 0 0 2
ππππππππ
β’ π0 = π1
β’ π1 = π2
β’ π£0 =1
2(π2 β π0)
β’ π£1 =1
2(π3 β π1)
π π‘ = π‘3 π‘2 π‘ 1
2 β2 1 1β3 3 β2 β10 0 1 02 0 0 2
0 1 0 00 0 1 0
β0.5 0 0.5 00 β0.5 0 0.5
ππππππππ
Catmull-Rom
β’ Interpolating curve
β’ Like BΓ©zier, equivalent to Hermite
β’ Continuity ?
β’ Local control ?
β’ Add tension
β’ π0 = π1
β’ π1 = π2
β’ π£0 =1
2(1 β π‘)(π2 β π0)
β’ π£1 =1
2(1 β π‘)(π3 β π1)
B-splines
β’ We may want more continuity than πΆ1
β’ π π‘ = Οπ=1π ππ ππ(π‘)
β parameterized by k control points
β made of polynomials of degree k-1
β is πΆ(πβ2)
β’ B-splines are a clean, flexible way of making long splines with
arbitrary order of continuity
β’ Various ways to think of construction
β a simple one is convolution
β relationship to sampling and reconstruction
Quadratic B-spline
ππ,3 π‘ =
1
2π’2, if π β€ π‘ < π + 1, π’ = π‘ β π
βπ’2 + π’ +1
2, if π + 1 β€ π‘ < π + 1, π’ = π‘ β (π + 1)
1
2(1 β π’)2, if π + 2 β€ π‘ < π + 3, π’ = π‘ β (π + 2)
1
2π’2, otherwise.