Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Computer Graphics: Parametric Curves and Surfaces

Similar presentations


Presentation on theme: "Advanced Computer Graphics: Parametric Curves and Surfaces"— Presentation transcript:

1 Advanced Computer Graphics: Parametric Curves and Surfaces
James Gain Department of Computer Science University of Cape Town Advanced Computer GraphicsCollaborative Visual Computing Laboratory

2 Advanced Computer Graphics
Objectives To introduce general concepts associated with all parametric curves To list the desirable properties of a curve formulation To consider the smoothness (continuity) and rendering of curves To derive the Hermite and Power curves 20/09/2018 Advanced Computer Graphics

3 Advanced Computer Graphics
Motivation Representing curves as polylines, and surfaces as a collection of polygons is problematic: requires large amounts of co-ordinate and connectivity information difficult to exactly design smoothly varying shapes Need a compact and easily manipulated high-level representation of smoothly varying curves and surfaces. But must be internally convertible to line segment or polygon approximation for polygon-scan conversion rendering. 20/09/2018 Advanced Computer Graphics

4 Advanced Computer Graphics
Spline A thin flexible wooden slat. Weights (ducks) fix the spline to go through certain points. Stiffness makes the curve smooth but not too wiggly. Features: Controllable Smooth but minimum curvature Þ Can be implemented as parametric polynomial piecewise curves. 20/09/2018 Advanced Computer Graphics

5 Advanced Computer Graphics
Formulations Explicit: y and z represented as functions of x: 2D line: Implicit function relating all coordinates: Weaknesses: may have too many or too few solutions affine transformations can be difficult vertical tangents (with infinite slope) present problems difficult to join separate curves together smoothly Strengths: good for point on curve tests 20/09/2018 Advanced Computer Graphics

6 Parametric Formulation
Express points on the curve in terms of an indirect control parameter, t: Generally, the parameter is clamped, 2D Line: Weaknesses: point on curve tests are difficult Strengths: calculating slope generating points on the curve joining separate curves together easier to apply affine transformations 20/09/2018 Advanced Computer Graphics

7 Advanced Computer Graphics
Polynomials An n-th degree polynomial has the form: Where are the coefficients and are the power terms. The degree, , is the highest power to which is raised. The order is the number of coefficients ( ). Constant: Linear: Quadratic: Cubic: 20/09/2018 Advanced Computer Graphics

8 Advanced Computer Graphics
Polynomial Curves Polynomial curves are represented by a sum of polynomials (basis or blending functions) each weighted by a 2D or 3D coefficient (control points) where the parameter has a restricted range Often represented in the form: Where is a point on the curve, are the control points and are the basis functions. Example: 20/09/2018 Advanced Computer Graphics

9 Advanced Computer Graphics
Basis Functions The degree of the curve is the degree of the highest basis function (sum of polynomials is a polynomial) There are order=n+1 basis functions and control points. For instance, a cubic curve has 4 control points. The contribution of a control point to the curve at position is determined (weighted) by the basis function We would like there to be an intuitive relationship between the control points and the curve. This depends on the choice of basis functions. If successive control points are joined by line segments this is called the control polygon. 20/09/2018 Advanced Computer Graphics

10 Advanced Computer Graphics
Piecewise Curves How do we create interesting and complex curves: Degree raising: Increase the degree of the curve (allows more inflections). Problems: cost of operations on the curve depend on the degree; each control point influences the whole of the curve Piecewise: Join the heads and tails of different curves. Have to make sure that the joins are smooth. 20/09/2018 Advanced Computer Graphics

11 Advanced Computer Graphics
Continuity Geometric continuity ( ) is visually smooth. The derivative vectors agree in direction but not magnitude. Full continuity ( ) is parametrically smooth. The derivative vectors agree in both direction and magnitude. 20/09/2018 Advanced Computer Graphics

12 Choosing degree and continuity
Cubic Degree : High enough degree to be truly 3D and have an inflection point Low enough degree to be efficient Continuity for Modelling: Visual appearance is important so geometric continuity generally sufficient Continuity for Animation: A camera or object follows the curve usually with constant size steps in . The change in speed and/or acceleration along the curve is important so parametric continuity is required. 20/09/2018 Advanced Computer Graphics

13 Advanced Computer Graphics
Exercise: Properties Question: What features are important for a curve representation? Answers: Can guarantee and control levels of continuity Compact to store Efficient to render and interrogate A geometrically intuitive relationship between the control points and the curve Must not oscillate Should be able to represent “all” shapes Easy to transform (scale, rotate, translate) and modify 20/09/2018 Advanced Computer Graphics

14 Advanced Computer Graphics
Properties Endpoint Interpolation: The curve passes through (interpolates) some (or all) of the control points. Affine Invariance: Instead of transforming potentially many individual points on the curve, the control points are transformed. This is similar to the property that affine transformations preserve straight lines. 20/09/2018 Advanced Computer Graphics

