Upload
others
View
15
Download
5
Embed Size (px)
Citation preview
CENG 477Introduction to Computer Graphics
Representing Curves and Surfaces
Introduction• There are no straight lines or flat faces in nature!• Therefore, representing and generating smooth shapes is a
requirement in many CG applications• Rendering will still use lines and triangles but their vertices
will be sampled from a curve or surface
CENG 477 – Computer Graphics 2
Curves• There are many ways to represent curves:
– must be practical (easy to manage and render)– must be flexible (general enough to be used in various modeling tasks)
• A good compromise is cubic polynomials• Each x, y, z coordinate expressed a cubic polynomial with
potentially different coefficients
CENG 477 – Computer Graphics 3
𝑥 𝑡 = 𝑎&𝑡' + 𝑏&𝑡* + 𝑐&𝑡 + 𝑑&
𝑦 𝑡 = 𝑎.𝑡' + 𝑏.𝑡* + 𝑐.𝑡 + 𝑑.
𝑧 𝑡 = 𝑎0𝑡' + 𝑏0𝑡* + 𝑐0𝑡 + 𝑑0
Curves• For a given t value, 𝑞 𝑡 = [𝑥 𝑡 𝑦 𝑡 𝑧 𝑡 ]represents the 3D
position along the curve• Almost like ray tracing except that the ray follows a curvy path
instead of a straight one!• The 𝑡 parameter is taken to be in range [0, 1]
CENG 477 – Computer Graphics 4
𝑞(0)𝑞(1)
𝑞(0.5)
Cubic Polynomials• As cubic polynomials have 4 unknowns (per component), we
need 4 constraints to find them• Different curves are distinguished by different constraints
– Hermite curves: 2 end points + 2 tangent vectors– Bezier curves: 2 end points + 2 control points– Splines: 4 control points (for each piece of the curve)
CENG 477 – Computer Graphics 5
Matrix Form• Cubic polynomials are conveniently expressed in matrix form:
CENG 477 – Computer Graphics 6
𝑥 𝑡 = 𝑎&𝑡' + 𝑏&𝑡* + 𝑐&𝑡 + 𝑑&
𝑦 𝑡 = 𝑎.𝑡' + 𝑏.𝑡* + 𝑐.𝑡 + 𝑑.
𝑧 𝑡 = 𝑎0𝑡' + 𝑏0𝑡* + 𝑐0𝑡 + 𝑑0
𝑄 𝑡 = 𝑥 𝑡 𝑦 𝑡 𝑧 𝑡 = [𝑡'𝑡*𝑡1]
𝑎& 𝑎. 𝑎0𝑏& 𝑏. 𝑏0𝑐& 𝑐. 𝑐0𝑑& 𝑑. 𝑑0
𝑄 𝑡 = 𝑇𝐶
Matrix Form• We will also need the derivative of this curve to specify
tangent vectors
CENG 477 – Computer Graphics 7
𝑑𝑄 𝑡𝑑𝑡 = 𝑄> 𝑡 =
𝑑𝑇𝑑𝑡 𝐶 = 3𝑡*2𝑡10 𝐶
Constraints• Imagine that we want to specify certain geometrical
constraints such as:– Start point– End point– Start direction (i.e. tangent vector at start point)– End direction (i.e. tangent vector at end point)
• We need to split the matrix C into two to allow embedding these constraints
CENG 477 – Computer Graphics 8
Constraints• Rewrite 𝐶 = 𝑀𝐺, where 𝐺 represents the geometry constraints
• Here, 𝑀 is called the basis matrix• 𝐺 is called the geometry or the constraints matrix• Different types of curves differ in 𝑀 and 𝐺
CENG 477 – Computer Graphics 9
C =
𝑎& 𝑎. 𝑎0𝑏& 𝑏. 𝑏0𝑐& 𝑐. 𝑐0𝑑& 𝑑. 𝑑0
=
𝑚DD 𝑚D* 𝑚D' 𝑚DE𝑚*D 𝑚** 𝑚*' 𝑚*E𝑚'D 𝑚'* 𝑚'' 𝑚'E𝑚ED 𝑚E* 𝑚E' 𝑚EE
𝑔D& 𝑔D. 𝑔D0𝑔*& 𝑔*. 𝑔*0𝑔'& 𝑔'. 𝑔'0𝑔E& 𝑔E. 𝑔E0
𝑀 𝐺
Constraints• Note that 𝑄 𝑡 = 𝑇𝑀𝐺• For instance:
CENG 477 – Computer Graphics 10
𝑥 𝑡 = [𝑡'𝑡*𝑡1] 𝑔D&
𝑚DD𝑚*D𝑚'D𝑚ED
+ 𝑔*&
𝑚D*𝑚**𝑚'*𝑚E*
+ 𝑔'&
𝑚D'𝑚*'𝑚''𝑚E'
+ 𝑔E&
𝑚DE𝑚*E𝑚'E𝑚EE
Blending Functions• Rewriting this gives us:
• That is, the curve is a weighted sum of the elements of the geometry matrix
CENG 477 – Computer Graphics 11
𝑥 𝑡 = [𝑡'𝑡*𝑡1] 𝑔D&
𝑚DD𝑚*D𝑚'D𝑚ED
+ 𝑔*&
𝑚D*𝑚**𝑚'*𝑚E*
+ 𝑔'&
𝑚D'𝑚*'𝑚''𝑚E'
+ 𝑔E&
𝑚DE𝑚*E𝑚'E𝑚EE
𝑥 𝑡 = 𝑡'𝑚DD + 𝑡*𝑚*D + 𝑡𝑚'D +𝑚ED 𝑔D& +𝑡'𝑚D* + 𝑡*𝑚** + 𝑡𝑚'* +𝑚E* 𝑔*& +𝑡'𝑚D' + 𝑡*𝑚*' + 𝑡𝑚'' +𝑚E' 𝑔'& +𝑡'𝑚DE + 𝑡*𝑚*E + 𝑡𝑚'E +𝑚EE 𝑔E&
Blending Functions• The weights are each cubic polynomials of 𝑡• These polynomials are called blending functions
CENG 477 – Computer Graphics 12
𝑥 𝑡 = 𝑡'𝑚DD + 𝑡*𝑚*D + 𝑡𝑚'D +𝑚ED 𝑔D& +𝑡'𝑚D* + 𝑡*𝑚** + 𝑡𝑚'* +𝑚E* 𝑔*& +𝑡'𝑚D' + 𝑡*𝑚*' + 𝑡𝑚'' +𝑚E' 𝑔'& +𝑡'𝑚DE + 𝑡*𝑚*E + 𝑡𝑚'E +𝑚EE 𝑔E&
𝐵D&E = 𝑇D&E𝑀E&E
Vector of blending functions
Hermite Curves• The constraints of Hermite curves are:
– Two end points: 𝑃D and 𝑃E– Two tangent vectors: 𝑅D and 𝑅E
CENG 477 – Computer Graphics 13
𝑃D
𝑃E𝑅D
𝑅E
Hermite Curves• The geometry matrix then becomes:
• To find 𝑀 remember that the curve in matrix form we have:
• And for derivative:
CENG 477 – Computer Graphics 14
𝐺 =
𝑃D𝑃E𝑅D𝑅E
=
𝑃D& 𝑃D. 𝑃D0𝑃E& 𝑃E. 𝑃E0𝑅D& 𝑅D. 𝑅D0𝑅E& 𝑅E. 𝑅E0
𝑄 𝑡 = 𝑇𝑀𝐺
𝑄′ 𝑡 = 𝑇′𝑀𝐺
Hermite Curves• We can now plug in values for the 𝑡 parameter
– Compute 𝑄 0 ,𝑄 1 ,𝑄> 0 , 𝑄′(1)
• This is the same as:
CENG 477 – Computer Graphics 15
𝑄 0 = [0001]𝑀𝐺𝑄 1 = [1111]𝑀𝐺𝑄′ 0 = [0010]𝑀𝐺𝑄′ 1 = [3210]𝑀𝐺
𝑄(0)𝑄(1)𝑄′(0)𝑄′(1)
=
0 0 0 11 1 1 10 0 1 03 2 1 0
𝑀𝐺
Hermite Curves• Remember that 𝐺 was equal to:
• So we have:
CENG 477 – Computer Graphics 16
𝐺 =
𝑃D𝑃E𝑅D𝑅E
=
𝑄(0)𝑄(1)𝑄′(0)𝑄′(1)
𝑄(0)𝑄(1)𝑄′(0)𝑄′(1)
=
0 0 0 11 1 1 10 0 1 03 2 1 0
𝑀
𝑄(0)𝑄(1)𝑄′(0)𝑄′(1)
Same
Only possibleif 𝑀 is the inverseof the matrix
Hermite Curves• Therefore, Hermite curves have the following basis matrix:
• This yields the following blending functions:
CENG 477 – Computer Graphics 17
𝑀 =
0 0 0 11 1 1 10 0 1 03 2 1 0
KD
=
2 −2 1 1−3 3 −2 −10 0 1 01 0 0 0
𝐵 = 2𝑡' − 3𝑡* + 1−2𝑡' + 3𝑡*𝑡' − 2𝑡* + 𝑡𝑡' − 𝑡*
M Let’s plot thesewith gnuplot anddo some experimentationwith Matlab!
Hermite Blending Functions
CENG 477 – Computer Graphics 18
Bezier Curves• Bezier curves can draw the same curves as Hermite curves• They are defined using control points instead of derivatives• Two control points are interpolated and two control points are
approximated
CENG 477 – Computer Graphics 19
Bezier Curves• The curve lies entirely within the convex-hull of these four
points• This is useful for clipping, culling, and intersection tests as the
convex-hull can be tested first instead of each line segment
CENG 477 – Computer Graphics 20
Bezier Curves• Bezier curves are related to the Hermite curves as:
• The factor 3 ensures that 𝑃* has the highest weight at 𝑡 = 1/3and 𝑃' has the highest weight at 𝑡 = 2/3, logically dividing the curve into 3 pieces
CENG 477 – Computer Graphics 21
𝑅D = 3(𝑃* − 𝑃D)
𝑅E = 3(𝑃E − 𝑃')
Bezier Curves• In matrix form, this relationship can be express as:
CENG 477 – Computer Graphics 22
𝐺O =
𝑃D𝑃E𝑅D𝑅E
=
1 0 0 00 0 0 1−3 3 0 00 0 −3 3
𝑃D𝑃*𝑃'𝑃E
𝐺P
This matrix translates Bezier geometrymatrix to the Hermite geometry matrix(let’s call this matrix as 𝑀PO)
Bezier Curves• Then Bezier curves can be defined as:
CENG 477 – Computer Graphics 23
𝑄 𝑡 = 𝑇𝑀O𝐺O = 𝑇𝑀O𝑀PO𝑀P
𝑄 𝑡 = 𝑇𝑀P𝐺P
𝑀P = 𝑀O𝑀POwhere
𝑄 𝑡 = 𝑡' 𝑡* 𝑡 1
−1 3 −3 13 −6 3 0−3 3 0 01 0 0 0
𝑃D𝑃*𝑃'𝑃E
Bezier Curves• This is equivalent to:
• These are called Bernstein polynomials– Their sum is always 1– They are always non-negative when 𝑡 ∈ [0,1]– That’s why the resulting curve is in the convex-hull of 𝑃D, 𝑃*, 𝑃', 𝑃E– Bernstein polynomial of degree 𝑛 is 𝐵T,U 𝑡 = 𝑛𝑖 𝑡T 1 − 𝑡 UKT
CENG 477 – Computer Graphics 24
𝑄 𝑡 = −𝑡' + 3𝑡* − 3𝑡 + 1 𝑃D +
3𝑡' − 6𝑡* + 3𝑡 𝑃* +−3𝑡' + 3𝑡* 𝑃' +𝑡' 𝑃E
=(1 − 𝑡)'𝑃D +3𝑡(1 − 𝑡)*𝑃* +3𝑡*(1 − 𝑡)𝑃' +𝑡'𝑃E +
Bezier Curves• Bezier curve is the sum of Bernstein polynomials
CENG 477 – Computer Graphics 25
𝑄 𝑡 = (1 − 𝑡)'𝑃D + 3𝑡(1 − 𝑡)*𝑃* + 3𝑡*(1 − 𝑡)𝑃' + 𝑡'𝑃E
𝑄 𝑡 = W𝐵T,U 𝑡 𝑃TXD
U
TYZ
𝐵T,U 𝑡 = 𝑛𝑖 𝑡T 1 − 𝑡 UKT
Bernstein Polynomials
CENG 477 – Computer Graphics 26
Continuity• Until now, we learned to draw a single curve segment• If we want to combine multiple curve segments, we must
ensure maintaining continuity
CENG 477 – Computer Graphics 27
Curve 1 Curve 2
Types of Continuity• No continuity:
– The curves do not meet
• C0 continuity:– The end points meet, also know as positional continuity
CENG 477 – Computer Graphics 28
Types of Continuity• C1 continuity:
– The curves meet and have identical tangent vectors at the connection
• C2 continuity:– The curves meet and have identical curvature at the connection– The curvature is defined as the rate of change of tangents
CENG 477 – Computer Graphics 29
Types of Continuity• Imagine a camera moving along a curve with multiple segments
– No continuity: camera will make jumps between segments– C0 continuity: camera velocity may suddenly change– C1 continuity: camera acceleration may suddenly change– C2 continuity: camera motion will appear smooth
• In general, maintaining C2 continuity is desired
CENG 477 – Computer Graphics 30
Maintaining Continuity• Imagine having two Hermite curves:
• C1 continuity can be maintained if 𝑃E = 𝑄D and 𝑅E = 𝑇D
CENG 477 – Computer Graphics 31
𝐺[ =
𝑃D𝑃E𝑅D𝑅E
𝐺\ =
𝑄D𝑄E𝑇D𝑇E
Maintaining Continuity• Similarly for two Bezier curves:
• C1 is ensured if 𝑃E = 𝑄D and 𝑃E − 𝑃' = 𝑄* − 𝑄D
CENG 477 – Computer Graphics 32
𝐺[ =
𝑃D𝑃*𝑃'𝑃E
𝐺\ =
𝑄D𝑄*𝑄'𝑄E
Maintaining Continuity• What if we want to maintain C2 continuity?• Unfortunately, neither Hermite nor Bezier curves can
guarantee C2 continuity• For this we have a new type of curve called splines
CENG 477 – Computer Graphics 33
Splines• The term spline was used to refer to flexible metal strips used
by draftspersons to design the surfaces of airplanes, cars, and ships, etc.
CENG 477 – Computer Graphics 34
core77.com
Splines• The splines, due to physical properties of the metal strips, had
second order (C2) continuity• Its mathematical equivalent is natural cubic splines• Splines have one more degree of continuity than that is
afforded by Hermite and Bezier curves• There are other types of splines:
– B-Splines– Uniform Nonrational B-Splines– Nonuniform Nonrational B-Splines– Nonuniform Rational B-Splines– Beta-Splines– V-Splines
CENG 477 – Computer Graphics 35
Natural Cubic Splines• Defined by n+1 control points• The spline, consisting of n curves, interpolates all of these
points
CENG 477 – Computer Graphics 36
𝑃Z
𝑃D
𝑃*
𝑃'𝑃E
𝑃UKD
𝑃U
𝑆Z(𝑡)
𝑆D(𝑡)
𝑆*(𝑡)
𝑆'(𝑡)
𝑆UKD(𝑡)
Natural Cubic Splines• The spline is defined as:
• Each curve is a cubic polynomial:
CENG 477 – Computer Graphics 37
𝑆 𝑡 =
𝑆Z 𝑡 , 𝑡Z ≤ 𝑡 ≤ 𝑡D𝑆D 𝑡 , 𝑡D ≤ 𝑡 ≤ 𝑡*⋮
𝑆UKD 𝑡 , 𝑡UKD ≤ 𝑡 ≤ 𝑡U
𝑆Z 𝑡 = 𝑎Z𝑡' + 𝑏Z𝑡* + 𝑐Z𝑡 + 𝑑Z⋮
𝑆UKD 𝑡 = 𝑎UKD𝑡' + 𝑏UKD𝑡* + 𝑐UKD𝑡 + 𝑑UKD
There are a totalof 4n unknowns!
Natural Cubic Splines• The end points of the curves must meet (C0 cont.) and their
first two derivatives must be equal (C1 and C2):
• This gives us 3n – 3 equations
CENG 477 – Computer Graphics 38
𝑆TKD 𝑡T = 𝑆T(𝑡T)𝑆TKD> 𝑡T = 𝑆T>(𝑡T)
𝑆TKD>> 𝑡T = 𝑆T>>(𝑡T)𝑖 = 1…𝑛 − 1
Natural Cubic Splines• We also know the values of the spline at the control points:
• This gives us another n+1 equations• We still need two more …• 𝑆>′ 𝑡Z = 𝑆>′ 𝑡U = 0 gives us natural cubic splines
CENG 477 – Computer Graphics 39
𝑆 𝑡T = 𝑃T, 𝑖 = 0… 𝑛
Computing Polynomials• Let’s call the second derivatives at control points as:
• For natural cubic spline we have 𝑍Z = 𝑍U = [000]M• How does 𝑆′′(𝑡) look like?
CENG 477 – Computer Graphics 40
𝑍T = 𝑆>>(𝑡T)
𝑆′(𝑡) 𝑆′′(𝑡)𝑆(𝑡)
Computing Polynomials• 𝑆′′(𝑡) will be piecewise-linear
CENG 477 – Computer Graphics 41
𝑍Z = 𝟎M
𝑍*
𝑍'
𝑍E
𝑍UKD
𝑍U = 𝟎M
𝑡Z 𝑡* 𝑡' 𝑡E 𝑡UKD 𝑡U
𝑆T>> 𝑡 = 𝑍T𝑡 − 𝑡TXD𝑡T − 𝑡TXD
+𝑍TXD𝑡 − 𝑡T𝑡TXD − 𝑡T𝑍D
𝑡D
This derivation is largely inspired from Arne Morten Kvarving’s slides on cubic splines
Computing Polynomials• 𝑆′′(𝑡) will be piecewise-linear
CENG 477 – Computer Graphics 42
𝑍Z = 𝟎M
𝑍*
𝑍'
𝑍E
𝑍UKD
𝑍U = 𝟎M
𝑡Z 𝑡* 𝑡' 𝑡E 𝑡UKD 𝑡U
𝑆T>> 𝑡 = 𝑍TXD𝑡 − 𝑡TℎT
+ 𝑍T𝑡TXD − 𝑡ℎT𝑍D
𝑡D
where ℎT = 𝑡TXD − 𝑡T
Computing Polynomials• At this point, we need to integrate twice to obtain 𝑆(𝑡)
CENG 477 – Computer Graphics 43
𝑆T>> 𝑡 = 𝑍TXD𝑡 − 𝑡TℎT
+ 𝑍T𝑡TXD − 𝑡ℎT
𝑆T> 𝑡 = 𝑍TXD(𝑡 − 𝑡T)*
2ℎT+ 𝑍T
(𝑡TXD − 𝑡)*
−2ℎT+ 𝐶T
𝑆T 𝑡 = 𝑍TXD(𝑡 − 𝑡T)'
6ℎT+ 𝑍T
(𝑡TXD − 𝑡)'
6ℎT+ 𝐶T𝑡 + 𝐷T
𝑆T 𝑡 = 𝑍TXD(𝑡 − 𝑡T)'
6ℎT+ 𝑍T
(𝑡TXD − 𝑡)'
6ℎT+ 𝐸T(𝑡 − 𝑡T) + 𝐹T(𝑡TXD − 𝑡)
where𝐶T = 𝐸T − 𝐹T and 𝐷T = 𝐹T𝑡TXD − 𝐸T𝑡T
Computing Polynomials• At this point, the only unknowns are 𝑍T, 𝑍TXD, 𝐸T and 𝐹T
• Plug-in the values at the control points:
• From here, we can determine 𝐸T and 𝐹T
CENG 477 – Computer Graphics 44
𝑆T 𝑡 = 𝑍TXD(𝑡 − 𝑡T)'
6ℎT+ 𝑍T
(𝑡TXD − 𝑡)'
6ℎT+ 𝐸T(𝑡 − 𝑡T) + 𝐹T(𝑡TXD − 𝑡)
𝑆T 𝑡T = 𝑃T = 𝑍TℎT*
6 + 𝐹TℎT
𝑆T 𝑡TXD = 𝑃TXD = 𝑍TXDℎT*
6 + 𝐸TℎT
Computing Polynomials• This gives us:
• Finally, we need to compute the 𝒁𝒊 terms• We know that 𝒁𝟎 = 𝒁𝒏 = [000]M
CENG 477 – Computer Graphics 45
𝑆T 𝑡 = 𝒁𝒊X𝟏(𝑡 − 𝑡T)'
6ℎT+ 𝒁𝒊
(𝑡TXD − 𝑡)'
6ℎT+
𝑃TXDℎT
−𝑍TXDℎT6 (𝑡 − 𝑡T) +
𝑃TℎT−𝑍TℎT6 (𝑡TXD − 𝑡)
Computing Polynomials• We did not use the constraint that the first derivatives at the
control points are equal; so take the derivative
CENG 477 – Computer Graphics 46
𝑺𝒊> 𝒕 = 𝒁𝒊X𝟏(𝑡 − 𝑡T)*
2ℎT− 𝒁𝒊
𝑡TXD − 𝑡 *
2ℎT+1ℎT
𝑷𝒊X𝟏 − 𝑷𝒊 −ℎT6 𝒁𝒊X𝟏 − 𝒁𝒊
𝑩𝒊
𝑺𝒊> 𝒕𝒊 = −𝒁𝒊ℎT2 +𝑩𝒊 −
ℎT6 𝒁𝒊X𝟏 +
ℎT6 𝒁𝒊
Computing Polynomials• Repeat this for the previous (or the next) segment:
CENG 477 – Computer Graphics 47
𝑺𝒊K𝟏> 𝒕 = 𝒁𝒊(𝑡 − 𝑡TKD)*
2ℎTKD− 𝒁𝒊K𝟏
𝑡T − 𝑡 *
2ℎTKD+
1ℎTKD
𝑷𝒊 − 𝑷𝒊K𝟏 −ℎTKD6 𝒁𝒊 − 𝒁𝒊K𝟏
𝑩𝒊K𝟏
𝑺𝒊K𝟏> 𝒕𝒊 = 𝒁𝒊ℎTKD2 +𝑩𝒊K𝟏 −
ℎTKD6 𝒁𝒊 +
ℎTKD6 𝒁𝒊K𝟏
Computing Polynomials• Now equate the segments at the control points:
CENG 477 – Computer Graphics 48
−𝒁𝒊ℎT2 +𝑩𝒊 −
ℎT6 𝒁𝒊X𝟏 +
ℎT6 𝒁𝒊 = 𝒁𝒊
ℎTKD2 +𝑩𝒊K𝟏 −
ℎTKD6 𝒁𝒊 +
ℎTKD6 𝒁𝒊K𝟏
𝑺𝒊> 𝒕𝒊 = 𝑺𝒊K𝟏> 𝒕𝒊
−3𝒁𝒊ℎT + 6𝑩𝒊 − ℎT𝒁𝒊X𝟏 + ℎT𝒁𝒊 = 3𝒁𝒊ℎTKD + 6𝑩𝒊K𝟏 − ℎTKD𝒁𝒊 + ℎTKD𝒁𝒊K𝟏
6(𝑩𝒊 − 𝑩𝒊K𝟏) = ℎTKD𝒁𝒊K𝟏 +2(ℎTKD + ℎT)𝒁𝒊+ℎT𝒁𝒊X𝟏
Computing Polynomials• We can set up n-1 equations in this form and we also have n-1
unknowns (from 𝑍D to 𝑍UKD)
• In the above equation, plug 𝑖 = 1…𝑛 − 1, and solve the resulting system
CENG 477 – Computer Graphics 49
6(𝑩𝒊 − 𝑩𝒊K𝟏) = ℎTKD𝒁𝒊K𝟏 +2(ℎTKD + ℎT)𝒁𝒊+ℎT𝒁𝒊X𝟏
Computing Polynomials• Setup the system such that we have the 𝐴𝑥 = 𝑏 form
CENG 477 – Computer Graphics 50
𝑣D ℎD 0 …ℎD 𝑣* ℎ*0 ℎ* 𝑣' ℎ'⋮ ⋱
𝑣UK* ℎUK*ℎUK* 𝑣UKD
𝑍D,&𝑍*,&𝑍',&⋮
𝑍UKD,&
=
𝑏D𝑏*𝑏'⋮
𝑏UKD
𝑣T = 2(ℎTKD + ℎT)
𝑏T = 6(𝐵T,& − 𝐵TKD,&)
• Note that we are solving for the x-components• We need to solve for y- and z-components if
our curve is 3 dimensional
ℎT = 𝑡TXD − 𝑡T
𝐵T,& =1ℎT
𝑃TXD,& − 𝑃T,&
Sample Output
CENG 477 – Computer Graphics 51
P = {(1, 1), (2, 3), (3, 2), (4, 5), (5, 1), (6, 3), (7, 2)}T = {0, 1, 2, 3, 4, 5, 6}
Parametric Bicubic Surfaces• Generalization of parametric cubic curves• Recall 𝑄 𝑡 = 𝑇𝑀𝐺• First replace 𝑡 by 𝑠 such that 𝑄 𝑠 = 𝑆𝑀𝐺• Now allow the points in 𝐺 to vary along a curve parametrized
by 𝑡
CENG 477 – Computer Graphics 52
𝑄 𝑠, 𝑡 = 𝑆𝑀𝐺(𝑡)
𝑄 𝑠, 𝑡 = 𝑆𝑀
𝐺D(𝑡)𝐺*(𝑡)𝐺'(𝑡)𝐺E(𝑡)
𝐺D&(𝑡) 𝐺D.(𝑡) 𝐺D0(𝑡)
Parametric Bicubic Surfaces• We can setup separate equations for x, y, and z:
CENG 477 – Computer Graphics 53
𝑄& 𝑠, 𝑡 = 𝑆𝑀
𝐺D&(𝑡)𝐺*&(𝑡)𝐺'&(𝑡)𝐺E&(𝑡)
𝑄. 𝑠, 𝑡 = 𝑆𝑀
𝐺D.(𝑡)𝐺*.(𝑡)𝐺'.(𝑡)𝐺E.(𝑡)
𝑄0 𝑠, 𝑡 = 𝑆𝑀
𝐺D0(𝑡)𝐺*0(𝑡)𝐺'0(𝑡)𝐺E0(𝑡)
Parametric Bicubic Surfaces• Now for a fixed 𝑡 = 𝑡D, 𝑄(𝑠, 𝑡D) is a curve because 𝐺(𝑡D) is
constant• Allowing 𝑡 to take on a different value, 𝑡*, where 𝑡* − 𝑡D is
very small, 𝑄(𝑠, 𝑡*) is a slightly different curve• Repeating this arbitrarily many times gives you a large set of
curves, which is our surface
CENG 477 – Computer Graphics 54
…
Called bicubic if 𝐺T (𝑡) are themselves cubic
Derivation• Assume that 𝐺T(𝑡) themselves are defined by:
CENG 477 – Computer Graphics 55
𝐺T 𝑡 = 𝑇𝑀𝑍T
𝐺T 𝑡 = 𝑇𝑀
𝑍TD𝑍T*𝑍T'𝑍TE
𝑍TD& 𝑍TD. 𝑍TD0
𝐺T& 𝑡 = 𝑇𝑀
𝑍TD&𝑍T*&𝑍T'&𝑍TE&
𝐺T. 𝑡 = 𝑇𝑀
𝑍TD.𝑍T*.𝑍T'.𝑍TE.
𝐺T0 𝑡 = 𝑇𝑀
𝑍TD0𝑍T*0𝑍T'0𝑍TE0
Derivation• Remember that we have:
• To combine them into a single equation, take the transpose of 𝐺T& 𝑡 , which is equal to itself due to its being a scalar:
CENG 477 – Computer Graphics 56
𝑄& 𝑠, 𝑡 = 𝑆𝑀
𝐺D&(𝑡)𝐺*&(𝑡)𝐺'&(𝑡)𝐺E&(𝑡)
𝐺T& 𝑡 = 𝑇𝑀
𝑍TD&𝑍T*&𝑍T'&𝑍TE&
𝐺D& 𝑡 M = 𝐺D& 𝑡 = 𝑍DD& 𝑍DD& 𝑍D'& 𝑍DE& 𝑀M𝑇M
𝐺*& 𝑡 M = 𝐺*& 𝑡 = 𝑍*D& 𝑍*D& 𝑍*'& 𝑍*E& 𝑀M𝑇M
𝐺'& 𝑡 M = 𝐺'& 𝑡 = 𝑍'D& 𝑍'D& 𝑍''& 𝑍'E& 𝑀M𝑇M
𝐺E& 𝑡 M = 𝐺E& 𝑡 = 𝑍ED& 𝑍ED& 𝑍E'& 𝑍EE& 𝑀M𝑇M
Derivation• Remember that we have:
• To combine them into a single equation, take the transpose of 𝐺T& 𝑡 , which is equal to itself due to its being a scalar:
CENG 477 – Computer Graphics 57
𝑄& 𝑠, 𝑡 = 𝑆𝑀
𝐺D&(𝑡)𝐺*&(𝑡)𝐺'&(𝑡)𝐺E&(𝑡)
𝐺T& 𝑡 = 𝑇𝑀
𝑍TD&𝑍T*&𝑍T'&𝑍TE&
𝐺D& 𝑡𝐺*& 𝑡𝐺'& 𝑡𝐺E& 𝑡
=
𝑍DD& 𝑍DD& 𝑍D'& 𝑍DE&𝑍*D& 𝑍*D& 𝑍*'& 𝑍*E&𝑍'D& 𝑍'D& 𝑍''& 𝑍'E&𝑍ED& 𝑍ED& 𝑍E'& 𝑍EE&
𝑀M𝑇M
Derivation• This gives us:
• Similarly for y and z:
CENG 477 – Computer Graphics 58
𝑄& 𝑠, 𝑡 = 𝑆
𝑚DD 𝑚D* 𝑚D' 𝑚DE𝑚*D 𝑚** 𝑚*' 𝑚*E𝑚'D 𝑚'* 𝑚'' 𝑚'E𝑚ED 𝑚E* 𝑚E' 𝑚EE
𝑍DD& 𝑍DD& 𝑍D'& 𝑍DE&𝑍*D& 𝑍*D& 𝑍*'& 𝑍*E&𝑍'D& 𝑍'D& 𝑍''& 𝑍'E&𝑍ED& 𝑍ED& 𝑍E'& 𝑍EE&
𝑀M𝑇M
𝑀 𝐺&
𝑄. 𝑠, 𝑡 = 𝑆𝑀𝐺.𝑀M𝑇M
𝑄0 𝑠, 𝑡 = 𝑆𝑀𝐺0𝑀M𝑇M
Hermite Surfaces• For Hermite surfaces, 𝑀 is the Hermite basis matrix• The elements of the geometry matrix (𝐺&, 𝐺., 𝐺0) store how
each component changes with respect to t:
CENG 477 – Computer Graphics 59
…𝑃DD = 𝑄(0, 0)
𝑃DE = 𝑄(0, 1)
𝑅DD = 𝑑𝑄(0,0)/𝑑𝑠
𝑅DE = 𝑑𝑄(0,1)/𝑑𝑠
𝑃ED = 𝑄(1, 0)
𝑃EE = 𝑄(1, 1)
𝑅ED = 𝑑𝑄(1, 0)/𝑑𝑠
𝑅EE = 𝑑𝑄(1, 1)/𝑑𝑠
Hermite Surfaces• How the starting point (𝑃D) changes with respect to t:
CENG 477 – Computer Graphics 60
𝐺& =𝑄&(0, 0) 𝑄&(0, 1)
𝑑𝑄&(0, 0)𝑑𝑡
𝑑𝑄&(0, 1)𝑑𝑡… … … …
… … … …… … … …
Hermite Surfaces• How the end point (𝑃E) changes with respect to t:
CENG 477 – Computer Graphics 61
𝐺& =
… … … …
𝑄&(1, 0) 𝑄&(1, 1)𝑑𝑄&(1, 0)
𝑑𝑡𝑑𝑄&(1,1)
𝑑𝑡… … … …… … … …
Hermite Surfaces• How the starting tangent vector (𝑅D), defined with respect to 𝑠,
changes with respect to t:
CENG 477 – Computer Graphics 62
𝐺& =
… … … …… … … …
𝑑𝑄&(0, 0)𝑑𝑠
𝑑𝑄&(0, 1)𝑑𝑠
𝑑*𝑄&(0, 0)𝑑𝑠𝑑𝑡
𝑑*𝑄&(0, 1)𝑑𝑠𝑑𝑡… … … …
Hermite Surfaces• How the ending tangent vector (𝑅E), defined with respect to 𝑠,
changes with respect to t:
CENG 477 – Computer Graphics 63
𝐺& =
… … … …… … … …… … … …
𝑑𝑄&(1, 0)𝑑𝑠
𝑑𝑄&(1, 1)𝑑𝑠
𝑑*𝑄&(1,0)𝑑𝑠𝑑𝑡
𝑑*𝑄&(1, 1)𝑑𝑠𝑑𝑡
Hermite Surfaces• So the entire geometry matrix looks like:
CENG 477 – Computer Graphics 64
𝐺& =
𝑄&(0,0) 𝑄&(0,1)𝑑𝑄&(0, 0)
𝑑𝑡𝑑𝑄&(0, 1)
𝑑𝑡
𝑄&(1,0) 𝑄&(1,1)𝑑𝑄&(1, 0)
𝑑𝑡𝑑𝑄&(1, 1)
𝑑𝑡𝑑𝑄&(0, 0)
𝑑𝑠𝑑𝑄&(0, 1)
𝑑𝑠𝑑*𝑄&(0,0)𝑑𝑠𝑑𝑡
𝑑*𝑄&(0, 1)𝑑𝑠𝑑𝑡
𝑑𝑄&(1, 0)𝑑𝑠
𝑑𝑄&(1, 1)𝑑𝑠
𝑑*𝑄&(1,1)𝑑𝑠𝑑𝑡
𝑑*𝑄&(1, 1)𝑑𝑠𝑑𝑡
Hermite Surfaces
CENG 477 – Computer Graphics 65
𝐺& =
0 5 5 50 5 5 50 0 0 00 0 0 0
𝐺. =
0 0 0 05 5 0 05 5 0 05 5 0 0
𝐺0 =
0 0 5 50 0 5 50 0 0 00 0 0 0
Bezier Surfaces• Remember that Bezier curves was defined using Bernstein
polynomials:
• Their extension to surfaces is straightforward:
CENG 477 – Computer Graphics 66
𝑄 𝑡 = W𝐵T,U 𝑡 𝑃TXD
U
TYZ𝐵T,U 𝑡 = 𝑛𝑖 𝑡T 1 − 𝑡 UKT
𝑄 𝑠, 𝑡 =WW𝐵T,U 𝑠 𝐵T,s 𝑡 𝑃TXD
s
tYZ
U
TYZ
Bezier Surfaces
CENG 477 – Computer Graphics 67
• Similar to a Bezier curve, a Bezier surface interpolates the end points and approximates the interior control points
Bezier Surfaces• Complex models can be created using Bezier surfaces• In such models, the entire surface is composed of multiple
Bezier surfaces, known as patches
CENG 477 – Computer Graphics 68
Gumbo Model
Bezier Surfaces• Such patches allows tessellating a surface at the desired level
of detail depending on viewing distance or other parameters• OpenGL tessellation shaders provide hardware support for this
CENG 477 – Computer Graphics 69