Vous êtes sur la page 1sur 8

Computer Graphics Geometric Modeling

An Example

Geometric
Modeling

3 4

Outline Wire-Frame Representation


 Objective: Develop methods and algorithms to
mathematically model shape of real world objects  Object is represented as as a set of points and edges (a graph)
containing topological information.
 Used for fast display in interactive systems.
 Categories:  Can be ambiguous:

Wire-frame representations

Boundary representations

Volumetric representations

5 6

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page


Computer Science - Technion
Computer Graphics Geometric Modeling
Volumetric Representation Constructive Solid Geometry
 Voxel based  Use set of volumetric primitives
 Advantages: simple and robust Boolean operations, Box, sphere, cylinder, cone, etc…
in/out tests, can represent and model the interior of the  For constructing complex objects
object. use Boolean operations
 Disadvantages: memory consuming, non-smooth, Union
difficult to manipulate. Intersection
Subtraction
Complement

7 8

CSG Trees Freeform Representation


 Operations performed  Explicit form: z = z(x, y) Explicit is a special case of
S 3 = S 2 − C2
recursively  Implicit form: f(x, y, z) = 0 implicit and parametric form
 Final object stored as  Parametric form: S(u, v) = [x(u, v), y(u, v), z(u, v)]
sequence (tree) of  Example – origin centered sphere of radius R:
S 2 = S 1 − B2 C2
operations on
primitives
Explicit :
 Common in CAD S1 = B1 + C1
packages – z = + R2 − x2 − y 2 ∪ z = − R2 − x2 − y 2
mechanical parts fit well Implicit :
into primitive based B2 x2 + y 2 + z2 − R2 = 0
framework Parametric :
B1
 Can be extended with ( x, y, z ) = ( R cosθ cosψ , R sin θ cosψ , R sin ψ ),θ ∈ [0,2π ],ψ ∈ [− π2 , π2 ]
C1
free-form primitives
9 10

Parametric Curves Mathematical Continuity


 Analogous to trajectory of particle in space.  C1(t) & C2(t), t ∈ [0,1] - parametric curves
 Single parameter t∈ [T1,T2] – like “time”. (x(t),y(t))  Level of continuity of the curves at C1(1) and C2(0) is:
C-1:C1(1) ≠ C2(0) (discontinuous)
 position = p(t) = (x(t),y(t)), k(t) = 1/r(t)
C0: C1(1) = C2(0) (positional continuity)
r(t)
velocity = v(t) = (x’(t),y’(t)) Ck, k > 0 : continuous up to kth derivative

C1 (1) = C2 (0), 0 ≤ j ≤ k
( j) ( j)

 Circle:
x(t) = cos(t), y(t) = sin(t) t ∈ [0,2π) ||v(t)|| ≡ 1
x(t) = cos(2t), y(t) = sin(2t) t ∈ [0,π) ||v(t)|| ≡ 2
x(t) = (1-t2)/(1+t2), y(t) = 2t/(1+t2) t ∈ (-∞,+∞)