15 Advanced Computer Graphics
More Properties Convex Hull Property: The curve never wanders outside the convex hull. This hull is defined as the set of all convex combinations of control points: Variation Diminishing Property: Curves does not oscillate more than its control polygon. In 2D, no straight line can intersect the curve more times than it intersects the control polygon. 20/09/2018 Advanced Computer Graphics

16 Rendering by Evaluation
Task: convert curve to a sequence of line segments Evaluate the curve at intervals. Join the evaluated points. Problems: length of line segments depends on the parametrisation (will be shorter where the magnitude of the derivative is smaller) not the curvature. No guarantee that the curve will appear smooth. 20/09/2018 Advanced Computer Graphics

17 Rendering by Subdivision
Recursively divide the curve in half. If sufficiently flat stop recursion, otherwise subdivide further. Need a means of subdividing and testing “flatness”. Good trade-off between visual quality and number of line segments. 20/09/2018 Advanced Computer Graphics

18 Advanced Computer Graphics
Power Curves Power Basis: Problem: very difficult to predict the shape of the curve from the position of the control points. Solution: use other basis functions (Hermite, Bézier). 20/09/2018 Advanced Computer Graphics

19 Advanced Computer Graphics
Hermite Curves Intuitive control: two endpoints and end tangent vectors Hermite curve equation: V P P 1 V 1 20/09/2018 Advanced Computer Graphics

20 Advanced Computer Graphics
Derivation Each basis function has four unknowns: Basis functions must satisfy the following properties: Use this information to solve for the coefficients of the basis functions. 20/09/2018 Advanced Computer Graphics

21 Advanced Computer Graphics
Formula Cubic Hermite Basis: 20/09/2018 Advanced Computer Graphics

22 Advanced Computer Graphics
Changing length of V0 V0 P1 P0 V1 20/09/2018 Advanced Computer Graphics

23 Changing direction of V0
20/09/2018 Advanced Computer Graphics

24 Advanced Computer Graphics
Properties Limited to cubic curves Curve does not lie within the convex hull of its control points C1 continuity is very easy to enforce (start and end points and vectors are set equal) More popular for animation than modelling 20/09/2018 Advanced Computer Graphics

25 Chaikin’s Corner Cutting
Take a control polygon and cut each edge at the and marks. Join these new points across the corners to create a refined (subdivided) control polygon. This process can be repeated, producing a successively smoother curve. In the limit, a quadratic curve. Note: each control point only influences a local portion of the curve. 20/09/2018 Advanced Computer Graphics

26 Advanced Computer Graphics
Objectives To explore Bézier curves in detail To briefly motivate for B-spline curves To compare and contrast the curve formulations described so far To extend from curves to surfaces To describe the shortcomings of standard surfaces and show how subdivision surfaces avoid them 20/09/2018 Advanced Computer Graphics

27 Advanced Computer Graphics
Bézier Curves Discovered independently in the early 70’s by Bézier and de Casteljau. Both worked in the automobile industry. Bézier curves are popular because there is a clear geometric connection between the control points and the curve: Interpolates the first and last control points: The tangent vectors at the endpoints are aligned with the line segments, and The curve lies in the convex hull of its control points. This is a key difference from Hermite curves. 20/09/2018 Advanced Computer Graphics

28 Bézier (Bernstein) Basis
Binomial coefficient function: Read as choose , it is the number of ways of choosing items from a collection of items. The binomial coefficients can be quickly derived using Pascal’s triangle (terms are summed from above diagonally left and right): 20/09/2018 Advanced Computer Graphics

29 Linear and Quadratic Bézier Curves
Linear (a line segment): Quadratic: 20/09/2018 Advanced Computer Graphics

30 Advanced Computer Graphics
Cubic Bézier Curves Cubic: 20/09/2018 Advanced Computer Graphics

31 Advanced Computer Graphics
Examples 20/09/2018 Advanced Computer Graphics

32 Advanced Computer Graphics
Properties Endpoint interpolation Convex Hull Curve is an affine combination of the control points and so lies inside the convex hull. Affine Invariance An affine transformation of the control points is the same as transforming the curve (not true of perspective projection). Linear Precision A high degree Bézier curve can be forced into a straight line segment by placing the control points on a straight line. Variation Diminishing The curve does not oscillate unduly. 20/09/2018 Advanced Computer Graphics

33 Exercise: Bézier Circles
Question: Create a single closed cubic Bézier curve that approximates a circle. Answer: (a) Closed curve (b) continuous at (c) All control points are collinear which implies, by the convex hull property, that (d) This is a point not a circle. 20/09/2018 Advanced Computer Graphics

34 The de Casteljau Algorithm
A recursive in-betweening (linear interpolation) process which can be used to: Generate a point on the curve (the alternative is to evaluate the Bézier curve equation). Split a Bézier curve into two halves. Working from the initial control polygon (the line segments joining adjacent control points): a point is placed of the way along each edge. These points are joined into a new control polygon. The process is repeated until only a single point is introduced. This is the point at parameter on the curve. 20/09/2018 Advanced Computer Graphics

