08_ParametricCurves_Web

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Curves

• used in many contexts


– fonts
– animation paths
– shape modeling
Parametric Spline Curves
• different representation
– implicit curves
– parametric curves
• mostly used

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 1 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 2

Implicit Representation for 2D Curves Parametric Representation for 2D Curves

• curves can be represented implicitly as • curves can be represented parametrically as


⎧ x = f x (u )
f (p) = f ( x, y ) = 0 p(u ) = ⎨
⎩ y = f y (u )
• example: circle of radius r centered at origin • example: circle of radius r centered at origin

⎧ x = r cos(u )
x2 + y2 − r 2 = 0 ⎨
⎩ y = r sin(u )

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 3 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 4
Parametric Representation of Splines Parametric Representation of Splines

• general parametric curve can be written as • splines: piecewise parametric polynomials


p(t ) = f (t ) t ∈ [0, N ] – polynomials are smooth
– controlled by small number of local control points
– discontinuities at integer intervals
• goals when defining f
– smoothness
– predictable and local control
– efficiency p(t ) = f (t ) t ∈ [0, N ]

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 5 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 6

Splines - Intuition Defining Splines

• define segment by “blending” control points • pick segment interpolating function


• impose constraints to define segments
– i.e. control points that define the spline
• impose constraints to join segments together
• join segments to form curve

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 7 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 8
Interpolating vs. Approximating Splines Smoothness
• interpolating • approximating • smoothness described by degree of continuity
– pass through control points – guided by control points – C0: same position at each side of joints
– C1: same tangent at each side of joints
– C2: same curvature at each side of joints
– Cn: n-th derivative defined at joints

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 9 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 10

Control Control

• local control • convex hull property


– changing control points only affect locally the curve – convex hull: smallest convex region enclosing all points
• easy to control • predictable behavior
– true for all splines • more efficient operations
– only some splines

yes

no

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 11 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 12
Efficiency Piecewise Linear Splines

• affine invariance • each segment is a linear function


– transforming the spline same as transforming controls p(t ) = ta + b t = [0,1]
– efficient algorithms, esp. combined with convex hull • impose endpoint constraints
– true for all used splines
⎧p(0) = p 0 ⎧a = p1 − p 0
⎨ ⇒⎨
⎩p(1) = p1 ⎩b = p 0
p(t ) = p 0 + t (p1 − p 0 ) t ∈ [0,1]

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 13 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 14

Point Blending Interpretation Matrix Notation

• can interpret as blending of points • write blending functions more conveniently


p(t ) = (1 − t )p 0 + tp1 = b0 (t )p 0 + b1 (t )p1 t ∈ [0,1) p(t ) = (1 − t )p 0 + tp1
• blending functions do not depend on points ⎡− 1 1⎤ ⎡p 0 ⎤
p(t ) = [t 1] ⎢ ⎥⎢ ⎥
– different intervals only change control points ⎣ 1 0⎦ ⎣ p1 ⎦

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 15 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 16
Joining Line Segments Hermite Splines

• impose C0 continuity at joints • each segment is a cubic polynomial function


– first segment ⎧p (0) = p
0 0
p(t ) = at 3 + bt 2 + ct + d
p 0 (t ) → ⎨ 0 0

⎩ p (1) = p • impose endpoints and tangents constraints


0
1
– second segment
⎧p1 (0) = p10
p1 (t ) → ⎨ 1
– implies ⎩ p (1) = p1
1
⎧p(0) = p 0
⎪p(1) = p
p 0 (1) = p1 (0) → p10 = p10 ⎪ 1

⎪p' (0) = p'0
⎪⎩p' (1) = p'1
• general formula
– appropriately rename control points
p(t) = b0 (t − k)pk + b1(t − k)pk+1 t ∈[0, N], k = floor(t)
Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 17 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 18

Hermite Splines Hermite

p(t ) = at 3 + bt 2 + ct + d • matrix formulation ⎡ 2 −2 1 2 ⎤ ⎡ p0 ⎤


p' (t ) = 3at + 2bt + c
2 ⎢− 3 3 − 2 − 1⎥ ⎢ p ⎥
p(t ) = [t 3 t2 t 1]⎢ ⎥⎢ 1⎥
⎢0 0 1 0 ⎥ ⎢p'0 ⎥
p ( 0) = d a = 2p 0 − 2p1 + p'0 +p'1
⎢1
⎣ 0 0 0 ⎥⎦ ⎢⎣ p'1 ⎥⎦
p(1) = a + b + c + d b = −3p 0 + 3p1 − 2p'0 −p'1 • blending functions
p ' ( 0) = c c = p '0
p' (1) = 3a + 2b d = p0

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 19 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 20
Bezier Splines Bezier Splines

