Parametric Curves
Parametric Curves
1 2
animation
3 4
Mathematical curve representation Parametric polynomial curves
Explicit y=f(x) We’ll use parametric curves where the functions are all
• what if the curve isn’t a function?
polynomials in the parameter.
n
x (u ) = ∑ ak u k
k =0
Implicit f(x,y) = 0 n
• hard to work with
y (u ) = ∑ bk u k
x2 + y2 − R2 = 0 Advantages:
k =0
easy (and efficient) to compute
Parametric (f(u),g(u))
infinitely differentiable
x(u) = cos 2πu
y(u) = sin 2πu
5 6
Qx (t ) = ax t 3 + bx t 2 + cx t + d x cx c y cz
Q(t ) = [ x(t ) y (t ) z (t ) ] or Qy (t ) = a y t 3 + by t 2 + c y t + d y d x d y d z
Qz (t ) = az t 3 + bz t 2 + cz t + d z ax ay az
b by bz
or
Q(t ) = [ x(t ) y (t ) z (t ) ] = t 3 t 1
x
t2 = T⋅C
ax ay az x
c cy cz
b
by bz d x dy dz
Q(t ) = t 3 t 1
x
t2
cx cy cz
d d d d
d x dy dz
Q(t ) = Q′(t ) = ( T ⋅ C ) = T ⋅ C + T ⋅ C = 3t 2 2t 1 0 ⋅ C
7
dt dt dt dt 8
Controlling the cubic Constraining the cubics
Q: How many constraints do we need to specify to fully
Redefine C as a product of the basis matrix M and the
determine the scalar cubic function Q(t)? 4-element column vector of constraints or geometry vector G
C = M ⋅G
m11 m12 m13 m14 G1x G1 y G1z
m G2 z
m22 m23 m24 G2 x G2 y
Q: How many constraints do we need to specify to fully Q(t ) = t 3 t2 t 1 21
m31 m32 m33 m34 G3 x G3 y G3 z
determine the 3-vector cubic function Q(t)?
m41 m42 m43 m44 G4 x G4 y G4 z
= T⋅M ⋅G
9 10
Hermite Curves
Determined by
endpoints P1 and P4
tangent vectors at the endpoints R1 and R4
So
Q(t ) = T ⋅ M h ⋅ G h P4
Where P1 R4
P1x P1 y P1z
P P4 y P4 z R1
Gh =
4x
R1x R1 y R1z
R4 x R4 y R4 z
11 12
Computing Hermite basis matrix Computing Hermite basis matrix
The constraints on Q(0) and Q(1) are found by direct Collecting all constraints we get
substitution:
Q (0) = [ 0 0 0 1] ⋅ M h ⋅ G h Q(t) P4 P1x P1 y P1z 0 0 0 1
P
Q (1) = [1 1 1 1] ⋅ M h ⋅ G h 4x
P4 y P4 z
= G = 1 1 1 1
P1 R4 Mh ⋅ Gh
R1x R1 y R1z h
0 0 1 0
Tangents are defined by
R1 R4 x R4 y R4 z 3 2 1 0
Q′(t ) = 3t 2
2t 1 0 ⋅ M h ⋅ G h
so constraints on tangents are: So
−1
0 0 0 1 2 −2 1 1
Q′(0) = [ 0 0 1 0] ⋅ M h ⋅ G h 1 1 1 1 −3 3 −2 −1
Mh = =
Q′(1) = [3 2 1 0] ⋅ M h ⋅ G h Q(t) P4
0 0 1 0 0 0 1 0
P1 R4
3 2 1 0 1 0 0 0
13 14
R1
P1 Bh(t)
R1 P
= B h (t ) 4 1 P1 P4
R1
2 −2 1 1 P1
−3 3 −2 −1 P R 4
Q(t ) = t 3 t2 t 1 4
0 0 1 0 R1
1 0 0 0 R 4 R1
15 R4 1 t 16
Continuity Continuity of Splines
We want our curve to have continuity. There shouldn’t be an abrupt P4
P2 =P3 R4
change when we move from one segment to the next.
C0: points coincide,
There are nested degrees of continuity: P1 R2 velocities don’t
R3
C0: C1: R1
P4 R4
P2 =P3 G1: points coincide,
velocities have same direction
P1 R2
R3
R1 P4 R4
P2 =P3 C1: points and velocities
coincide
C2: C3, C4, …: P1 R2 = R3
Q: What’s C2?
17 R1 18
Bézier Curves
P1 P4
P2
R1 = 3(P2 − P1 )
R 4 = 3(P4 − P3 )
P1x P1 y P1z P1
P P2 y P2 z P2
Gb = =
2x
P3 x P3 y P3 z P3
P4 x P4 y P4 z P4
19 20
Bézier basis matrix Bézier basis matrix
Establish the relation between the Hermite and Besier Q(t ) = T ⋅ M h ⋅ G h = T ⋅ M h ⋅ ( M hb ⋅ G b )
geometry vectors:
= T ⋅ ( M h ⋅ M hb ) ⋅ G b = T ⋅ M b ⋅ G b
R1 = 3(P2 − P1 )
R 4 = 3(P4 − P3 ) −1 3 −3 1
3 −6 3 0
M b = M h M hb =
−3 3 0 0
P1 1 0 0 P1
0
P 0 1 0 0 0
0 1 P2
0
Gh = 4 = = M bhG b
R 1 −3 3 0 0 P3
R 4 0 0 −3 3 P4 Q(t ) = T ⋅ M b ⋅ G b
21 22
n
n
Q(t ) = ∑ Pi t i (1 − t ) n −i
1 t 23
i =0 i 24
Displaying Bézier curves Subdivide and conquer
How could we draw one of these things?
Instead, we’ll splice together a curve from individual segments that are
cubic Béziers.
First, we’ll rewrite our equation for Q(t) in matrix form: Qv (1) = Qw (0) ⇒ V3 = W0
−1 3 −3 1 P0 Qv′ (1) = Qw′ (0) ⇒ V3 − V2 = W1 − W0
3 −6 3 P Q′(0) = 3(V1 − V0 )
Q (t ) = t 3 t2 t 1
−3 3
1
P2
Q′(1 ) = 3(V3 − V2 ) Qv′′ (1) = Qw′′ (0) ⇒ V1 − 2V2 + V3 = W0 − 2W1 + W2
P Q′′(0) = 6(V0 − 2V1 + V2 )
1 3
Q′′(1 ) = 6(V1 − 2V2 + V3 )
⇓
W2 = V1 + 4V3 − 4V2
31 32
A-frames and continuity Building a complex spline
Let’s try to get some geometrical intuition about what this last Instead of specifying the Bézier control points themselves, let’s specify
the corners of the A-frames in order to build a C2 continuous spline.
continuity equation means.
V3 = W0
W1
B1
W2
W1
V0
These are called B-splines. The starting set of points are called de Boor
W2 W3 points.
33 34
How can we keep the C2 continuity we get with B-splines but get
interpolation, too?
41 42
1 4 1 D2 E2
We can use forward elimination to zero out everything below the =
diagonal, then back substitution to compute each D value. % # #
1 4 1 Dm-1 Em-1
43 1 2 Dm Em 44
Back subsitution C2 interpolating spline
The resulting matrix is upper diagonal: Once we’ve solved for the real Dis, we can plug them in to find our Bézier
control points and draw the final spline:
UD = F
u11 … u1m D0 F0
D F
1 1
D2 F2
=
% # # #
Dm-1 Fm-1
umm Dm Fm
We can now solve for the unknowns by back substitution:
umm Dm = Fm Have we lost anything?
47 48
Catmull-Rom basis matrix
Q ( t ) = t 3 t 2 t 1
2 −1 0 1 0 P3
0 2 0 0 P4 P3
P0
P4
49 50
53