Graphics Graphics Lab @ Korea University cgvr.korea.ac.kr Introduction to Computer Graphics.
Computer Graphics Geometric Modeling - Webcourse...
Transcript of Computer Graphics Geometric Modeling - Webcourse...
1
Computer Graphics
Copyright 1996 C. Gotsman & G. Elber
Computer Science Dept. Technion
Geometric Modeling
Page 1
Geometric
Modeling
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
2
An Example
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
3
OutlineObjective: Develop methods and algorithms to
mathematically model shapes of real world objects
Categories:
Wire-frame representations
Boundary representations
Primitive based
Freeform based
Meshes & subdivision
Volumetric representations
Freeform based
Voxel Based
Octree Based
Trivariate Functions
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
4
Wire-Frame Representation
Object is represented as as a set of points and edges (a graph)
containing topological information.
Used for fast display in interactive systems.
Can be ambiguous:
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
5
Ambiguity
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
6
Volumetric Representation
Voxel basedSpace subdivided into equal size boxes – each has on/off flag according to if inside/outside object
Scalar values (e.g. density) per voxel are also common
Common in imaging applications (CT,MRI,Ultrasound)
Memory consuming
Extension – Octree (recursive construction).
Advantage: simple and robust Boolean operations, in/out tests, can represent and model the interior of the object.
Disadvantage: memory consuming, non-smooth, time consuming to manipulate.
2
Computer Graphics
Copyright 1996 C. Gotsman & G. Elber
Computer Science Dept. Technion
Geometric Modeling
Page 2
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
7
Display – Iso surfaces
Difficulty to display volumetric content.
Instead we can represent the boundary of the volume,
solving for T(u, v, w) = T0
Marching cubes – examine each individual cube (eight
neighboring voxels) and locally decide the shape of the
iso surface there.
Result is a polygonal approximation of the iso surface.
-3
-3
-3
+3-3
+3
-3
+3
-3
+3
-4
+8+8
+8
-8
-8
T0 = 0
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
8
Constructive Solid Geometry
Use set of volumetric primitives
Box, sphere, cylinder, cone, etc…
For constructing complex objects
use Boolean operations
Union
Intersection
Subtraction
Complement
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
9
CSG Trees
Operations performed
recursively
Final object stored as
sequence (tree) of
operations on
primitives
Common in CAD
packages –
mechanical parts fit well
into primitive based
framework
Can be extended with
free-form primitives
C2
B2
S S C3 2 2
S S B2 1 2
C1
B1
S B C1 1 1
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
10
Freeform Representation
Explicit form: z = z(x, y)
Implicit form: f(x, y, z) = 0
Parametric form: S(u, v) = [x(u, v), y(u, v), z(u, v)]
Example – origin-centered sphere of radius R:
],[],2,0[),sin,cossin,coscos(),,(
0
:
:
22
2222
222222
RRRzyx
Rzyx
yxRzyxRz
:Parametric
Implicit
Explicit
Explicit is a special case of
implicit and parametric form
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
11
A representation of choice
What makes a good representation for
solid modeling?
Ease/Intuitive shape manipulation
Class of representable models
Ease of display and evaluation
Ease of query answering such as inside/outside,
subdivision, interference
Robustness and accuracy
Closure under operations such as Booleans.
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
12
Intuitive Curve Editing
3
Computer Graphics
Copyright 1996 C. Gotsman & G. Elber
Computer Science Dept. Technion
Geometric Modeling
Page 3
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
13
Splines – Free Form Curves
To allow control of curves need description via set of
basis functions + coefficients
Require geometric meaning of coefficients (base)
Approximate/interpolate set of positions, derivatives, etc..
Typically parametric
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
14
Polynomial Bases
Monomial basis {1, x, x2, x3, …}
Coefficients are geometrically
meaningless
Manipulation is not robust
Number of coefficients =
polynomial rank
We seek coefficients with geometrically intuitive meanings
Polynomials are easy to analyze, derivatives remain polynomial,
etc.
Other polynomial bases (with better geometric intuition):
Lagrange (Interpolation scheme)
Hermite (Interpolation scheme)
Bezier (Approximation scheme)
B-Spline (Approximation scheme) Lagrange
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
15
Mathematical Continuity
C1(t) & C2(t), t [0,1] - parametric curves
Level of continuity of the curves at C1(1) and C2(0) is:
C-1: C1(1) C2(0) (discontinuous)
C0: C1(1) = C2(0) (positional continuity)
Ck, k > 0 : continuous up to kth derivative
Continuity of single curve inside its parameter domain is
similarly defined - for polynomial bases it is C
kjCCjj
0),0()1( )(
2
)(
1
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
16
Geometric Continuity
Mathematical continuity is too strong a requirement
May be relaxed to geometric continuity
Gk, k 0 : Same as Ck
Gk, k =1 : C'1(1) = C'2(0)
Gk, k 0 : There is a reparameterization of C1(t) & C2(t), where
the two are Ck
E.g.
C1(t)=[cos(t),sin(t)], t[/2,0]
C2(t)=[cos(t),sin(t)], t[0,/2]
C3(t)=[cos(2t),sin(2t)], t[0,/4]
C1(t) & C2(t) are C1 (& G1) continuous
C1(t) & C3(t) are G1 continuous (not C1)C1
C2, C3
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
17
More on Continuity Consider a set of points {Pi}i=0,n
A piecewise constant interpolant will be C-1
A piecewise linear interpolant will be C0
Polyhedra are usually piecewise linear approximation
of freeform polynomials
Polyhedra are C0 continuous
Higher order polynomials posses better continuity
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
18
Cubic Hermite Basis
The set of polynomials of degree k is a linear vector
space of degree k+1
The canonical, monomial basis for polynomials is
{1, x, x2, x3,…}
Define geometrically-oriented basis for cubic
polynomials
hi,j(t): i, j = 0,1, t[0,1]
Has to
satisfy:
4
Computer Graphics
Copyright 1996 C. Gotsman & G. Elber
Computer Science Dept. Technion
Geometric Modeling
Page 4
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
19
Hermite Cubic Basis (cont’d)
The four cubics which satisfy these conditions are
Obtained by solving four linear equations in four
unknowns for each basis function
Prove: Hermite cubic
polynomials are linearly
independent and form a
basis for cubic
polynomials
)1()()1()(
)32()(1)32()(
2
11
2
10
2
01
2
00
ttthttth
ttthttth
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
20
Hermite Cubic Basis (cont’d)
Lets solve for h00(t) as an example.
h00(t) = a x3 + b x2 + c x + d
must satisfy the following four
constraints:
Four equations and four unknown to solve for.
.230)1('
,0)0('
,0)1(
,1)0(
00
00
00
00
cbah
ch
dcbah
dh
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
21
Hermite Cubic Basis (cont’d)
Let C(t) be a cubic polynomial defined as the linear
combination:
What are C(0), C(1), C’(0), C’(1) ?
Pi
)()()()()( 111100011000 thTthTthPthPtC
Hermite
C(0) = P0, C(1) = P1, C’(0) = T0, C’(1) = T1
To generate a curve through P0 & P1 with slopes T0 &
T1 use
)()()()()( 111100011000 thTthTthPthPtC
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
22
Parametric Splines
So far we solve for a single explicit function C(t)
Cannot represent closed curves such as a circle
Solution: let Pi = (xi, yi) and Ti = (tix, ti
y) be vector
functions
Solve for each individual
axis independently
Here is an example of
four Hermite cubics that
approximate a circle
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
23
Cubic Splines
Standard spline input – set of points {Pi}i=0, n
No derivatives’ specified as input
Can we prescribe derivatives values in order to achieve C2?
Interpolate by n cubic segments (4n DOF):
Derive {Ti}i=0 , n from C2 continuity constraints
Solve 4n equations
1,..,1,)0()1(
:equations) 1( sconstraint continuityC
1,..,1,)0()1(
:equations) 1( sconstraint continuityC
,..,1,)1(,)0(
:equations) (2ion Interpolat
''
1
''
2
'
1
'
1
1
niCC
n
niCC
n
niPCPC
n
ii
ii
iiii
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
24
Cubic Splines Have two degrees of freedom left (to reach 4n DOF)
Options
Natural end conditions: C1''(0) = 0, Cn''(1) = 0
Complete end conditions: C1'(0) = 0, Cn'(1) = 0
Prescribed end conditions (derivatives available at the ends):
C1'(0) = T0, Cn'(1) = Tn
Quadratic end conditions
C1''(0) = C1''(1), Cn''(0) = Cn''(1),
Periodic end conditions
C1'(0) = Cn'(1), C1''(0) = Cn''(1),
Question: What parts of C(t) are affected as a result of
a change in Pi ?
prescribed
natural
5
Computer Graphics
Copyright 1996 C. Gotsman & G. Elber
Computer Science Dept. Technion
Geometric Modeling
Page 5
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
25
The assumption t [0,1] (uniform parameterization)
is arbitrary
Implicitly implies same curve length for each segment
Not natural if points are not equally spaced
One alternative - chord-length parameterization:
Question: Can chord-length parameterization be
used for cubic Hermite splines?
Parameterization
].,0[ :segmentth ' For the
)()( Denote 2
1
2
1
i
y
i
y
i
x
i
x
ii
dti
PPPPd
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
26
Parameterization
Question: What do we need arc/chord length curves for?
Uniform
Chord- length
[0,1]
[0,1]
[0,8]
[0,1]
[0,3]
[0,1]
[0,1]
[0,4]
Lagrange
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
27
Bezier CurvesThe Bezier curve is an approximation
of a given control polygon (a polyline)
Denote by (t): t[0,1]
Bezier curve of degree n is defined over n+1
control points,
{Pi}i=0, n
Have two
formulations
Constructive
Algebraic
P1 P3P5
P1
P2
P0P0 P2P4
)(t
)(t
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
28
De Casteljau Construction
);(:)(
);()()1(:)(
do to:=For
do to1:For
;:)( do to0:For
][
]1[]1[
1
][
]0[
tPt
ttPtPttP
nji
nj
PtPni
n
n
j
i
j
i
j
i
ii
(1/3)
Select t[0,1] value. Then,
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
29
Algebraic Form of Bezier Curves
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
30
6
Computer Graphics
Copyright 1996 C. Gotsman & G. Elber
Computer Science Dept. Technion
Geometric Modeling
Page 6
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
31
Algebraic Form of Bezier Curves
Bezier curve for set of control points {Pi}i=0, n :
where {Bin(t)}i=0, n Bernstein basis of polynomial
of degree n
Here is a
Cubic case
example:
n
i
iin
i
n
ii ttini
nPtBPt
0
n
0=i
)1()!(!
!)( = )(
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
32
Algebraic Form of Bezier Curves
why?
Curve is linear combination of basis functions
Curve is affine combination of control points
n
0=i
]1,0[,1)( ttBn
i
n
i
iin
i ttini
nPt
0
)1()!(!
! = )(
Bezier
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
33
Properties of Bezier Curves (t) is polynomial of degree n
(t) CH(P0,…,Pn)
(0) = P0 and (1) = Pn
'(0) = n(P1P0) and '(1) = n(PnPn-1)
(t) is affine invariant and variation diminishing
(t) is intuitive to control via Pi and it follows the general shape of the control polygon
'(t) is a Bezier curve of one degree less
Questions:What is the shape of a Bezier curve whose control points lie on a line?
How can one connect two Bezier curves with c0 continuity? c1 ? c2 ?
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
34
Bezier Curve Editing
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
35
Some Trivia
Bezier curves introduced nearly
simultaneously by Pierre Bezier at
Renault and Paul De Casteljau at
Citroen (late 60s)
Attributed to Bezier as he was the
first to make the results public
Bezier
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
36
Degree corresponds to number of control points
Global support: change in one control point affects the entire
curve
For large sets of points – curve deviates far from the points
Cannot represent conics exactly. Most noticeably
circles
Can be resolved by introducing a more powerful representation
of rational curves.
As an example, a 90 degrees arc as a rational Bezier curve:
.2where
)()()(
)()()()(
2
1
20
2
22
2
11
2
00
2
222
2
111
2
000
w
ww
tBwtBwtBw
tBPwtBPwtBPw tCP0
=(0,1)
P1=(1,1)
P2 =(1,0)
Drawbacks of Bezier Curves
7
Computer Graphics
Copyright 1996 C. Gotsman & G. Elber
Computer Science Dept. Technion
Geometric Modeling
Page 7
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
37
B-Spline Curves Idea: Generate basis where functions are continuous
across the domains while presenting local support
For each parameter value only a finite set of basis functions is non zero.
The parametric domain is subdivided into sections at
parameter values denoted knots, {i }.
The B-spline functions are then defined over the knots.
The knots are denoted uniform knots if i - i-1 = c,
constant. W.l.o.g.,
assume c = 1.
1
0
)()(n
i
ii tNPtC
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
38
Uniform Cubic B-Spline Curves Definition (uniform knot sequence, i - i-1 = 1):
),[
),[
),[
),[
6/)1(
6/)463(
6/)1333(
6/
)(
),3[,)()(
43
32
21
1
3
2
1
3
23
23
3
3
1
0
3
ii
ii
ii
ii
i
i
i
i
i
n
i
ii
t
t
t
t
tr
tr
tr
tr
r
rr
rrr
r
tN
nttNPt
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
39
Uniform Cubic B-Spline Curves For any t [3, n]:
(prove it!)
For any t [3, n] at most four basis functions are non
zero
Any point on a cubic B-Spline is an affine combination
of at most four control points
1)(1
0
3
n
i
i tN
.)(
)()(
Then, .,Let
3
3
0
3
0
3
1
0
0
3
430
i
ii
n
i
iitt
tNP
tNPt
t
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
40
In general, B-Splines do not interpolate control points
in particular, the uniform cubic B-spline curves do not interpolate
the end points of the curve.
Why is the end points’ interpolation important?
Two ways are common to force endpoint interpolation:
Let P0 = P1 = P2 (same for other end)
Add a new control point (same for other end) P-1 = 2P0 – P1 and a
new basis function N-13(t).
Question:
What is the shape of the curve at the end points if the first
method is used?
What is the derivative vector of the curve at the end points if the
first method is used?
Boundary Conditions for
Cubic B-Spline Curves
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
41
Local Control of B-spline Curves
Control point Pi
affects (t) only for
t(i, i+4)
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
42
Intuitive B-spline Curve Editing
8
Computer Graphics
Copyright 1996 C. Gotsman & G. Elber
Computer Science Dept. Technion
Geometric Modeling
Page 8
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
43
Properties of B-Spline Curves
For n control points, (t) is a piecewise polynomial of
degree 3, defined over t[3, n)
and for specific t = t0?
(t) is affine invariant and variation diminishing
(t) follows the general shape of the control polygon and it is intuitive and ease to control its shape
Questions:What is (i) equal to?
What is '(i) equal to?
What is the continuity of (t) ? Prove it!
4
0
3),..,()(
n
i
ii PPCHt
B-spline
),3[,)()(1
0
3 nttNPtn
i
ii
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
44
From Curves to Surfaces
A curve is expressed as inner product of coefficients
Pi and basis functions
One way of extending curves into surfaces is to treat
surface as a curves of curves. This approach is also
known as tensor product surfaces
Assume Pi is not constant, but are functions of a
second, new parameter v:
n
i
ii uBPuC0
)()(
m
j
jiji vBQvP0
)()(
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
45
From Curves to Surfaces (cont’d)Then
or
Question: What is the difference between u and v?
n
i
i
m
j
jij
n
i
i
m
j
jij
n
i
ii
uBvBQ
uBvBQ
uBPuC
0 0
0 0
0
)()(
)()(
)()(
n
i
i
m
j
jij uBvBQvuS0 0
)()(),( BezPatch
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
46
Intuitive Surface Editing
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
47
Surface constructors
Construction the geometry is a first stage in any
synthetic image synthesis process
There exist a set of high level, simple and intuitive,
surface constructors for novice users:
Bilinear patch
Ruled surface
Boolean sum
Surface of Revolution
Extrusion surface
Surface from curves (skinning)
Swept surface
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
48
Bilinear Patches
Bilinear interpolation of 4 3D points - 2D analog of 1D
linear interpolation between 2 points in the plane
Given P00, P01, P10, P11 the parametric Bilinear surface
for u,v[0,1] is:
Questions:
What does an isoparametric curve of a Bilinear patch look
like ?
Can you represent the Bilinear patch as a Bezier surface?
When is a Bilinear patch planar?
11100100 )1()1()1)(1(),( uvPPvuvPuPvuvuP
9
Computer Graphics
Copyright 1996 C. Gotsman & G. Elber
Computer Science Dept. Technion
Geometric Modeling
Page 9
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
49
Ruled Surfaces
Given two curves a(t) and b(t), the corresponding ruled
surface between them is constructed by
The corresponding points on a(t) and b(t) are connected by
straight lines
Questions:
When is a ruled surface a bilinear patch?
When is a bilinear patch a ruled surface?
S(u, v) = v a(u) + (1-v) b(u)
a(u)b(u)
11100100 )1()1()1)(1(),( uvPPvuvPuPvuvuP
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
50
Boolean Sum
Given four connected curves i i=1,2,3,4, Boolean sum
S(u, v) fills the interior. Let,
Then
)()1()(),(
)()1()(),(
)1(
)1()1)(1(),(
312
201
1110
0100
vuvuvuS
uvuvvuS
uvPPvu
vPuPvuvuP
),(),(),(),( 21 vuPvuSvuSvuS
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
51
Boolean Sum (cont’d)
S(u,v) interpolates the four
i along its boundaries.
For example, consider the
u = 0 boundary:
Question: Must i be coplanar?
)(
)1()()1(
)1()(1)(0)0()1()0(
),0(),0(),0(
),0(
3
010030001
01003120
21
v
vPPvvPvvP
vPPvvvvv
vPvSvS
vS
)()1()(),()()1()(),(
)1()1()1)(1(),(
312201
11100100
vuvuvuSuvuvvuS
uvPPvuvPuPvuvuP
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
52
Surface of Revolution Rotate a, usually planar,
curve around an axis
Consider curve
(t) = (x(t), 0, z(t))
and let Z be the axis of
revolution. Then,
Question: sin and cos are not rational. Can we represent
surfaces of revolution as rational?
).(),(
),sin()(),(
),cos()(),(
uvuz
vuvuy
vuvux
z
x
x
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
53
Extrusion Surface
Extrusion of a, usually
planar, curve along a
linear segment.
Consider curve (t) and
vector
Then
.)(),( VvuvuS
V
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
54
Surface from Curves (Skinning)
An intuitive surface fitting (approximation or
interpolation) scheme
Fit a surface through a set of prescribed curves:
Question: Must the curves be planar? Closed?
10
Computer Graphics
Copyright 1996 C. Gotsman & G. Elber
Computer Science Dept. Technion
Geometric Modeling
Page 10
Geomertic Modeling I - Center for Graphics and Geometric Computing,
Technion
55
Sweep Surface A general surface construction scheme
Rigid motion of one (cross section) curve along another (axis) curve:
The cross section can change as it is swept along
Question: Is an Extrusion as special case of sweep?
Surface of revolution?