Download presentation
Presentation is loading. Please wait.
1
3D Modeling, Graphics, and Animation
J. Rossignac CS4451&CS6491 11/27/2018 Curves and surfaces 4451 3D Modeling, Graphics, and Animation Prof. Jarek Rossignac College of Computing Georgia Institute of Technology 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002 Subdivision of curves & surfaces
2
Jarek Rossignac, CoC, GT, ©Copyright 2002
Lecture Objectives Learn (by heart) the Split&Tweak and the 4-point subdivision rules for polygons Be able to discuss their advantages and drawbacks Be able to design a trivial algorithm for these schemes Understand how to construct good bounds (in 2D and in 3D) around the final curve from one of its approximations Understand how to use these subdivisions to define tessellations (quads or triangles) of smooth surfaces in 3D Be able to design the surface subdivision schemes Understand the benefits of having a parametric polynomial form for the curves and surfaces 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
3
Jarek Rossignac, CoC, GT, ©Copyright 2002
Motivation Smooth curves and surfaces are used for aesthetic, manufacturing, and analysis applications where discontinuities due to triangulated approximations would create misleading artifacts. Designers like to specify such curves by adjusting a control polygon with only a few vertices How to go from a crude control polygon (black) to a smooth curve (red)? Suggestions? 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
4
Split&tweak B-spline subdivision
Given a control polygon, for example (a,b,c,d), repeat the following sequence of two steps, until all consecutive 4-tuples of control points are nearly co-linear. 1. “Split”: insert a new control point in the middle of each edge (2,4,6,8) 2. “Tweak”: move the old control points half-way towards the average of their new neighbors (1,3,5,7) The control polygon converges rapidly to a smooth curve, which happens to be a cubic B-spline curve. a 2 b 4 c 6 d 8 1 3 5 7 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
5
My first Split&Tweak in Scheme
(define w 200) (define s 10) (define (draw-p-to-p p1 p2 col) (draw-solid-line (make-posn (+ (* (/ w s) (posn-x p1)) w) (- w (* (/ w s) (posn-y p1)))) (make-posn (+ (* (/ w s) (posn-x p2)) w) (- w (* (/ w s) (posn-y p2)))) col)) (define (draw-port col) (begin (start (* 2 w) (* 2 w)) )) (define (last w)(cond [ (empty? (rest w)) (first w)][else (last (rest w))] )) (define (mid a b) (make-posn (/ (+ (posn-x a) (posn-x b)) 2) (/ (+ (posn-y a) (posn-y b)) 2))) (define (refine q r) (cond [(empty? (rest q)) (cons (first q) (cons (mid (first r) (first q)) empty))] [true (cons (first q) (cons (mid (first q) (first (rest q))) (refine (rest q) r))) ])) (define (subdivide q n color) (cond [(= n 0) (draws q color)] [else (subdivide (tweaks (tweakh (refine q q ))) (- n 1) color)])) (define (tweaks q) (cons (first q) (tweak (rest q)))) (define (tweak q) (cond [(or (empty? (rest q)) (empty? (rest (rest q)))) q] [else (cons (first q) (cons (mid (first (rest q)) (mid (first q) (first (rest (rest q))) ) (tweak (rest (rest q) ))) )] )) (define (tweakh r) (cons (mid (first r) (mid (first (rest r)) (last r))) (rest r))) (define (draws q color) (draw q q color)) (define (draw q r color) (cond [(empty? (rest q)) (draw-p-to-p (first r) (last r) color) ] [else (and (draw-p-to-p (first q) (first (rest q)) color) (draw (rest q) r color) )])) (define p (list (make-posn -8 8) (make-posn 8 8) (make-posn 8 -8) )) (draw-port 'yellow) (draws p 'black) (subdivide p 1 'red) (subdivide p 2 'green) (subdivide p 4 'blue) 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
6
Examples from my Split&Tweak program
11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
7
Yang’s version in MatLab
function result = Sub_divide (P, color, width); [m, N] = size (P); P = [P, P(:,1)]; % make it closed loop result = zeros (m, 2*N); even = [2:2:2*N]; odd = [1:2:2*N-1];prev = [1:N]; next = [2:N+1]; result(:,even) = 0.5 * (P(:,prev) + P(:,next)); prev = [2*N, 2:2:2*N-2]; next = [2:2:2*N]; result(:,odd) = 0.5 * (result(:,prev) + result(:,next)); result(:,odd) = 0.5 * (result(:,odd) + P(:,1:N)); 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
8
Implement your own version
Try for the most elegant and shortest (not the fastest) Start with an array V of n vertices of a closed polygon P in 2D Write a procedure SHOW(V) that renders P Make another array M of n midpoints of edges of P Make a third array A, where each vertex of V is moved by 1/4 towards its neighbors in V Display the polygons of V, M and A to verify your program Make an array S of 2n vertices by interleaving A and M {A[0],M[0],A[1],M[1],A[2],M[2]…A[n],M[n]} Display polygon of S and of V in different colors to check Make a procedure BSPLINE(V) that takes V and returns S SHOW(BSPLINE(BSPLINE(BSPINE(V))))… 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
9
Jarek Rossignac, CoC, GT, ©Copyright 2002
Inspiration Check previous year projects with examples and sourcew code 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
10
Can the limit curve self-intersect?
Can it self-intersect when P does not? 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
11
Where do the control vertices converge to?
The original control vertex b converges to b’=(a+4b+c)/6 The tangent at b’ to the B-spline curve is parallel to ac b b’ c a 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
12
Local control for B-spline curves
Trace the original vertices during subdivision Do they move along straight lines? They subdivide the final curve into spans Each span is influenced by 4 control vertices Each control vertex influences 4 spans Each span converges to a cubic Bezier curve The coordinates of C(t) are cubic polynomials in t b’ a b d e d’ 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
13
Each span is a cubic polynomial
A polynomial formulation is available for each span C(t)= B0(t)P0+ B1(t)P1+ B2(t)P2+ B3(t)P3 Bi are cubic polynomials in t Pi are control points easily derived from a, b, d, e b P1 P0 c a b’ a b d e d’ 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
14
Jarek Rossignac, CoC, GT, ©Copyright 2002
Convex hull Each span lies in the convex hull of 4 original vertices The two from which its end-points evolved Their immediate neighbors on each side The convex hull of 4 points in 3D? A tetrahedron The convex hull of 4 points in 2D? Covered by 3 triangles: ABD, ABE, BDE B’ A B D E D’ 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
15
How can we use the convex hull property?
Display uncertainty (region guaranteed to contain the limit curve) Shade triangles (in 2D) or tetrahedra (in 3D) Decide when to stop the subdivision All triangles or tetrahedra are nearly linear Quickly decide when two B-spline curves in 2D are not intersecting The convex hulls do not overlap 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
16
Jarek Rossignac, CoC, GT, ©Copyright 2002
Open curves If you want to subdivide an open polygon Trace the original vertices through the subdivision process They split the curve into spans (bent versions of the original edges) v0 should not influence the head (beginning of the curve) vn–1 should not influence the tail (end) v0 v1 v2 vn-2 vn-1 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
17
Jarek Rossignac, CoC, GT, ©Copyright 2002
4-point subdivision The B-spline subdivision produces a curve that does not interpolate the vertices of the original polygon P To obtain an interpolating subdivision rule, we must leave the original vertices of P where they are, and thus must displace the mid-points. By how much? C(t)=at3+bt2+ct+d, and thus C(0)=d A=C(-3)=-27a+9b-3c+d B=C(-1)=-a+b-c+d D=C(1)=a+b+c+d E=C(3)=27a+9b+3c+d D=M+(M-M’)/8, with 2M=B+D and 2M’=A+E Offset is 1/8 of ||MM’|| C(0) C(-1) C(1) B M D C(-3) C(3) A M’ E 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
18
Implement your own 4-point subdivision
Start with an array V of n vertices of a closed polygon P in 2D Make another array M of n midpoints of edges of P Make a third array A, where each vertex of M is moved by 1/4 away from its neighbors in M Display the polygons of V, M and A to verify your program Make an array S of 2n vertices by interleaving V and A {V[0],A[0],V[1],A[1],…V[n],A[n]} Display polygon of S and of V in different colors to check. Make a procedure FOURPTS(V) that takes V and returns S SHOW(FOURPTS(FOURPTS(FOURPTS(V))))… 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
19
Compare both approaches
Which one interpolates the original vertices? Which one produces the smoothest curve? When is this important? Can both have cusps (non smooth points)? How can you force the B-spline curve to go through a point? Which one has a convex-hull property? 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
20
Cubic B-spline and four-points
From James Koch 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
21
Jarek Rossignac, CoC, GT, ©Copyright 2002
Which one is smoother? By Stevie Strickland 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
22
Making a sharp corner in a B-spline curve
By Stevie Strickland 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
23
Jarek Rossignac, CoC, GT, ©Copyright 2002
A compromise B-spline subdivision rounds the corners and thus shrinks a convex shape 4-points subdivision bulges the edges out and hence grows a convex shape Both produce curves that are relatively far from the initial control polygon We may want a compromise Closer to the polygon Bulging less Cuttling less 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
24
Jarek Rossignac, CoC, GT, ©Copyright 2002
Jarek’s subdivision Split each edge as before (in both schemes) Tweak old vertices by half of the B-spline displacement and the new vertices by half of the 4-point displacement 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
25
Jarek’s subdivision curve
Bezier Jarek 4-points 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
26
Jarek Rossignac, CoC, GT, ©Copyright 2002
Implementing Jarek’s subdivision 1 - For each vertex vi, compute the average ai of its neighbors and store a displacement vector Di=(ai–vi)/8. 2 - For each edge (vi,vi+1), insert a new vertex mi=(vi+vi+1)/2, and displace it by –(Di+Di+1)/2. 3 - Displace each old vertex vi by Di. 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
27
Three subdivision schemes
B-spline (uniform cubic B-spline), most popular: Introduces new vertices at edge mid-points (split) Tucks in the old vertices by 1/2 the displacement towards the average of their new neighbors (tweak) Very smooth result: piecewise cubic parametric formulation Does not interpolate the original vertices Shrinks convex regions 4-points: Leaves the old vertices unchanged Bulges the edges by displacing their mid-point away from the average of the neighbors (split & tweak) Interpolates the original vertices Grows convex regions Jarek Combines half of the tweaks of the other two Final curve is closer to the original polygon 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
28
Jarek Rossignac, CoC, GT, ©Copyright 2002
What about curves in 3D? Nothing was said about the dimension of the space. The procedures work for any dimension and in any space. You can apply the subdivision to the x coordinates first, then to the y coordinates, then to the z, or to the 3D points. 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
29
Jarek Rossignac, CoC, GT, ©Copyright 2002
Draw a surface Take m polygons of n vertices each. Subdivide each one k times: to get m polygons of n2k vertices Transpose: make n2k new polygons of m vertices each: The first one is made of the first vertices of each one of the m polygons The second one is made of the second vertices of the m polygons… Subdivide each one of the n2k new polygons k times: to get n2k polygons of m2k vertices each Draw each polygon Transpose again transpose … subdivide transpose subdivide 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
30
Example of a B-spine subdivision
By James Koch (notice that the surface does not even go through the control loops 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
31
Example of a four-point subdivision
By Justin Kennedy 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
32
Example of a mixed subdivision
By Jesse Shieh 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
33
B-spline, 4-points and mixed
11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
34
How to produce a tessellation of the surface
Perform the subdivide-transpose-subdivide-transpose Capture all quads, each bounded by four edge produced by the previous process. Display them as quads or triangulate each one 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
35
Four-point torus from 3 triangles
By Ignacio Llamas 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
36
More complex torus with normals
By Peter Presti 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
37
Jarek Rossignac, CoC, GT, ©Copyright 2002
What you must remember Names and subdivision rules for all 3 schemes How to implement them How to compute the convex hull for B-spline spans How to generate 3D surfaces by using these schemes 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
38
Examples of simple questions for quiz
Name the three curve subdivision schemes discussed in class? What are the two steps of the cubic B-spline subdivision? Does a B-spline subdivision interpolate the original vertices? What is the difference between the implementations of the B-spline and the 4-point subdivision schemes? What is a span in a polygon produced by B-spline subdivision. Provide a formulation of a pointset that contains such a span. Provide a detailed pseudocode for Jarek’s subdivision scheme. Explain how you can use the curve subdivision to produce surfaces. 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
39
Research questions to think about
Jarek’s subdivision is a 50/50 compromise between the B-spline and the 4-point schemes. How would you implement a t/(1-t) compromise? Design a simple algorithm that would implement any of the split&tweak subdivisions step in a single pass over the vertices. (You may keep a small buffer of the last few vertices, but assume no random access.) Suppose that you move a single vertex of the original control polygon. How many spans of the final curve are affected? Is the answer the same for all three subdivision schemes? Are these two formulations of Jarek’s subdivision equivalent? Tweak old vertices by half of the B-spline displacement and the new vertices by half of the 4-point displacement For each vertex vi, compute the average ai of its neighbors and store a displacement vector Di=(ai–vi)/8. Then, for each edge (vi,vi+1), insert a new vertex mi=(vi+vi+1)/2, and displace it by –(Di+Di+1)/2. Finally, displace each old vertex vi by Di. 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
40
Jarek Rossignac, CoC, GT, ©Copyright 2002
Project 1 In pairs. Design & program together! Report individually. January 13: Phase 1A (making and drawing polygons) Create/draw/save polygons in 2D using OpenGL January 20: Phase 1B (split&tweak subdivision) Implement a weighted average of B-spline and 4-points January 27: Phase 1C (Studies span of control, area change) See how much of the curve is affected by moving one vertex Compute change in area change between the original and the three subdivision curves February 3: Phase 1D (simplification and error measure) Explore different criteria for deleting vertices in simplification Measure the resulting error Start with previous year projects (source code and discussions): Most of the grade is in the report, not the code! Plan your work: sequence, testing, figures 11/27/2018 Jarek Rossignac, CoC, GT, ©Copyright 2002
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.