35 de Casteljau Specifics
The recurrence relation is: Where are the original control points and is the point on the curve. The intermediate control points constitute two Bézier curves split from the original at : 20/09/2018 Advanced Computer Graphics

36 The Problem of Local Control
Bézier curves are geometrically intuitive but they fail to provide local control. A designer cannot concentrate on altering part of a Bézier curve without affecting the rest. This is because the basis functions, which define the weight (influence) given to each control point, are all non-zero over So, each control point has some influence over the shape of the whole curve. Solution: build a curve by piecing together polynomial segments. This is the purpose behind B-spline curves. 20/09/2018 Advanced Computer Graphics

37 Advanced Computer Graphics
Evaluation Power Hermite Bézier B-spline Some Interpolation Convex Hull Easy Subdivision Easily Achievable Continuity (cubics) C1 C2 Variable Degree 20/09/2018 Advanced Computer Graphics

38 Advanced Computer Graphics
Surfaces Curves generalise to Surfaces: A surface is a function of two variables rather than just one A rectangular surface has a curve running along each of its four edges. A rectangular surface can be envisioned as a curve which changes its shape as it is swept through space. Each control point of the initial curve is moved along a path which is itself a curve. Surface Definition: An -degree by -degree Bézier patch is defined by control points : 20/09/2018 Advanced Computer Graphics

39 Advanced Computer Graphics
Surface Properties Adjacent control points can be connected to form a control net (which serves the same purpose as a control polygon). The degrees along and do not have to match. B-spline surfaces are a similar extension of B-spline curves. Continuity between patches: C0: continuous in position. The four edge c.p. must match. C1: continuous in position and tangent vector. The two control points on either side of each edge c.p. must be colinear with the edge point and each other and be equidistant from the edge point. Algorithms (e.g. de Casteljau subdivision) and properties (e.g. convex hull) still apply with some small modification. 20/09/2018 Advanced Computer Graphics

40 Advanced Computer Graphics
Example Surfaces Example: cubic Bézier patch The four corner c.p. are interpolated. Each edge is a curve defined by four c.p. There are four interior c.p. determining the inner shape. 20/09/2018 Advanced Computer Graphics

41 Exercise: Designing Surfaces
Question: Specify the control points of an open-ended continuous cylinder with radius and height composed of two patches. You need only create one patch and explain how the other follows. 20/09/2018 Advanced Computer Graphics

42 Rendering Bézier Surfaces
Adaptive Subdivision: Approximate the surface with planar polygons, Check if a quadrilateral with corners at the endpoints is an adequate approximation to the surface. If so, halt recursion. If not, subdivide into two smaller Bézier patches using bi-parametric de Casteljau. Subdivision must alternate in and on successive recursive subdivisions. Need to specify a tolerance for when the quadrilateral is an adequate approximation. The set of resulting (non-planar) quadrilaterals is further subdivided into (planar) triangles. 20/09/2018 Advanced Computer Graphics

43 Advanced Computer Graphics
Surface Normals Often require a surface normal (e.g. Gouraud and Phong shading) Procedure: Given a surface Calculate the partial derivatives and These are tangents to the surface. Take the cross product to get the normal Scale the normal so that it is a unit vector: 20/09/2018 Advanced Computer Graphics

44 Advanced Computer Graphics
Subdivision Surfaces Motivation: Creating objects from Bézier patches is very difficult if they have a non-planar topology. For instance a C1 sphere cannot be constructed from non-degenerate patches. But complex topologies and many-sided patches are possible with subdivision surfaces, Method: Similar to Chaikin’s corner cutting. Start with a closed control net roughly approximating the object. Successively refine the control net by introducing new c.p.. In the limit this produces a smooth surface. Proviso: There may be exception points where continuity is not as high. 20/09/2018 Advanced Computer Graphics

45 Doo-Sabin Subdivision
Mostly produces a quadratic B-spline surface. Algorithm: Input: an arbitrary open or closed polyhedron; Output: a smooth surface. Refinement: Find the centroid of each face (average its vertices). Find the midpoints of all straight lines connecting the centroid to its defining vertices. Construct a new polyhedron from these midpoints by forming: E-faces. For a given edge there are four midpoints controlled by its endpoints. Connect these midpoints into a rectangle. V-faces. Form a face with the midpoints that surround an original vertex. F-faces. Connect the midpoints belonging to the same face. 20/09/2018 Advanced Computer Graphics

46 Curves and Surfaces in OpenGL
use Evaluators to compute points on a curve or surface. A very powerful mechanism. setup: glMaplf(type, u_min, u_max, stride, order, point_array); example: glMaplf(GL_MAP_VERTEX_3, 0.0, 1.0, ?, 4, data); enable: glEnable(type); rendering: glEvalCoordlf(u); replaces glVertex Similar calls for creating surfaces. Find out about stride! 20/09/2018 Advanced Computer Graphics


Download ppt "Advanced Computer Graphics: Parametric Curves and Surfaces"

Similar presentations


Ads by Google