Computing & Information Sciences Kansas State University Lecture 31 of 42CIS 636/736: (Introduction...
Transcript of Computing & Information Sciences Kansas State University Lecture 31 of 42CIS 636/736: (Introduction...
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Lecture 32 of 42
Wednesday, 11 April 2008
William H. Hsu
Department of Computing and Information Sciences, KSU
KSOL course pages: http://snipurl.com/1y5gc
Course web site: http://www.kddresearch.org/Courses/CIS636
Instructor home page: http://www.cis.ksu.edu/~bhsu
Readings:
Sections 12.2 – 12.5, 12.7, Eberly 2e – see http://snurl.com/1ye72
No class Friday, 18 Apr 2008 (lab next Monday)
Surfaces 2: Bicubic Surfaces
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Surface ModellingSurface Modelling
© 2007 McCaul, B., City University Dublin
CA433 Computer Graphics I
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Many real-world objects are inherently smooth, therefore need infinitely many points to model it. This is not feasible for a computer with finite storage. More often we merely approximate the object with pieces of planes, spheres, or other shapes that are easy to describe mathematically. We will introduce two most common representations for 3D surfaces: polygon mesh surfaces and parametric surfaces. We will also discuss parametric curves since parametric surfaces are a generalisation of the curves.
Modelling the Elegant Teapot
© 2007 McCaul, B., City University Dublin
CA433 Computer Graphics I
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Polygon Meshes
VERTEX TABLE
V1: x1, y1, z1
V2: x2, y2, z2
V3: x3, y3, z3
V4: x4, y4, z4
V5: x5, y5, z5
EDGE TABLE
E1: V1, V2
E2: V2, V3
E3: V3, V1
E4: V3, V4
E5: V4, V5
E6: V5, V1
POLYGON TABLE
P1: V1, V2 , V3
P2: V1 , V3 , V4 , V5
POLYGON TABLE
P1: E1, E2 , E3
P2: E3 , E4 , E5 , E6
or
E1
E2
E3
E5E4
E6
V2
V3
V4
V5
V1
P1 P2
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
The geometry can be stored as three tables: a vertex table, an edge table, and a polygon table. Each entry in the vertex table is a list of coordinates defining that point. Each entry in the edge table consists of a pointer to each endpoint of that edge. And the entries in the polygon table define a polygon by providing pointers to the edges that make up the polygon.
We can eliminate the edge table by letting the polygon table reference the vertices directly, but we can run into problems, such as drawing some edges twice, because we don't realise that we have visited the same set of points before, in a different polygon. We could go even further and eliminate the vertex table by listing all the coordinates explicitly in the polygon table, but this wastes space because the same points appear in the polygon table several times.
Polygon Meshes
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Representing Polygon Meshes
1). The explicit way: just list 3D vertices of each polygon in a certain order. The problems are, firstly it represents same vertex many times and secondly, no explicit representation of shared edges and vertices
2). Pointer to a vertex list: store all vertices once into a numbered list, and represent each polygon by its vertices. It saves space (vertex only listed once) but still has no explicit representation of shared edges and vertices
3). Explicit edges: list all edges that belong to a polygon, and for each edge list the vertices that define it along with the polygons of which it is a member.
)),,(),...,,,(),,,(( 222111 nnn zyxzyxzyxP
)5,4,3,1(P
),,( 121 PVVE
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Types of Curves
1). Explicit:
In the Cartesian plane, an explicit equation of a planar curve is given by y = f(x). The difficulties with this approach are that (1) it is impossible to get multiple values of y for a single x, so curves such as circles and ellipses must be represented by multiple curve segments; and (2) describing curves with vertical tangents is difficult and numerically unstable.
2). Implicit:
f(x, y) = 0 Ax+By+C =0
This method has difficulties on determining tangent continuity of two given curves which is crucial in many applications.
(Circle can be defined as: x2+y2=1, but what about a half circle?)
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Types of Curves
3). Parametric Curves:
The cubic polynomials that defines a curve segment Q(t)= [x(t) y(t)]T are of the form
Written in matrix form, it becomes
Q(t)= [x(t) y(t)] = T C
where
yyyy
xxxx
dtctbtaty
dtctbtatx
23
23
)(
)(
x
y
y
y
y
x
x
x
d
c
b
a
d
c
b
a
C 123 tttT
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Parametric Bicubic Surfaces
The equations that describe a parametric curve depend on a variable t that is not explicitly part of the geometry.
By sweeping through t, in our case 0 ≤ t ≤ 1, it is possible to evaluate the equations and determine the x and y values for points on the curve.
)(
)(
tgy
tfx
t = 0.0
t = 1.0
t
Parameter space Object space
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Parametric Bicubic Surfaces
Parametric Bicubic Surfaces are a generalisation of parametric cubic curves
1010)]()()([)( vuu, v, zu, v, yu, vx u, vP
• If one parameter, say v, is held at a constant value then the above will represent a curve. • The surface is then generated by sweeping all points on the boundary curve P(u,0) (say) through cubic trajectories, defined using the parameter v, to the boundary curve P(u,1).
v=0u=0
u=1
v=1
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
The representation of the bicubic surface patch can be illustrated by considering the Bézier Surface Patch. The edge P(0,v) of a Bezier patch is defined by giving four control points P00, P01, P02 and P03. Similarly the opposite edge P(1,v) can be represented by a Bezier curve with four control points. The surface patch is generated by sweeping the curve P(0,v) through a cubic trajectory in the parameter u to P(1,v). To define this trajectory we need four control points, hence the Bezier surface patch requires a mesh of 44 control points as illustrated below.
Bézier Surface Patch
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Further reading…Further reading…
Chapter 11 of Foley and VanDam Representing Curves and Surfaces
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Surfaces – a Simple ExtensionSurfaces – a Simple Extension
Easy to generalise from cubic curves to bicubic surfaces. Surfaces defined by parametric equations of two variables, s and t. ie. a surface is approximated by a series of crossing parametric cubic
curves Result is a polygon mesh and decreasing step size in s and t will give a
mesh of small near-planar quadrilateral patches and more accuracy.
1010 tands
© 2007 Hawick, K. Massey University (New Zealand)
159.235 Graphics and Graphical Programming
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Example Bézier surfaceExample Bézier surface
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Control of Surface ShapeControl of Surface Shape
Control is now a 2D array of control points. The two parameter surface function, forming the tensor product with the
blending functions is:
Use appropriate blending functions for Bézier and B-Spline surface functions.
Convex Hull property is preserved since bicubic is still a weighted sum (1).
),(),(
)()(),(
tsZandtsYforsimilarly
qtfsftsX ijjij
i
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Bézier ExampleBézier Example
Matrix formulation is as follows:
coordszofarrayisq
tMqMstsz
coordsyofarrayisq
tMqMstsy
coordsxofarrayisq
tMqMstsx
z
TBzB
T
y
TByB
T
x
TBxB
T
44
....),(
44
....),(
44
....),(
Substitute suitable values for s and t (20 in the above ex.)
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
B-Spline SurfacesB-Spline Surfaces
Break surface into 4-sided patches choosing suitable values for s and t. Points on any external edges must be multiple knots of multiplicity k. Lot more work than Bézier. There are other types of spline systems and NURBS modelling packages are
available to make the work much easier. Use polygon packages for display, hidden-surface removal and rendering.
(Bézier too)
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Continuity of Bicubic PatchesContinuity of Bicubic Patches
Hermite and Bézier patches C0 continuity by sharing 4 control points between patches. C1 continuity when both sets of control points either side of the edge
are collinear with the edge. B-Spline patch.
C2 continuity between patches.
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Displaying Bicubic PatchesDisplaying Bicubic Patches
Can calculate surface normals to bicubic surfaces by vector cross product of the 2 tangent vectors.
Normal is expensive to compute Formulation of normal is a biquintic (two-variable,fifth-degree) polynomial.
Display. Can use brute-force method – very expensive ! Forward differencing method very attractive.
Computing & Information SciencesKansas State University
Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics
Curves & Surfaces II - SummaryCurves & Surfaces II - Summary
Bezier Curves Bicubic patches
Acknowledgments - thanks to Eric McKenzie, Edinburgh, from whose Graphics Course some of these slides were adapted.