Computer Graphics WS07/08 – Splines
Computer Graphics
- Splines -
Computer Graphics - Splines - Hendrik Lensch Computer Graphics - - PowerPoint PPT Presentation
Computer Graphics - Splines - Hendrik Lensch Computer Graphics WS07/08 Splines Overview Last Time Image-Based Rendering Today Parametric Curves Lagrange Interpolation Hermite Splines Bezier Splines
Computer Graphics WS07/08 – Splines
Computer Graphics WS07/08 – Splines 2
– Image-Based Rendering
– Parametric Curves – Lagrange Interpolation – Hermite Splines – Bezier Splines – DeCasteljau Algorithm – Parameterization
Computer Graphics WS07/08 – Splines 3
– Explicit
restricted domain
– Implicit:
unknown solution set
– Parametric:
– Avoids complicated functions (z.B. pow, exp, sin, sqrt) – Use simple polynomials of low degree
Computer Graphics WS07/08 – Splines 4
– 3D: f(t)= (x(t), y(t), z(t))
Computer Graphics WS07/08 – Splines 5
– Simple basis: 1, t, t2, ... (t usually in [0 .. 1])
– Coefficients can be determined from a sufficient number of constraints (e.g. interpolation of given points)
=
= =
n i i i A
t t z t y t x t P ) ( ) ( ) ( ) (
Monomials Degree (= Order – 1) Coefficients ∈R3
( )
⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = = =
− − − − , , , 1 , 1 , 1 , , , ´ , 1
1 ) ( ) ( ) ( ) ( ) (
z y x n z n y n x n z n y n x n n
A A A A A A A A A t t t T t z t y t x t P M L A
Computer Graphics WS07/08 – Splines 6
– Polynomial of degree (n-1)
– C0 = G0 = same point – Parametric continuity C1
– Geometric continuity G1
– Similar for higher derivatives
( )
[ ]
⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = = =
− − − − , , , 1 , 1 , 1 , , , ´ , 1 1
1 1 ) ´( ) ´( ) ´( ) ´( ) ´(
z y x n z n y n x n z n y n x n- n
A A A A A A A A A )t (n- nt t T t z t y t x t P M L A
Computer Graphics WS07/08 – Splines
– G0: curves are joined – G1: first derivatives are proportional at joint point, same direction but not necessarily same length – G2: first and second derivatives are proportional
– C0: curves are joined – C1: first derivative equal – C2: first and second derivatives are equal. If t is the time, this implies the acceleration is continuous. – Cn: all derivatives up to and including the nth are equal.
Computer Graphics WS07/08 – Splines 8
– Lagrange polynomials for a set of parameters T={t0, ..., tn}
– Good for interpolation at given parameter values
– Polynomial of degree n (n factors linear in t)
– Use Lagrange Polynomials with point coefficients
⎩ ⎨ ⎧ = = = − − =∏
≠ =
1 ) ( with , ) ( j i t L t t t t t L
ij j n i n j i
j i j n i
δ
=
n i i n i
Computer Graphics WS07/08 – Splines 9
– T={t0, t1}
– T={t0, t1, t2}
1 1 1 1 1 1
t0 t1 1 L0
1
L1
1
2 2 1 1 2 0 )
t0 t2 1 L0
1
L0
2
t1
Computer Graphics WS07/08 – Splines 10
– Degree depends on the number of interpolation constraints – Strong overshooting for high degree (n > 7) – Problems with smooth joints – Numerically unstable – No local changes
Computer Graphics WS07/08 – Splines 11
– Standard curve and surface primitives in geometric modeling – Key frame and in-betweens in animations – Filtering and reconstruction of images
– Name for a tool in ship building
– Within computer graphics:
Segment 1 Segment 2 Segment 3 Segment 4 What Continuity ?
Computer Graphics WS07/08 – Splines 12
2 3 4 1 1
1
) ( T y ) ( T y ) ( T P P(t)
3 3 2 2
t t t
i i
+ = =∑
i
2 3 4 1 y2 y3 T(t)
Computer Graphics WS07/08 – Splines 13
– Interpolation of position P and tangent P´ information for t= {0, 1} – Basis functions
2 3 3 2 3 2 2 3 1 2 3
) 2 3 ( ) ( ) 1 ( ) ( ) 1 ( ) ( ) 2 1 ( ) 1 ( ) ( t t t H t t t H t t t H t t t H − = − − = − = + − =
1
3
H
3 3
H
3 2
H
3 1
H
Computer Graphics WS07/08 – Splines 14
– H0 (H3) interpolates smoothly from 1 to 0 (1 to 0) – H0 and H3 have zero derivative at t= 0 and t= 1
– H1 and H2 are zero at t= 0 and t= 1
– H1 (H2) has slope 1 at t= 0 (t= 1)
– P0, P`1 are positions ∈R3 – P`0, P1 are derivatives (tangent vectors) ∈R3
3 3 1 3 2 1 3 1 3
3
H
3 3
H
3 2
H
3 1
H
Computer Graphics WS07/08 – Splines 15
Computer Graphics WS07/08 – Splines 16
3 2 1 4 4 4 4 4 4 4 3 4 4 4 4 4 4 4 2 1 4 4 4 4 3 4 4 4 4 2 1 O L 4 4 4 3 4 4 4 2 1 4 4 4 4 3 4 4 4 4 2 1 O 4 4 3 4 4 2 1 L M L
H H
G T T T T M z y x y y x z y x z y x T z y x n z n y n x n z n y n x
P P P P M M M M t t G G G G G G G G G G G G M M M M t t A A A A A A A A A t t t P ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ =
− − − 1 1 Functions Basis 21 13 12 11 2 3 (4x3) G Matrix Geometry , , , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , (4x4) M Matrix Basis 21 13 12 11 2 3 , , , 1 , 1 , 1 , , , ´ , 2 3
´ ´ 1 1 1 ) (
Computer Graphics WS07/08 – Splines 17
– Two matrices must multiply to unit matrix
H H T H H T H H T H H T
P P P P G M G M G M G M ) 1 2 3 ( ´ ) 1 ( ´ ) 1 1 1 1 ( ) 1 (
1 1
= = = =
H H H T T T T
1 1
−
1 H
Computer Graphics WS07/08 – Splines 18
– Different curve representation – Start and end point – 2 point that are approximated by the curve (cubics) – P´0= 3(b1-b0) and P´1= 3(b3-b2)
B HB T T T T T T T T H
3 2 1 1 1
Computer Graphics WS07/08 – Splines 19
– P(t)=T MH GH = T MH (MHB GB) = T (MHMHB) GB = T MB GB
– Basis functions: Bernstein polynomials
⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ − − − − = = 1 3 3 3 6 3 1 3 3 1
HB H B
M M M
i n i n i n i i n i
− =
3 3 2 2 1 2 3 3 3
1 3 1 3 1 ) ( P(t) b t
( t b
t( b
( b t B
i i i
+ + + = = ∑ =
3 BB0
3
B1
3
B2
3
B3
3
Computer Graphics WS07/08 – Splines 20
– End point interpolation – Tangents explicitly specified – Smooth joints are simple
– Geometric meaning of control points – Affine invariance
∀ ∑Bi(t) = 1
– Convex hull property
– Symmetry: Bi(t) = Bn-i(1-t)
– Smooth joints need to be maintained explicitly
Computer Graphics WS07/08 – Splines 21
– Simple but expensive
– Recursive definition of the basis functions – Inserting this once yields: – with the new Bézier points given by the recursion
1 1 1
n i n i n i − − −
− = − =
1 1 1
n i n i i n i n i i
i i k i k i k i
− − +
1 1 1
Computer Graphics WS07/08 – Splines 22
– Recursive degree reduction of the Bezier curve by using the recursion formula for the Bernstein polynomials
– t= 0.5
1 1 1
k i k i k i − − +
1 1 1
− = − =
n i n i n i i n i n i i
Computer Graphics WS07/08 – Splines 23
– Take boundaries of the deCasteljau triangle as new control points for left/right portion of the curve
– Backwards subdivision
Computer Graphics WS07/08 – Splines 24
– Smooth (C1)-joints between (cubic) spline segments
– Tangents given by neighboring points Pi-1 Pi+1 – Construct (cubic) Hermite segments
– Arbitrary number of control points – Interpolation without overshooting – Local control
Computer Graphics WS07/08 – Splines 25
– Piecewise polynomial curve – Four control points per segment – For n control points we obtain (n-3) polynomial segments
– Smooth interpolation of a given sequence of points – Key frame animation, camera movement, etc. – Only G1-continuity – Control points should be equidistant in time
⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ − − − − = =
+ + +
T T T T CR CR i
i i i i
P P P P T G T t P
3 2 1
2 1 1 1 4 5 2 1 3 3 1 2 1 ) ( M
__
Computer Graphics WS07/08 – Splines 26
– Often only the control points are given – How to obtain a suitable parameterization ti ?
– Arbitrary up to a constant factor
– Distances are not affine invariant ! – Shape of curves changes under transformations !!
= −
− = =
i j i i i
P P dist t t
1 1
) (
Computer Graphics WS07/08 – Splines 27
– Analog: Think P(t) as a moving object with mass that may
Uniform Chord-Length
Computer Graphics WS07/08 – Splines
– Spline curve with local control and high continuity
– Degree: n – Control points: P0, ..., Pm (Control polygon, m ≥ n+1) – Knots: t0, ..., tm+n+1 (Knot vector, weakly monotonic) – The knot vector defines the parametric locations where segments join
– Continuity:
i m i n i
P t N t P
=
= ) ( ) (
Computer Graphics WS07/08 – Splines
) ( ) ( ) (
if 1 ) (
1 1 1 1 1 1 1
t N t t t t t N t t t t t N t t t t N
n i i n i n i n i i n i i n i i i i − + + + + + + − + +
− − − − − = ⎩ ⎨ ⎧ < < =
1 2 3 4 5 1 2 3 4 5 N0 N1 N2 N3 N4 N0
1
N1
1
N2
1
N3
1
Uniform Knot vector
Computer Graphics WS07/08 – Splines
– Degree increases in every step – Support increases by one knot interval
Computer Graphics WS07/08 – Splines
– All knots at integer locations
– Example: cubic B-Splines
– Basis functions affect only (n+1) Spline segments – Changes are localized
n i n i
N B =
n i n i
d P =
Degree 2
Computer Graphics WS07/08 – Splines
– Spline segment lies in convex hull of (n+1) control points – (n+1) control points lie on a straight line curve touches this line – n control points coincide curve interpolates this point and is tangential to the control polygon
Degree 2
Computer Graphics WS07/08 – Splines
– Knots at beginning and end with multiplicity
– Interpolation of end points and tangents there – Conversion to Bézier segments via knot insertion
Computer Graphics WS07/08 – Splines
– Evaluation at t: tl < t < tl+1: i ∈ {l-n, ..., l}
– Affine invariance – Stable numerical evaluation
i i r i r i n i r i r i r i n i r i r i
− + + + + + − + + + +
1 1 1 1 1
n i n i
d t P = ) (