(x(t),y(t))
v(t) = (x’
(x’(t),y’
(t),y’(t))
 Continuity of single curve inside its parameter domain is
similarly defined - for polynomial bases it is C∞
11 12

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page


Computer Science - Technion
Computer Graphics Geometric Modeling
Geometric Continuity Polynomial Bases
 Mathematical continuity is sometimes too strong  Monomial basis {1, x, x2, x3, …}
 May be relaxed to geometric continuity Coefficients are geometrically
(so curves would look the same, but need to change their meaningless
parameterization) Manipulation is not robust
Gk, k ≤ 0 : Same as Ck  Number of coefficients =
Gk, k =1 : C'1(1) =α C'2(0) polynomial rank
Gk, k≥ 0 : There is a reparameterization of C1(t) & C2(t), where  We seek coefficients with geometrically intuitive meanings
the two are Ck
 Polynomials are easy to analyze, derivatives remain polynomial,
 E.g. etc.
C2, C3
C1(t)=[cos(t),sin(t)], t∈[−π/2,0]  Other polynomial bases (with better geometric intuition):
C2(t)=[cos(t),sin(t)], t∈[0,π/2] Lagrange (Interpolation scheme)
C3(t)=[cos(2t),sin(2t)], t∈[0,π/4] Hermite (Interpolation scheme)
C1(t) & C2(t) are C1 (& G1) continuous C1 Bezier (Approximation scheme)
C1(t) & C3(t) are G1 continuous (not C1) B-Spline (Approximation scheme)

13 14

Cubic Hermite Basis Physical Splines


 Set of polynomials of degree k is 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:

15 16

Hermite Cubic Basis Hermite Cubic Basis (cont’d)


 The four cubics which satisfy these conditions are  Lets solve for h00(t) as an example.
 h00(t) = a t3 + b t2 + c t + d
h00 (t ) = t ( 2t − 3) + 1
2
h01 (t ) = −t ( 2t − 3)
2

must satisfy the following four


h10 (t ) = t (t − 1) 2 h11 (t ) = t 2 (t − 1)
constraints:
 Obtained by solving four linear equations in four h00 (0) = 1 = d ,
unknowns for each basis function h00 (1) = 0 = a + b + c + d ,
h00 ' (0) = 0 = c,
 Prove: Hermite cubic h00 ' (1) = 0 = 3a + 2b + c.
polynomials are linearly
independent and form a  Four linear equations in four unknowns.
basis for cubics

17 18

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page


Computer Science - Technion
Computer Graphics Geometric Modeling
Hermite Cubic Basis (cont’d) Parametric Splines
 Let C(t) be a cubic polynomial defined as the linear
i

combination:
C ( t ) = P0 h00 ( t ) + P1h01 ( t ) + T0 h10 ( t ) + T1h11 ( t ) Fit spline independently for x(t) and y(t) to obtain C(t)

 Then C(0) = P0, C(1) = P1, C’(0) = T0, C’(1) = T1

 To generate a curve through P0 & P1 with slopes T0 &


T1, use

C ( t ) = P0h00 (t ) + P1h01 (t ) + T0 h10 (t ) + T1h11 (t )

19 20

Cubic Splines Cubic Splines


 Standard spline input – set of points {Pi}i=0, n  Have two degrees of freedom left (to reach 4n DOF)
No derivatives’ specified as input  Options
Natural end conditions: C1''(0) = 0, Cn''(1) = 0
 Interpolate by n cubic segments (4n DOF):
Complete end conditions: C1'(0) = 0, Cn'(1) = 0
Derive {Ti}i=0,..,n from C2 continuity constraints
Prescribed end conditions (derivatives available at the ends):
Solve 4n linear equations in 4n unknowns C1'(0) = T0, Cn'(1) = Tn
Periodic end conditions natural
C1'(0) = Cn'(1), C1''(0) = Cn''(1),
Interpolation (2n equations):
prescribed
Ci (0) = Pi −1 Ci (1) = Pi i = 1,.., n
C1 continuity constraints ( n − 1 equations):
Ci' (1) = Ci' +1 ( 0) i = 1,.., n − 1
 Question: What parts of C(t) are affected as a result of a change in
C2 continuity constraints ( n − 1 equations): Pi ?
Ci'' (1) = Ci''+1 ( 0) i = 1,.., n − 1

21 22

Bezier Curves De Casteljau Construction


Select t∈[0,1] value. Then,
 Bezier curve is an
approximation of given For i := 0 to n do Pi[ 0 ] (t ) := Pi ;
control points For j :=1 to n do
 Denote by γ (t): t∈[0,1] For i := j to n do
 Bezier curve of degree
n is defined over n+1 P1 P3 P5 P1 Pi[ j ] (t ) := (1 − t ) Pi[−1j −1] (t ) + tPi[ j −1] (t );
control points {Pi}i=0, n
γ (t) γ (t ) := Pn[ n ] (t );
γ (t )
P0 P0 t = 1/3
P2 P4 P2

γ (1/3)
23 24

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page


Computer Science - Technion
Computer Graphics Geometric Modeling
Algebraic Form of Bezier Curves
Bezier curve for set of control points {Pi}i=0, n :
n n
n!
γ (t ) = ∑ Pi Bin (t ) =∑ Pi (1− t )n−i t i
i =0 i =0 i!(n − i)!

where {Bin(t)}i=0, n Bernstein basis of polynomial of


degree n

Cubic case:

25 26

n
n!
γ (t) =∑Pi (1−t)n−i ti
i=0 i!(n−i)!
Algebraic Form of Bezier Curves Properties of Bezier Curves
n  γ (t) is polynomial of degree n
 ∑B
i=0
i
n
(t ) = 1,∀t ∈ [0,1]
 γ (t) is contained in the convex hull CH(P0,…,Pn)
 γ (0) = P0 and γ (1) = Pn
why?
 γ '(0) = n(P1−P0) and γ '(1) = n(Pn−Pn-1)
 Curve is linear combination of basis functions
 γ (t) is affine invariant and variation diminishing
 Curve is affine combination of control points
 γ (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 Bezier curves whose control points lie on
one line?
How can one connect two Bezier curves with C0 continuity? C1
? C2 ?

27 28

Drawbacks of Bezier Curves B-Spline Curves


 Idea: Generate basis where functions are continuous
 Degree corresponds to number of control points
across the domains with local support
Global support: change in one control point affects the entire
curve n −1

For large sets of points – curve deviates far from the points C (t ) = ∑ Pi N i (t )
i =0
 Cannot represent conics exactly. Most noticeably
circles  For each parameter value only a finite set of basis
Can be resolved by introducing a more powerful representation functions is non-zero
of rational curves.  The parametric domain is subdivided into sections at
parameter values called knots, {τi }.
For example, a 90 degrees arc as a rational Bezier curve:

P1 w0 P0 B02 (t ) + w1P1B12 (t ) + w2 P2 B22 (t )  The B-spline functions are then defined over the knots
P0 C (t ) =
w0 B02 (t ) + w1B12 (t ) + w2 B22 (t )  The knots are called uniform knots if τi - τi-1 = c,
=(0,1) =(1,1)

w0 w2 constant. WLOG,
P2 where = 2.
=(1,0) w12 assume c = 1.
29 30

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page


Computer Science - Technion
Computer Graphics Geometric Modeling
Uniform Cubic B-Spline Curves Uniform Cubic B-Spline Curves
 Definition (uniform knot sequence, τi - τi-1 = 1):  For any t ∈ [3, n]:
n −1

n−1 ∑ N i3 ( t ) = 1
γ (t ) = ∑ Pi Ni3 (t ), t ∈[3, n) (prove it!) i=0
i =0
 For any t ∈ [3, n] at most four basis functions are non
 r /6 3
r = t −τ i t ∈[τ i ,τ i +1 )
 zero
  Any point on a cubic B-Spline is a convex combination
(−3r + 3r + 3r + 1) / 6
3 2
r = t −τ i+1 t ∈[τ i +1 ,τ i +2 )
 of at most four control points
Ni3 (t ) = 
 (3r 3 − 6r 2 + 4) / 6

r = t − τ i +2 t ∈[τ i+2 ,τ i +3 ) Let t0 ∈ [τ 3 ,τ 4 ). Then,
 n −1
 (1 − r )3 / 6 r = t − τ i +3 t ∈[τ i+3 ,τ i+4 ) γ (t ) t =t = ∑ Pi Ni3 (t0 )
0
i =0
τ3
= ∑PN
i =τ 3 −3
i
3
i (t0 ).

31 32

Boundary Conditions for Local Control of B-spline Curves


Cubic B-Spline Curves Control point Pi
 B-Splines do not interpolate control points affects γ (t) only for
in particular, the uniform cubic B-spline curves do not interpolate
t∈(τi, τi+4)
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 B-spline
first method is used?
33 34

Properties of B-Spline Curves From Curves to Surfaces


 n −1
γ (t ) = ∑ PN
i=0
i i
3
( t ), t ∈ [ 3, n )  A curve is expressed as inner product of coefficients
Pi and basis functions
 For n control points, γ (t) is a piecewise polynomial of
n
C ( u ) = ∑ Pi Bi ( u )
degree 3, defined over t∈[3, n) i=0
 n −4
γ (t ) ∈ UCH ( Pi ,.., Pi+3 )  Treat surface as a curves of curves. Also known as
i =0 tensor product surfaces
 γ(t) is affine invariant and variation diminishing  Assume Pi is not constant, but are functions of a
 γ(t) follows the general shape of the control polygon and second, new parameter v:
it is intuitive and ease to control its shape
 Questions: m
What is γ (τi) equal to? Pi ( v ) = ∑ Qij B j ( v )
What is γ '(τi) equal to? j =0
What is the continuity of γ (t) ? Prove !
35 36

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page


Computer Science - Technion
Computer Graphics Geometric Modeling
From Curves to Surfaces (cont’d) Surface Constructors
Then
n  Construction of the geometry is a first stage in any
C (u ) = ∑ Pi Bi (u ) image synthesis process
i =0
 Use a set of high level, simple and intuitive, surface
n  m 
= ∑  ∑ Qij B j (v )  Bi (u ) constructors:
i =0  j =0 Bilinear patch

n m
Ruled surface
= ∑∑ Qij B j (v)Bi (u ) Boolean sum
i =0 j =0 Surface of Revolution
Extrusion surface
or n m
S (u , v ) = ∑∑ Qij B j (v )Bi (u )
Surface from curves (skinning)
BezPatch
i =0 j = 0
Swept surface

37 38

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 bilinear surface for u,v∈[0,1] P00 P01
is:
P10
P (u , v ) = (1 − u )(1 − v ) P00 + (1 − u ) vP01 + u (1 − v ) P10 + uvP11

P10 y
 Questions: P11
What does an isoparametric curve of a bilinear patch look
like ?
Can you represent the bilinear patch as a Bezier surface? x
When is a bilinear patch planar?

39 40

Ruled Surfaces
 Given two curves a(t) and b(t), the corresponding
ruled surface between them is:

S(u,v) = v a(u) + (1-v)b(u)

b(u)
a(u)

The corresponding points on a(u) and b(u) are connected by


straight lines
 Questions:
When is a ruled surface a bilinear patch?
When is a bilinear patch a ruled surface?
41 42

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page


Computer Science - Technion
Computer Graphics Geometric Modeling
Surface of Revolution Extrusion
 Rotate a, usually planar,
curve around an axis  Extrusion of a, usually
planar, curve along a
 Consider curve linear segment.
β(t) = (βx(t), 0, βz(t))
and let Z be the axis of  Considerr curve β(t) and
revolution. Then, vector V

x (u , v ) = β x ( u ) cos( v ),  Then
y (u , v ) = β x ( u ) sin( v ), r
S ( u , v ) = β (u ) + v V .
z ( u , v ) = β z (u ).

43 44

Sweep Surface
 Rigid motion of one (cross section) curve along another
(axis) curve:

 The cross section may change as it is swept

Question: Is an extrusion a special case of a sweep?


a surface of revolution?
45

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page


Computer Science - Technion

Vous aimerez peut-être aussi