Advanced Computer Graphics: Parametric Curves and Surfaces - PowerPoint PPT Presentation

1 / 46
About This Presentation
Title:

Advanced Computer Graphics: Parametric Curves and Surfaces

Description:

affine transformations can be difficult ... Affine Invariance: ... This is similar to the property that affine transformations preserve straight lines. ... – PowerPoint PPT presentation

Number of Views:764
Avg rating:3.0/5.0
Slides: 47
Provided by: edwin58
Category:

less

Transcript and Presenter's Notes

Title: Advanced Computer Graphics: Parametric Curves and Surfaces


1
Advanced Computer GraphicsParametric Curves and
Surfaces
  • James Gain
  • Department of Computer ScienceUniversity of Cape
    Town
  • jgain_at_cs.uct.ac.za

2
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

3
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.

4
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.

5
Formulations
  • Explicit
  • y and z represented as functions of x
  • 2D line
  • Implicit
  • function relating all coordinates
  • 2D line
  • 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

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

7
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

8
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

9
Basis Functions
  • The degree of the curve is the degree of the
    highest basis function (sum of polynomials is a
    polynomial)
  • There are ordern1 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.

10
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.

11
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.

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.

13
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

14
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.

15
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.

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.

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.

18
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).

19
Hermite Curves
  • Intuitive control two endpoints and end tangent
    vectors
  • Hermite curve equation

20
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.

21
Formula
  • Cubic Hermite Basis

22
Changing length of V0
V0
P1
P0
V1
23
Changing direction of V0
24
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

25
Chaikins 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.

26
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

27
Bézier Curves
  • Discovered independently in the early 70s 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.

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 Pascals triangle (terms are summed from
    above diagonally left and right)

29
Linear and Quadratic Bézier Curves
  • Linear (a line segment)
  • Quadratic

30
Cubic Bézier Curves
  • Cubic

31
Examples
32
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.

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.

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.

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

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.

37
Evaluation
38
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


39
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.

40
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.

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.

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.

43
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

44
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 Chaikins 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.

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.

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.
Write a Comment
User Comments (0)
About PowerShow.com