3d graphics for game programming (j. han) chapter vi parametric curves and surfaces

28
Graphics for Game Programming (J. Han) Chapter VI Chapter VI Parametric Curves and Surfaces Parametric Curves and Surfaces

Upload: felicia-george

Post on 03-Jan-2016

226 views

Category:

Documents


2 download

TRANSCRIPT

3D Graphics for Game Programming (J. Han)

Chapter VIChapter VIParametric Curves and SurfacesParametric Curves and Surfaces

3D Graphics for Game Programming (J. Han)

Line SegmentLine Segment

Recall that in Chapter 3, a ray defined by the start point and the direction vector is represented in a parametric equation.

Now consider a line segment between two end points, p0 and p1. The vector connecting p0 and p1, p1-p0, corresponds to the direction vector, and therefore the line segment can be represented in the following parametric equation:

6-22

p0

p1p1-p0

p(t)=p0+t(p1-p0)

=(1-t)p0+tp1

3D Graphics for Game Programming (J. Han)

Line Segment (cont’d)Line Segment (cont’d)

A line segment connecting two end points is represented as a linear interpolation of the points.

The line segment may be considered as being divided into two parts by p(t), and the weight for an end point is proportional to the length of the part “on the opposite side,” i.e., the weights for p0 and p1 are (1-t) and t, respectively.

6-33

[from Wikipedia]

3D Graphics for Game Programming (J. Han)

Quadratic Bézier CurveQuadratic Bézier Curve

de Casteljau algorithm = recursive linear interpolations for defining a curve The quadratic Bézier curve interpolates the end points, p0 and p2, and is pulled

toward p1, but does not interpolate it.

6-44

[from Wikipedia]

3D Graphics for Game Programming (J. Han)

Cubic Bézier CurveCubic Bézier Curve

The cubic Bézier curve interpolates the end points, p0 and p3, and is pulled toward p1 and p2.

6-55

[from Wikipedia]

3D Graphics for Game Programming (J. Han)

Quartic Bézier CurveQuartic Bézier Curve

The de Casteljau algorithm can be applied for a higher-degree Bézier curve. For example, a quartic (degree-4) Bézier curve can be constructed using five points.

Such higher-degree curves often reveal undesired wiggles. Worse still, they do not bring significant advantages. In contrast, quadratic curves have little flexibility. Therefore, cubic Bézier curves are most popularly used in the graphics field.

6-66

[from Wikipedia]

3D Graphics for Game Programming (J. Han)

Bézier Curve – Control Points and Bernstein PolynomialsBézier Curve – Control Points and Bernstein Polynomials

The points pis are called control points. A degree-n Bézier curve requires (n+1) control points. The coefficients associated with the control point are polynomials of parameter t, and are named Bernstein polynomials.

6-77

3D Graphics for Game Programming (J. Han)

Bézier Curve – Control Point OrderBézier Curve – Control Point Order

Different orders of the control points produce different curves.

6-88

3D Graphics for Game Programming (J. Han)

Bézier Curve – Tessellation for RenderingBézier Curve – Tessellation for Rendering

The typical method to display a Bézier curve is to approximate it using a series of line segments. This process is often called tessellation. It evaluates the curve at a fixed set of parameter values, and joins the evaluated points with straight lines.

6-99

3D Graphics for Game Programming (J. Han)

Bézier Curve – Affine InvarianceBézier Curve – Affine Invariance

6-1010

3D Graphics for Game Programming (J. Han)

Hermite CurveHermite Curve

6-1111

3D Graphics for Game Programming (J. Han)

Catmull-Rom SplineCatmull-Rom Spline

A spline (piecewise curve) composed of cubic Hermite curves passes through the given points qis. Two adjacent Hermite curves should share the tangent vector at their junction.

The tangent vector at qi is parallel to the vector connecting qi-1 and qi+1.

6-1212

3D Graphics for Game Programming (J. Han)

ApplicationApplication

6-1313

3D Graphics for Game Programming (J. Han)

Application (cont’d)Application (cont’d)

6-1414

3D Graphics for Game Programming (J. Han)

Bilinear PatchBilinear Patch

Combination of linear interpolations using four control points

Matrix representation where the center matrix corresponds to the control point net

6-1515

3D Graphics for Game Programming (J. Han)

Bilinear Patch (cont’d)Bilinear Patch (cont’d)

Tessellation with nested for loops

6-1616

3D Graphics for Game Programming (J. Han)

Bilinear Patch (cont’d)Bilinear Patch (cont’d)

Let’s reverse the order of u and v in linear interpolations.

6-1717

3D Graphics for Game Programming (J. Han)

Bilinear Patch (cont’d)Bilinear Patch (cont’d)

The control points are not necessarily in a plane, and consequently the bilinear patch is not necessarily a plane.

6-1818

3D Graphics for Game Programming (J. Han)

Biquadratic Bézier PatchBiquadratic Bézier Patch

6-1919

A simple extension of bilinear patch

3D Graphics for Game Programming (J. Han)

Biquadratic Bézier Patch (cont’d)Biquadratic Bézier Patch (cont’d)

6-2020

3D Graphics for Game Programming (J. Han)

Biquadratic Bézier Patch (cont’d)Biquadratic Bézier Patch (cont’d)

Another example

6-2121

3D Graphics for Game Programming (J. Han)

Biquadratic Bézier Patch (cont’d)Biquadratic Bézier Patch (cont’d)

So far, we have seen two-stage explicit evaluation. Now, let’s see repeated bilinear interpolations, which produce the same

result.

6-2222

3D Graphics for Game Programming (J. Han)

Bicubic Bézier PatchBicubic Bézier Patch

6-2323

A simple extension of biquadratic Bézier patch

We can of course reverse the order of u and v.

3D Graphics for Game Programming (J. Han)

Bicubic Bézier Patch (cont’d)Bicubic Bézier Patch (cont’d)

6-2424

Let’s apply repeated bilinear interpolations.

Tessellation and rendering result

3D Graphics for Game Programming (J. Han)

Shape ControlShape Control

6-2525

3D Graphics for Game Programming (J. Han)

Bézier TriangleBézier Triangle

Degree-1 Bézier triangle

The weights (u,v,w) are called the barycentric coordinates of p. The triangle is divided into three sub-triangles, and the weight given for a control

point is proportional to the area of the sub-triangle “on the opposite side.” Obviously, u+v+w=1, and therefore w can be replaced by (1-u-v).

6-2626

3D Graphics for Game Programming (J. Han)

Bézier Triangle (cont’d)Bézier Triangle (cont’d)

Degree-2 Bézier triangle

See what s represents when u=0 and u=1.

6-2727

3D Graphics for Game Programming (J. Han)

Bézier Triangle (cont’d)Bézier Triangle (cont’d)

Degree-3 Bézier triangle

6-2828