• Hermite splines has points and vectors controls


– would like to use just points
– insight: specify tangents as difference of points
• choose appropriate scaling value, see later p0 = q0
p1 = q 3
p'0 = 3(q1 − q 0 )
p'1 = 3(q 3 − q 2 )

⎡ −1 3 − 3 1⎤ ⎡q 0 ⎤
⎢ 3 −6 3 0⎥ ⎢ q1 ⎥
p(t ) = [t 3 t2 t 1]⎢ ⎥⎢ ⎥
⎢− 3 3 0 0⎥ ⎢q 2 ⎥
⎢1
⎣ 0 0 0⎥⎦ ⎢⎣q 3 ⎥⎦
Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 21 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 22

Bezier Splines Piecewise Cubic Splines – Smoothness

• blending functions • C1 at joints by imposing equal tangents


– Hermite: same tangents
– Bezier: collinear control points
• geometric continuity if length of tangent differs

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 23 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 24
Piecewise Cubic Splines – Control Piecewise Cubic Splines – Affine Invariance

• local control • affine invariance


– comes from the formulation by segments – affine is combination of linear and translation
– for each segment, curve defined by 4 control points – blending functions sum to 1

X (p(t )) = Mp(t ) + t = M (∑ 3
i =0 i
)
b (t )p i + t =
• convex hull
= ∑i =0 bi (t ) Mp i + ∑i =0 bi (t )t =
3 3

– when blending positions


= ∑i =0 bi (t ) M (p i + t ) =∑i =0 bi (t ) MX (p i )
3 3
3
bi (t ) ≥ 0 and ∑ b (t ) = 1
i =0
i

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 25 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 26

Bezier Splines Catmull-Rom Splines

• widely used, especially in 2D • interpolating spline


– primitive in PDF – no convex hull property
• represent C1 and C0 curves with corners • as Hermite, derivatives automatically determined
• easily add point at any position – using adjacent control points
– end tangent using either adding point or zero

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 27 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 28
Catmull-Rom Splines Drawing Splines
p'k = (p k +1 − p k −1 ) / 2 • approximate with a sequence of line segments
– efficiency: fast evaluation, small number of segments
– guarantees on accuracy
• approaches
– uniform subdivision in t (fast)
– recursive subdivision (small number of segments)

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 29 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 30

Uniform Subdivision Adaptive Subvision - Bezier

• evaluate spline at fixed t intervals • recursively subdivide spline


– can be done efficiently • until line segments approximate well curve

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 31 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 32
De Casteljau Algorithm - Bezier B-Splines

• recursively do • would like C2 continuity at joints


– connect midpoints of the control polygons – give up interpolation
– connect midpoints of the new segments • impose 3 continuity constraints at joints
– the midpoint of this last segment is on the curve
– and splits the curve in two Bezier segments ⎡ −1 3 − 3 1⎤ ⎡ q k −1 ⎤

1 3 −6 3 0⎥ ⎢ q k ⎥
• stop when control polygon is close to collinear p(t ) = [t 3 t2 t 1] ⎢ ⎥⎢ ⎥
6 ⎢− 3 0 3 0⎥ ⎢ q k +1 ⎥
⎢1
⎣ 4 1 0⎥⎦ ⎢⎣q k +2 ⎥⎦

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 33 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 34

Other Splines Spline Equivalence

• many other types • all splines seen so far are equivalent


– represented by 4x4 matrices
• non-uniform B-splines
– discontinuities not evenly spaces • can convert control points from one to other
• non-uniform rational B-splines (NURBS) – algorithms can be based on the most efficient
– ratios of non-uniform B-splines – UIs can be based on the most user-friendly
– invariance under perspective
– can represent conic sections exactly
– often used in 3D

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 35 Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 36
2D vs. 3D splines

• often use 2D splines in 3D


– by projecting onto a plane
• 3D parametric splines have same formulation
– just use 3D vectors vs. 2D ones

Computer Graphics • Parametric Curves © 2005 Fabio Pellacini • 37

You might also like