+ All Categories

Bezier

Date post: 14-Nov-2015
Category:
Upload: immacoolcat
View: 10 times
Download: 4 times
Share this document with a friend
Description:
bezier
Popular Tags:
76
MAE 152 Computer Graphics for Scientists and Engineers Splines and Bezier Curves
Transcript
  • MAE 152Computer Graphics for Scientists and EngineersSplines and Bezier Curves

  • Introduction|Representing CurvesA number of small line-segments joinedInterpolationParametric equationsTypes of curve we studyNatural Cubic Splines and Bezier CurvesDerivationImplementation

  • Computers cant draw curves.The more points/line segments that are used, the smoother the curve.

  • Why have curves ?Representation of irregular surfacesExample: Auto industry (car body design)Artists representationClay / wood modelsDigitizingSurface modeling (body in white)Scaling and smootheningTool and die Manufacturing

  • Curve representationProblem: How to represent a curve easily and efficientlyBrute force and ignorance approaches:storing a curve as many small straight line segmentsdoesnt work well when scaled inconvenient to have to specify so many pointsneed lots of points to make the curve look smoothworking out the equation that represents the curvedifficult for complex curvesmoving an individual point requires re-calculation of the entire curve

  • Solution - Interpolation

  • The need for smoothnessSo far, mostly polygonsCan approximate any geometry, butOnly approximateNeed lots of polygons to hide discontinuitiesStorage problemsMath problemsNormal directionTexture coordinatesNot very convenient as modeling toolGets even worse in animationAlmost always need smooth motion

  • Geometric modelingRepresenting world geometry in the computerDiscrete vs. continuous againAt least some part has to be done by a humanWill see some automatic methods soonReality: humans are discrete in their actionsSpecify a few points, have computer create something which makes senseExamples: goes through points, goes near points

  • RequirementsWant mathematical smoothnessSome number of continuous derivatives of PLocal controlLocal data changes have local effectContinuous with respect to the dataNo wiggling if data changes slightlyLow computational effort

  • A solutionUse SEVERAL polynomialsComplete curve consists of several piecesAll pieces are of low orderThird order is the most commonPieces join smoothlyThis is the idea of spline curves or just splines

  • Parametric Equations - linearWalk from P0 to P1 at a constant speed.Start from P0 at t=0Arrive at P1 at t=1dx = x1 - x0dy = y1 - y0 Where are you at a general time t?x(t) = x0 + t.dxy(t) = y0 + t.dyEquation(s) of a straight line as a function of an arbitrary parameter t.

  • Let us just confirm thatQuestion Where are you at t=0.5?dx = 13 - 2 = 11dy = 8 - 3 = 5x(0.5) = 2 + (0.5 . 11) = 7.5y(0.5) = 3 + (0.5 .5) = 5.5

    Answer: Youll be halfway there.

  • Why use parametric equations?One, two, three or n-dimensional representation is possibleCan handle infinite slope of tangentsCan represent multi-valued functions

  • For this class Natural Cubic SplineBezier Curves

  • SplinesDefine the knots(x0,y0) - (x3,y3)Calculate all other points

  • ContinuityParametric continuity CxOnly P is continuous: C0Positional continuityP and first derivative dP/du are continuous: C1Tangential continuityP + first + second: C2Curvature continuityGeometric continuity GxOnly directions have to match

  • (a)(b)(c)Order of continuity

  • Wiggling effectExample: Four data pointsThird degree polynomial Might look something like:This the ONLY third degree polynomial which fits the dataWiggling gets much worse with higher degree

  • Polynomial parametric equationsTo represent a straight line - linear parametric equation (i.e. one where the highest power of t was 1). For curves, we need polynomial equations. Why? Because the graphs of polynomial equations wiggle!

  • Natural Cubic Splinespline, n. 1 A long narrow and relatively thin piece or strip of wood, metal, etc. 2 A flexible strip of wood or rubber used by draftsmen in laying out broad sweeping curves, as in railroad work.

    A natural spline defines the curve that minimizes the potential energy of an idealized elastic strip.

  • A natural cubic spline defines a curve, in which the points P(u) that define each segment of the spline are represented as a cubic P(u) = a0 + a1u + a2u2 + a3u3Where u is between 0 and 1 and a0, a1, a2 and a3 are (as yet) undetermined parameters. We assume that the positions of n+1 control points Pk, where k = 0, 1,, n are given, and the 1st and 2nd derivatives of P(u) are continuous at each interior control point.

  • Undesirable wiggles and oscillations for higher orders

    The lowest order polynomials to satisfy the following conditionsWhy cubic?Caution! Heavy math ahead!

  • Parameterization

  • non-uniformRe-parameterization

  • Interpolation versus Approximation

  • 12345Hermite Interpolation

  • Hermite SplineSay the user provides A cubic spline has degree 3, and is of the form:

    For some constants a, b, c and d derived from the control points, but how?We have constraints:The curve must pass through x0 when t=0The derivative must be x0 when t=0The curve must pass through x1 when t=1The derivative must be x1 when t=1

  • How to specify slope Di

  • Hermite SplineA Hermite spline is a curve for which the user provides:The endpoints of the curveThe parametric derivatives of the curve at the endpointsThe parametric derivatives are dx/dt, dy/dt, dz/dt That is enough to define a cubic Hermite spline, more derivatives are required for higher order curves

  • Hermite SplineSolving for the unknowns gives:

    Rearranging gives:or

  • Hermite curves in 2D and 3DWe have defined only 1D splines: x = f(t:x0,x1,x0,x1)For higher dimensions, define the control points in higher dimensions (that is, as vectors)

  • Basis FunctionsA point on a Hermite curve is obtained by multiplying each control point by some function and summingThe functions are called basis functions

    Chart1

    0100

    0.0002980.999702-0.0000990.009801

    0.0011840.998816-0.0003920.019208

    0.0026460.997354-0.0008730.028227

    0.0046720.995328-0.0015360.036864

    0.007250.99275-0.0023750.045125

    0.0103680.989632-0.0033840.053016

    0.0140140.985986-0.0045570.060543

    0.0181760.981824-0.0058880.067712

    0.0228420.977158-0.0073710.074529

    0.0280.972-0.0090.081

    0.0336380.966362-0.0107690.087131

    0.0397440.960256-0.0126720.092928

    0.0463060.953694-0.0147030.098397

    0.0533120.946688-0.0168560.103544

    0.060750.93925-0.0191250.108375

    0.0686080.931392-0.0215040.112896

    0.0768740.923126-0.0239870.117113

    0.0855360.914464-0.0265680.121032

    0.0945820.905418-0.0292410.124659

    0.1040.896-0.0320.128

    0.1137780.886222-0.0348390.131061

    0.1239040.876096-0.0377520.133848

    0.1343660.865634-0.0407330.136367

    0.1451520.854848-0.0437760.138624

    0.156250.84375-0.0468750.140625

    0.1676480.832352-0.0500240.142376

    0.1793340.820666-0.0532170.143883

    0.1912960.808704-0.0564480.145152

    0.2035220.796478-0.0597110.146189

    0.2160.784-0.0630.147

    0.2287180.771282-0.0663090.147591

    0.2416640.758336-0.0696320.147968

    0.2548260.745174-0.0729630.148137

    0.2681920.731808-0.0762960.148104

    0.281750.71825-0.0796250.147875

    0.2954880.704512-0.0829440.147456

    0.3093940.690606-0.0862470.146853

    0.3234560.676544-0.0895280.146072

    0.3376620.662338-0.0927810.145119

    0.3520.648-0.0960.144

    0.3664580.633542-0.0991790.142721

    0.3810240.618976-0.1023120.141288

    0.3956860.604314-0.1053930.139707

    0.4104320.589568-0.1084160.137984

    0.425250.57475-0.1113750.136125

    0.4401280.559872-0.1142640.134136

    0.4550540.544946-0.1170770.132023

    0.4700160.529984-0.1198080.129792

    0.4850020.514998-0.1224510.127449

    0.50.5-0.1250.125

    0.5149980.485002-0.1274490.122451

    0.5299840.470016-0.1297920.119808

    0.5449460.455054-0.1320230.117077

    0.5598720.440128-0.1341360.114264

    0.574750.42525-0.1361250.111375

    0.5895680.410432-0.1379840.108416

    0.6043140.395686-0.1397070.105393

    0.6189760.381024-0.1412880.102312

    0.6335420.366458-0.1427210.099179

    0.6480.352-0.1440.096

    0.6623380.337662-0.1451190.092781

    0.6765440.323456-0.1460720.089528

    0.6906060.309394-0.1468530.086247

    0.7045120.295488-0.1474560.082944

    0.718250.28175-0.1478750.079625

    0.7318080.268192-0.1481040.076296

    0.7451740.254826-0.1481370.072963

    0.7583360.241664-0.1479680.069632

    0.7712820.228718-0.1475910.066309

    0.7840.216-0.1470.063

    0.7964780.203522-0.1461890.059711

    0.8087040.191296-0.1451520.056448

    0.8206660.179334-0.1438830.053217

    0.8323520.167648-0.1423760.050024

    0.843750.15625-0.1406250.046875

    0.8548480.145152-0.1386240.043776

    0.8656340.134366-0.1363670.040733

    0.8760960.123904-0.1338480.037752

    0.8862220.113778-0.1310610.034839

    0.8960.104-0.1280.032

    0.9054180.094582-0.1246590.029241

    0.9144640.085536-0.1210320.026568

    0.9231260.076874-0.1171130.023987

    0.9313920.068608-0.1128960.021504

    0.939250.06075-0.1083750.019125

    0.9466880.053312-0.1035440.016856

    0.9536940.046306-0.0983970.014703

    0.9602560.039744-0.0929280.012672

    0.9663620.033638-0.0871310.010769

    0.9720.028-0.0810.009

    0.9771580.022842-0.0745290.007371

    0.9818240.018176-0.0677120.005888

    0.9859860.014014-0.0605430.004557

    0.9896320.010368-0.0530160.003384

    0.992750.00725-0.0451250.002375

    0.9953280.004672-0.0368640.001536

    0.9973540.002646-0.0282270.000873

    0.9988160.001184-0.0192080.000392

    0.9997020.000298-0.0098010.000099

    1000

    x1

    x0

    x'1

    x'0

    Sheet1

    tx1x0x'1x'0

    00100

    0.010.0002980.999702-0.0000990.009801

    0.020.0011840.998816-0.0003920.019208

    0.030.0026460.997354-0.0008730.028227

    0.040.0046720.995328-0.0015360.036864

    0.050.007250.99275-0.0023750.045125

    0.060.0103680.989632-0.0033840.053016

    0.070.0140140.985986-0.0045570.060543

    0.080.0181760.981824-0.0058880.067712

    0.090.0228420.977158-0.0073710.074529

    0.10.0280.972-0.0090.081

    0.110.0336380.966362-0.0107690.087131

    0.120.0397440.960256-0.0126720.092928

    0.130.0463060.953694-0.0147030.098397

    0.140.0533120.946688-0.0168560.103544

    0.150.060750.93925-0.0191250.108375

    0.160.0686080.931392-0.0215040.112896

    0.170.0768740.923126-0.0239870.117113

    0.180.0855360.914464-0.0265680.121032

    0.190.0945820.905418-0.0292410.124659

    0.20.1040.896-0.0320.128

    0.210.1137780.886222-0.0348390.131061

    0.220.1239040.876096-0.0377520.133848

    0.230.1343660.865634-0.0407330.136367

    0.240.1451520.854848-0.0437760.138624

    0.250.156250.84375-0.0468750.140625

    0.260.1676480.832352-0.0500240.142376

    0.270.1793340.820666-0.0532170.143883

    0.280.1912960.808704-0.0564480.145152

    0.290.2035220.796478-0.0597110.146189

    0.30.2160.784-0.0630.147

    0.310.2287180.771282-0.0663090.147591

    0.320.2416640.758336-0.0696320.147968

    0.330.2548260.745174-0.0729630.148137

    0.340.2681920.731808-0.0762960.148104

    0.350.281750.71825-0.0796250.147875

    0.360.2954880.704512-0.0829440.147456

    0.370.3093940.690606-0.0862470.146853

    0.380.3234560.676544-0.0895280.146072

    0.390.3376620.662338-0.0927810.145119

    0.40.3520.648-0.0960.144

    0.410.3664580.633542-0.0991790.142721

    0.420.3810240.618976-0.1023120.141288

    0.430.3956860.604314-0.1053930.139707

    0.440.4104320.589568-0.1084160.137984

    0.450.425250.57475-0.1113750.136125

    0.460.4401280.559872-0.1142640.134136

    0.470.4550540.544946-0.1170770.132023

    0.480.4700160.529984-0.1198080.129792

    0.490.4850020.514998-0.1224510.127449

    0.50.50.5-0.1250.125

    0.510.5149980.485002-0.1274490.122451

    0.520.5299840.470016-0.1297920.119808

    0.530.5449460.455054-0.1320230.117077

    0.540.5598720.440128-0.1341360.114264

    0.550.574750.42525-0.1361250.111375

    0.560.5895680.410432-0.1379840.108416

    0.570.6043140.395686-0.1397070.105393

    0.580.6189760.381024-0.1412880.102312

    0.590.6335420.366458-0.1427210.099179

    0.60.6480.352-0.1440.096

    0.610.6623380.337662-0.1451190.092781

    0.620.6765440.323456-0.1460720.089528

    0.630.6906060.309394-0.1468530.086247

    0.640.7045120.295488-0.1474560.082944

    0.650.718250.28175-0.1478750.079625

    0.660.7318080.268192-0.1481040.076296

    0.670.7451740.254826-0.1481370.072963

    0.680.7583360.241664-0.1479680.069632

    0.690.7712820.228718-0.1475910.066309

    0.70.7840.216-0.1470.063

    0.710.7964780.203522-0.1461890.059711

    0.720.8087040.191296-0.1451520.056448

    0.730.8206660.179334-0.1438830.053217

    0.740.8323520.167648-0.1423760.050024

    0.750.843750.15625-0.1406250.046875

    0.760.8548480.145152-0.1386240.043776

    0.770.8656340.134366-0.1363670.040733

    0.780.8760960.123904-0.1338480.037752

    0.790.8862220.113778-0.1310610.034839

    0.80.8960.104-0.1280.032

    0.810.9054180.094582-0.1246590.029241

    0.820.9144640.085536-0.1210320.026568

    0.830.9231260.076874-0.1171130.023987

    0.840.9313920.068608-0.1128960.021504

    0.850.939250.06075-0.1083750.019125

    0.860.9466880.053312-0.1035440.016856

    0.870.9536940.046306-0.0983970.014703

    0.880.9602560.039744-0.0929280.012672

    0.890.9663620.033638-0.0871310.010769

    0.90.9720.028-0.0810.009

    0.910.9771580.022842-0.0745290.007371

    0.920.9818240.018176-0.0677120.005888

    0.930.9859860.014014-0.0605430.004557

    0.940.9896320.010368-0.0530160.003384

    0.950.992750.00725-0.0451250.002375

    0.960.9953280.004672-0.0368640.001536

    0.970.9973540.002646-0.0282270.000873

    0.980.9988160.001184-0.0192080.000392

    0.990.9997020.000298-0.0098010.000099

    11000

  • Hermite and Cubic Spline Interpolation

  • Spline InterpolationNatural Spline

  • Deriving Natural Cubic Splines

  • Tri-Diagonal Matrix for Natural Cubic Spline

  • Other End Condition

  • AB

  • (0,1,2,3,4,5)(0,1,2,6,7,8)Knot Spacing

  • Euclidean Distance

  • HomeworkClosed Curves

  • Bezier CurvesAn alternative to splines M. Bezier was a French mathematician who worked for the Renault motor car company. He invented his curves to allow his firms computers to describe the shape of car bodies.

  • Bezier Approximation

  • Bezier curvesTypically, cubic polynomialsSimilar to Hermite interpolationSpecial way of specifying end tangentsRequires special set of coefficientsNeed four pointsTwo at the ends of a segmentTwo control tangent vectors

  • Bezier curvesControl polygon: control points connected to each other

    Easy to generalize to higher orderInsert more control pointsHermite third order only

  • De Casteljau algorithmCan compute any point on the curve in a few iterationsNo polynomials, pure geometryRepeated linear interpolationRepeated order of the curve timesThe algorithm can be used as definition of the curve

  • De Casteljau algorithm

  • De Casteljau algorithm

  • De Casteljau algorithm

  • De Casteljau algorithm

  • De Casteljau Algorithm

  • Bezier Polynomial Function

  • Parametric equations for x(t),y(t)

  • Some Bezier Curves

  • Bezier Curves - propertiesNot all of the control points are on the lineSome just attract it towards themselvesPoints have influence over the course of the lineInfluence (attraction) is calculated from a polynomial expression(show demo applet)

  • Convex Hull property

  • Bezier Curve PropertiesThe first and last control points are interpolatedThe tangent to the curve at the first control point is along the line joining the first and second control pointsThe tangent at the last control point is along the line joining the second last and last control pointsThe curve lies entirely within the convex hull of its control pointsThe Bernstein polynomials (the basis functions) sum to 1 and are everywhere positiveThey can be rendered in many waysE.g.: Convert to line segments with a subdivision algorithm

  • Disadvantages

    The degree of the Bezier curve depends on the number of control points.

    The Bezier curve lacks local control. Changing the position of one control point affects the entire curve.

  • InvarianceTranslational invariance means that translating the control points and then evaluating the curve is the same as evaluating and then translating the curveRotational invariance means that rotating the control points and then evaluating the curve is the same as evaluating and then rotating the curveThese properties are essential for parametric curves used in graphicsIt is easy to prove that Bezier curves, Hermite curves and everything else we will study are translation and rotation invariant

  • Longer CurvesA single cubic Bezier or Hermite curve can only capture a small class of curvesAt most 2 inflection pointsOne solution is to raise the degreeAllows more control, at the expense of more control points and higher degree polynomialsControl is not local, one control point influences entire curveAlternate, most common solution is to join pieces of cubic curve together into piecewise cubic curvesTotal curve can be broken into pieces, each of which is cubicLocal control: Each control point only influences a limited part of the curveInteraction and design is much easier

  • Piecewise Bezier CurveknotP0,0P0,1P0,2P0,3P1,0P1,1P1,2P1,3

  • ContinuityWhen two curves are joined, we typically want some degree of continuity across the boundary (the knot)C0, C-zero, point-wise continuous, curves share the same point where they joinC1, C-one, continuous derivatives, curves share the same parametric derivatives where they joinC2, C-two, continuous second derivatives, curves share the same parametric second derivatives where they joinHigher orders possibleQuestion: How do we ensure that two Hermite curves are C1 across a knot?Question: How do we ensure that two Bezier curves are C0, or C1, or C2 across a knot?

  • Achieving ContinuityFor Hermite curves, the user specifies the derivatives, so C1 is achieved simply by sharing points and derivatives across the knotFor Bezier curves:They interpolate their endpoints, so C0 is achieved by sharing control pointsThe parametric derivative is a constant multiple of the vector joining the first/last 2 control pointsSo C1 is achieved by setting P0,3=P1,0=J, and making P0,2 and J and P1,1 collinear, with J-P0,2=P1,1-JC2 comes from further constraints on P0,1 and P1,2

  • Bezier Continuity

  • DOF and LocalityThe number of degrees of freedom (DOF) can be thought of as the number of things a user gets to specifyIf we have n piecewise Bezier curves joined with C0 continuity, how many DOF does the user have?If we have n piecewise Bezier curves joined with C1 continuity, how many DOF does the user have?Locality refers to the number of curve segments affected by a change in a control pointLocal change affects fewer segmentsHow many segments of a piecewise cubic Bezier curve are affected by each control point if the curve has C1 continuity?What about C2?

  • Geometric ContinuityDerivative continuity is important for animationIf an object moves along the curve with constant parametric speed, there should be no sudden jump at the knotsFor other applications, tangent continuity might be enoughRequires that the tangents point in the same directionReferred to as G1 geometric continuityCurves could be made C1 with a re-parameterizationThe geometric version of C2 is G2, based on curves having the same radius of curvature across the knotWhat is the tangent continuity constraint for a Bezier curve?

  • Bezier Geometric ContinuityP0,0P0,1P0,2JP1,1P1,2P1,3

  • Problem with Bezier CurvesTo make a long continuous curve with Bezier segments requires using many segmentsMaintaining continuity requires constraints on the control point positionsThe user cannot arbitrarily move control vertices and automatically maintain continuityThe constraints must be explicitly maintainedIt is not intuitive to have control points that are not free

  • Bezier Basis Functions for d=3

    Chart1

    1000

    0.9702990.0294030.0002970.000001

    0.9411920.0576240.0011760.000008

    0.9126730.0846810.0026190.000027

    0.8847360.1105920.0046080.000064

    0.8573750.1353750.0071250.000125

    0.8305840.1590480.0101520.000216

    0.8043570.1816290.0136710.000343

    0.7786880.2031360.0176640.000512

    0.7535710.2235870.0221130.000729

    0.7290.2430.0270.001

    0.7049690.2613930.0323070.001331

    0.6814720.2787840.0380160.001728

    0.6585030.2951910.0441090.002197

    0.6360560.3106320.0505680.002744

    0.6141250.3251250.0573750.003375

    0.5927040.3386880.0645120.004096

    0.5717870.3513390.0719610.004913

    0.5513680.3630960.0797040.005832

    0.5314410.3739770.0877230.006859

    0.5120.3840.0960.008

    0.4930390.3931830.1045170.009261

    0.4745520.4015440.1132560.010648

    0.4565330.4091010.1221990.012167

    0.4389760.4158720.1313280.013824

    0.4218750.4218750.1406250.015625

    0.4052240.4271280.1500720.017576

    0.3890170.4316490.1596510.019683

    0.3732480.4354560.1693440.021952

    0.3579110.4385670.1791330.024389

    0.3430.4410.1890.027

    0.3285090.4427730.1989270.029791

    0.3144320.4439040.2088960.032768

    0.3007630.4444110.2188890.035937

    0.2874960.4443120.2288880.039304

    0.2746250.4436250.2388750.042875

    0.2621440.4423680.2488320.046656

    0.2500470.4405590.2587410.050653

    0.2383280.4382160.2685840.054872

    0.2269810.4353570.2783430.059319

    0.2160.4320.2880.064

    0.2053790.4281630.2975370.068921

    0.1951120.4238640.3069360.074088

    0.1851930.4191210.3161790.079507

    0.1756160.4139520.3252480.085184

    0.1663750.4083750.3341250.091125

    0.1574640.4024080.3427920.097336

    0.1488770.3960690.3512310.103823

    0.1406080.3893760.3594240.110592

    0.1326510.3823470.3673530.117649

    0.1250.3750.3750.125

    0.1176490.3673530.3823470.132651

    0.1105920.3594240.3893760.140608

    0.1038230.3512310.3960690.148877

    0.0973360.3427920.4024080.157464

    0.0911250.3341250.4083750.166375

    0.0851840.3252480.4139520.175616

    0.0795070.3161790.4191210.185193

    0.0740880.3069360.4238640.195112

    0.0689210.2975370.4281630.205379

    0.0640.2880.4320.216

    0.0593190.2783430.4353570.226981

    0.0548720.2685840.4382160.238328

    0.0506530.2587410.4405590.250047

    0.0466560.2488320.4423680.262144

    0.0428750.2388750.4436250.274625

    0.0393040.2288880.4443120.287496

    0.0359370.2188890.4444110.300763

    0.0327680.2088960.4439040.314432

    0.0297910.1989270.4427730.328509

    0.0270.1890.4410.343

    0.0243890.1791330.4385670.357911

    0.0219520.1693440.4354560.373248

    0.0196830.1596510.4316490.389017

    0.0175760.1500720.4271280.405224

    0.0156250.1406250.4218750.421875

    0.0138240.1313280.4158720.438976

    0.0121670.1221990.4091010.456533

    0.0106480.1132560.4015440.474552

    0.0092610.1045170.3931830.493039

    0.0080.0960.3840.512

    0.0068590.0877230.3739770.531441

    0.0058320.0797040.3630960.551368

    0.0049130.0719610.3513390.571787

    0.0040960.0645120.3386880.592704

    0.0033750.0573750.3251250.614125

    0.0027440.0505680.3106320.636056

    0.0021970.0441090.2951910.658503

    0.0017280.0380160.2787840.681472

    0.0013310.0323070.2613930.704969

    0.0010.0270.2430.729

    0.0007290.0221130.2235870.753571

    0.0005120.0176640.2031360.778688

    0.0003430.0136710.1816290.804357

    0.0002160.0101520.1590480.830584

    0.0001250.0071250.1353750.857375

    0.0000640.0046080.1105920.884736

    0.0000270.0026190.0846810.912673

    0.0000080.0011760.0576240.941192

    0.0000010.0002970.0294030.970299

    0001

    B0

    B1

    B2

    B3

    Sheet1

    tB0B1B2B3

    01000

    0.010.9702990.0294030.0002970.000001

    0.020.9411920.0576240.0011760.000008

    0.030.9126730.0846810.0026190.000027

    0.040.8847360.1105920.0046080.000064

    0.050.8573750.1353750.0071250.000125

    0.060.8305840.1590480.0101520.000216

    0.070.8043570.1816290.0136710.000343

    0.080.7786880.2031360.0176640.000512

    0.090.7535710.2235870.0221130.000729

    0.10.7290.2430.0270.001

    0.110.7049690.2613930.0323070.001331

    0.120.6814720.2787840.0380160.001728

    0.130.6585030.2951910.0441090.002197

    0.140.6360560.3106320.0505680.002744

    0.150.6141250.3251250.0573750.003375

    0.160.5927040.3386880.0645120.004096

    0.170.5717870.3513390.0719610.004913

    0.180.5513680.3630960.0797040.005832

    0.190.5314410.3739770.0877230.006859

    0.20.5120.3840.0960.008

    0.210.4930390.3931830.1045170.009261

    0.220.4745520.4015440.1132560.010648

    0.230.4565330.4091010.1221990.012167

    0.240.4389760.4158720.1313280.013824

    0.250.4218750.4218750.1406250.015625

    0.260.4052240.4271280.1500720.017576

    0.270.3890170.4316490.1596510.019683

    0.280.3732480.4354560.1693440.021952

    0.290.3579110.4385670.1791330.024389

    0.30.3430.4410.1890.027

    0.310.3285090.4427730.1989270.029791

    0.320.3144320.4439040.2088960.032768

    0.330.3007630.4444110.2188890.035937

    0.340.2874960.4443120.2288880.039304

    0.350.2746250.4436250.2388750.042875

    0.360.2621440.4423680.2488320.046656

    0.370.2500470.4405590.2587410.050653

    0.380.2383280.4382160.2685840.054872

    0.390.2269810.4353570.2783430.059319

    0.40.2160.4320.2880.064

    0.410.2053790.4281630.2975370.068921

    0.420.1951120.4238640.3069360.074088

    0.430.1851930.4191210.3161790.079507

    0.440.1756160.4139520.3252480.085184

    0.450.1663750.4083750.3341250.091125

    0.460.1574640.4024080.3427920.097336

    0.470.1488770.3960690.3512310.103823

    0.480.1406080.3893760.3594240.110592

    0.490.1326510.3823470.3673530.117649

    0.50.1250.3750.3750.125

    0.510.1176490.3673530.3823470.132651

    0.520.1105920.3594240.3893760.140608

    0.530.1038230.3512310.3960690.148877

    0.540.0973360.3427920.4024080.157464

    0.550.0911250.3341250.4083750.166375

    0.560.0851840.3252480.4139520.175616

    0.570.0795070.3161790.4191210.185193

    0.580.0740880.3069360.4238640.195112

    0.590.0689210.2975370.4281630.205379

    0.60.0640.2880.4320.216

    0.610.0593190.2783430.4353570.226981

    0.620.0548720.2685840.4382160.238328

    0.630.0506530.2587410.4405590.250047

    0.640.0466560.2488320.4423680.262144

    0.650.0428750.2388750.4436250.274625

    0.660.0393040.2288880.4443120.287496

    0.670.0359370.2188890.4444110.300763

    0.680.0327680.2088960.4439040.314432

    0.690.0297910.1989270.4427730.328509

    0.70.0270.1890.4410.343

    0.710.0243890.1791330.4385670.357911

    0.720.0219520.1693440.4354560.373248

    0.730.0196830.1596510.4316490.389017

    0.740.0175760.1500720.4271280.405224

    0.750.0156250.1406250.4218750.421875

    0.760.0138240.1313280.4158720.438976

    0.770.0121670.1221990.4091010.456533

    0.780.0106480.1132560.4015440.474552

    0.790.0092610.1045170.3931830.493039

    0.80.0080.0960.3840.512

    0.810.0068590.0877230.3739770.531441

    0.820.0058320.0797040.3630960.551368

    0.830.0049130.0719610.3513390.571787

    0.840.0040960.0645120.3386880.592704

    0.850.0033750.0573750.3251250.614125

    0.860.0027440.0505680.3106320.636056

    0.870.0021970.0441090.2951910.658503

    0.880.0017280.0380160.2787840.681472

    0.890.0013310.0323070.2613930.704969

    0.90.0010.0270.2430.729

    0.910.0007290.0221130.2235870.753571

    0.920.0005120.0176640.2031360.778688

    0.930.0003430.0136710.1816290.804357

    0.940.0002160.0101520.1590480.830584

    0.950.0001250.0071250.1353750.857375

    0.960.0000640.0046080.1105920.884736

    0.970.0000270.0026190.0846810.912673

    0.980.0000080.0011760.0576240.941192

    0.990.0000010.0002970.0294030.970299

    10001

  • Bezier Curves in OpenGL OpenGL supports Beziers through mechanism called evaluators used to compute the blending functions, bi (u), of any degree. Smooth curves and surfaces are drawn by approximating them with large number of small line segments or polygons. Described mathematically by a small number of parameters such as control points. 1D Bezier curves can also be used to define paths in time for animation Evaluator is a way to compute points on a curve or surface using only control points. They do not require uniform spacing of u. Bezier curves can then be rendered at any precision.

  • EvaluatorsA Bezier curve is a vector-valued function of one variable C(u) = [X(u) Y(u) Z(u)] and a Bezier surface patch is a vector-valued function of two variable S(u,v) = [X(u,v) Y(u,v) Z(u,v)]

    To use evaluatorfirst define the function C(u) or S(u,v)then use the glEvalCoord{12}() command

  • Berstein Polynomial & Bezier Curve

  • One-Dimensional EvaluatorsGLfloat ctrlpoints[4][3] = {...};void init(void) {glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]);}

    void display(void) { glBegin(GL_LINE_STRIP); for(i=0; i

  • Defining 1-D EvaluatorglMap1(target,u1,u2,stride,order,points);

    target: tells what the control points representu1,u2: the range of the variable ustride: the number of floating-point values to advance in the data between one control point and the nextorder: the degree plus one, and it should agree with the number of control pointspoints: pointer to the first coordinate of the first control point

  • Evaluating 1-D EvaluatorglEvalCoord1(u); glEvalCoord1v(*u);

    Causes evaluation of the enabled mapsu: the value of the domain coordinateMore than one evaluator can be defined and evaluated at a time. (ex) GL_MAP1_VERTEX_3 and GL_MAP1_COLOR_4In this case, calls to glEvalCoord1() generates both a position and a color.

  • point ctrlpts[ ] = { . } ; glMaplf ( GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, ctrlpts);glEnable (GL_MAP1_VERTEX_3); /* GL_MAP1_VERTEX_3 specifies data type for ctrlpts , range of u = [ 0.0, 1.0], 3 is the number of values between control points , (order = degree +1) = 4 *//* With evaluator enabled, draw line segments for Bezier curve */e.g. /* define and enable 1D evaluator for Bezier cubic curve */glBegin (GL_LINE_STRIP);for ( i = 0; i
  • One-Dimensional Grid and Its Eval.define a one-dimensional evenly spaced grid using glMapGrid1*(), and then evaluate the (part of) grid points using glEvalMesh1()glMapGrid1(n, u1, u2); defines a grid that goes from u1 to u2 in n steps.glEvalMesh1(mode, p1, p2); mode: GL_POINT or GL_LINE evaluates from integer indices p1 to p2 with evenly spaced coordinate

  • Bezier Surface

  • Two-Dimensional EvaluatorsEverything is similar to the one-dimensional case, except that all the commands must take two parameters, u and v, into account 1. Define evaluator(s) with glMap2*() 2. Enable them with glEnable() 3. Invoke them by calling glEvalCoord2() between a glBegin() and glEnd() or by specifying and applying a mesh with glMapGrid2() and glEvalMesh2()

  • Defining and EvaluatingglMap2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);glEvalCoord2(u, v);glEvalCoord2v(*values); Example

  • Grid and Its EvaluationglMapGrid2(nu, u1, u2, nv, v1, v2);glEvalMesh2(mode, i1, i2, j1, j2);

  • Using Evaluators for TexturesGLfloat ctrlpoints[4][4][3] = {...};GLfloat texpts[2][2][2] = {...};void init(void) { glMap2f(GL_MAP2_VERTEX_3,...,&ctrlpoints[0][0][0]); glMap2f(GL_MAP2_TEXTURE_COORD_2,..., &texpts[0][0][0]); glEnable(GL_ MAP2_VERTEX_3); glEnable(GL_MAP2_TEXTURE_COORD_2); glMapGrid2f(...);}void display(void) { glEvalMesh2(...);}

  • End Of Curves


Recommended