+ All Categories
Home > Documents > Curves and surfaces

Curves and surfaces

Date post: 26-May-2017
Category:
Upload: bskcsunil
View: 234 times
Download: 2 times
Share this document with a friend
37
Representing Curves and Surfaces
Transcript
Page 1: Curves and surfaces

RepresentingCurves

andSurfaces

CSC 292:Computer GraphicsRandal C. Nelson

Page 2: Curves and surfaces

NeedsWant to represent smooth curves and surfaces� Real world objects.� CAD� Plots, sketches.� Animation, camera paths.� Interpolation of datasets in modeling.� Interactive creation of new models.We will consider various techniques� Polygon meshes.� Parametric curves (cubic).� Parametric surfaces (bicubic).� Quadric surfaces.

1

Page 3: Curves and surfaces

Polygon MeshesApproximate curved surfaces with connectedpolygons.� Collection of edges, vertices, and polygons.� Edges connect 2 vertices.� Polygon is (planar) closed sequence of edges.� Each edge is shared by at most 2 polygons.

2

Page 4: Curves and surfaces

Various operations must be supported,depending on application, but some arecommon.� Find edges incident to vertex.� Find all polygons sharing edge or vertex.� Find vertices connected by an edge.� Find edges of polygon.� Display mesh in various ways.� Find errors (e.g. missing edges).� Compute max distances from polygons toother surface representation.

3

Page 5: Curves and surfaces

Representing Polygon MeshesVarious representations have been used, allwith various tradeo�s.� Explicit polygon set.� Pointers to vertex list.� Pointers to edge list.

4

Page 6: Curves and surfaces

Explicit Polygons� Store polygons as lists of vertices.� Simple.� Edges and vertices are duplicated.� No explicit representation of shared edgesand vertices, so they are hard to �nd.�Match problems due to roundo�.� Shared edges drawn twice.

5

Page 7: Curves and surfaces

Pointers to Vertex List� SPHIGS method.� Vertices stored once.� Polygons are lists of pointers to vertices.� Easy sharing of vertices.� Still hard to �nd polygons that share anedge.� Edges still drawn twice.

6

Page 8: Curves and surfaces

Pointers to an edge list� Set of vertices.� Set of edges where each edge containspointers to vertices and pointers topolygons.� Polygons are lists of pointers to edges.� Display by showing all edges.� Can be extended to allow more than 2polygons to intersect at an edge.� Still doesn't allow easy determination ofedges incident to a vertex.�Modi�cation called a winged edge extendsedges by adding pointers to adjacent edges,and extends vertices to include pointers toincident edges.

7

Page 9: Curves and surfaces

Consistency CheckingCheck that:� Polygons are closed.� Each edge is used at least once, but notmore than (twice, n-times).� Each vertex is referenced by at least twoedgesSometimes we want to ensure that:�Mesh is connected.� Graph is planar.� Polyhedron has no holes.

8

Page 10: Curves and surfaces

Watch for:� Zero length edges.� Same edge twice in a polygon.� Overall consistency in more complexrepresentations.

9

Page 11: Curves and surfaces

Finding Plane EquationsOften we want to know the equation of theplane containing a polygon. Recall that thegeneral equation for a plane is:

Ax +By + Cz +D = 0� Three non-collinear points de�ne a plane.� So one way is to pick three vertices.� A, B, and C de�ne the plane normal andcan be found with cross product of twovectors connecting vertices. This also checkscollinearity.� Obtain D by plugging in one point.

10

Page 12: Curves and surfaces

More Robust MethodPolygons with more than 3 points may not beplanar due to numerical (roundo�) errors, orerrors in generation process� In almost planar case, can use all points toget better guess.� Use fact that A, B, and C are proportionalto signed areas of projection of polygon ontoplane perpendicular to corresponding axis.� Projection is easy.� Polygon areas are computed from (signed)sums of trapezoids.� Compute non-planarity by �ndingperpendicular distances.d = Ax +By + Cz +DpA2 +B2 + C2� Representation is not unique.11

Page 13: Curves and surfaces

Parametric Cubic Curves� Using linear approximations (segments,polygons) takes lots of points to get goodaccuracy for curved objects.� Can be a problem for some applications(especially interactive generation).� Using higher degree polynomials can givebetter (and better-looking) approximationswith much less explicit information.

12

Page 14: Curves and surfaces

Representations for Equations� Explicit representation: y = f (x){ Can't do multiple values of y - have tobreak into pieces.{ These pieces are not rotationallyinvariant.{ Vertical tangents cause problems.� Implicit equations: x2 + y2 = 1{Might have more solutions that we want.{ Solving is tricky.{ Joining is tricky.� Parametric equations: x = f (t); y = g(t){ Avoids above problems.{ Typically what is used.

13

Page 15: Curves and surfaces

Parametric Cubic Curves�We will use piecewise polynomial curves,each segment represented parametrically,with constraints on joins.� Use cubics because they are the lowestdegree with enough exibility to matchendpoints and slope.� Higher orders give unwanted wiggles andare harder to use.� 4 parameters of cubic let 4 geometricparameters be set (e.g. 2 endpoints and 2slopes).� Parametric cubics can be non-planar in 3D(2nd order curves always lie in some plane).� Sometimes higher degree polynomials areused in applications where more constraintsmust be met (aerodynamics)

14

Page 16: Curves and surfaces

Mathematical Representation� Parametric cubic polynomials have the form

x(t) = axt3 + bxt2 + cxt + dxy(t) = ayt3 + byt2 + cyt + dyz(t) = azt3 + bzt2 + czt + dzwith t on the interval [0; 1].� If we de�ne the vector T = [t3; t2; t; 1] andthe matrixC =

2666666666666664ax ay azbx by bzcx cy czdx dy dz

3777777777777775Then we can write conciselyQ(t) = [x(t); y(t); z(t)] = T � C15

Page 17: Curves and surfaces

Continuity Properties� The derivative of the curve is the tangentvector, and is given byQ0(t) = T 0 � C = [3t2; 2t; 1; 0] � C.� Tangent has both direction and magnitude.� Two types of continuity are de�ned forparametric curves: geometric continuityGn, and parametric continuity Cn.� G0 geometric continuity means theendpoints match.� G1 geometric continuity means the tangentdirections (but not necessarily themagnitudes) match.

16

Page 18: Curves and surfaces

� Cn continuity means the nth derivativesmatch.� C0 means the endpoints match (just likeG0).� C1 means the tangent vectors direction andmagnitude match. i.e. no discontinuities invelocity if t is time.� C2 means no acceleration discontinuities.

17

Page 19: Curves and surfaces

Continuity Constraints� Visually, when Q generates a static curve,G1 is enough, and indistinguishable fromC1.� For animation, we generally want at leastC1 and sometimes C2.� Generally, C1 implies G1 (not vice versa).Exception if magnitude goes to 0.� Curve segments are determined byconstraints on endpoints, tangent vectors,and continuity.� Each cubic polynomial has 4 unknowns, sowe need 4 constraints per segment.

18

Page 20: Curves and surfaces

Cubic Fitting MethodsWe will look at several di�erent methods forapproximating curves (and ultimately surfaces)using cubic polynomials, with di�erent sorts ofconstraint mechanisms.� Hermite - 2 endpoints, 2 tangents.� Bezier - 2 endpoints, 2 tangent-controllingcontrol points� Splines (several types) controlled by 4control points that lie near, but are notgenerally interpolated by the spline.

19

Page 21: Curves and surfaces

Generic Form�We rewrite the coe�cient matrix C as aproduct of two matrices C = M �G.�M is a 4� 4 matrix called the basis matrix.� G is a 4� n geometry matrix composed ofa column of n-dimensional constraints (suchas endpoints or tangent vectors).C =

2666666666666664m11 m12 m13 m14m21 m22 m23 m24m31 m32 m33 m34m41 m42 m43 m44

3777777777777775 �2666666666666664g1x g1y g1zg2x g2y g2zg3x g3y g3zg4x g4y g4z

3777777777777775

20

Page 22: Curves and surfaces

� If we multiply out just x(t) = T �M �Gx,we get a big long equation:x(t) = (t3m11 + t2m21 + tm31 +m41)g1x +(t3m12 + t2m22 + tm32 +m42)g2x +(t3m13 + t2m23 + tm33 +m43)g3x +(t3m14 + t2m23 + tm34 +m44)g4x� y(t) and z(t) are analogous.�We note the above is just a weighted sumof cubic equations. The equations aredetermined by M and the weights are thecontrol points.� The di�erent cubic polynomials are calledblending functions and are given byB = T �M .

21

Page 23: Curves and surfaces

� Note similarity to the linear interpolationformulax(t) = (1� t)g1x + (t)g2xy(t) = (1� t)g1y + (t)g2yz(t) = (1� t)g1z + (t)g2z� In this sense, �tting cubics can be seen as asimple generalization of �tting linesegments.

22

Page 24: Curves and surfaces

Representation of Fitting Methods� The di�erent �tting methods can all berepresented by varying M and theinterpretation of the points composing G.� The elements of M are carefully determinedto guarantee speci�c continuity conditionson the interpretation of G.� Finding the M matrices is a bit of a trick,but it only has to be derived once for each�tting method.� Generalizes to higher degree polynomials.

23

Page 25: Curves and surfaces

Hermite Curves� Constraints are on endpoints P1 and P4,and tangent vectors (magnitude included)R1 and R4 at those same endpoints(indexing is for consistency with latermodels).� Together these make up the Hermitegeometry vector (actually a matrix) GH .

GH =2666666666666664P1P4R1R4

3777777777777775 =2666666666666664p1x p1y p1zp4x p4y p4zr1x r1y r1zr4x r4y r4z

3777777777777775

24

Page 26: Curves and surfaces

�We want to �nd the Hermite basis matrixMH that relates GH to the polynomialcoe�cients.� This can be done by setting up constraintsand solving for the elements of MH .� First recall thatx(t) = [ t3 t2 t 1MH �GHx]� By substituting t = 0 and t = 1 into theequations for x(t) and x0(t), we get fourequations:x(0) = P1x = [ 0 0 0 1 ]MH �GHxx(1) = P4x = [ 1 1 1 1 ]MH �GHxx0(0) = P1x = [ 0 0 1 0 ]MH �GHxx0(1) = P1x = [ 3 2 1 0 ]MH �GHx

25

Page 27: Curves and surfaces

� These can be rewritten in matrix form2666666666666664P1P4R1R4

3777777777777775 = GHx =26666666666666640 0 0 11 1 1 10 0 1 03 2 1 0

3777777777777775MH �GHx� For this to be true MH must be the inverseof the 4� 4 matrix

MH =26666666666666640 0 0 11 1 1 10 0 1 03 2 1 0

3777777777777775�1 =

26666666666666642 �2 1 1�3 3 �2 �10 0 1 01 0 0 0

3777777777777775

26

Page 28: Curves and surfaces

� If we expand this, we get the Hermiteblending functions:Q(t) = (2t3 � 3t2 + 1)P1+ (�2t3 + 3t2)P4+ (t3 � 2t2 + t)R1+ (t3 � t2)R4

1 P4

R 1

R 4

P1

1

f(t)

t

� Note that at t = 0 only P1 e�ects the value,and at t = 1 only P4 does. In between, theother polynomials contribute.27

Page 29: Curves and surfaces

� By varying the tangent slope andmagnitude, the character of the curvepassing through the endpoints can bemodi�ed.� For passing a curve through multiple points,we generate one Hermite cubic per intervaland control the tangents to obtain thedesired continuity (G1 or C1).� A simple method of display is just toincrement t and �nd values on the curve bydirect computation (a bit ine�cient).�We can transform the curves bytransforming the geometry vector and usingit to generate the transformed curve.

28

Page 30: Curves and surfaces

Bezier Curves� Here, instead of two endpoints and twotangents, we specify two endpoints P1 andP4, and two control points P2 and P3 thatindirectly specify the tangents.� Speci�cally R1 = 3(P2 � P1) andR4 = 3(P4 � P3).� The factor of 3 gives good continuityproperties.� Curve interpolates the endpoints, andapproximates the control points.� Running a similar derivation gives us thebasis matrix MB for the Bezier geometrymatrix GB.

MH =2666666666666664�1 3 �3 13 �6 3 0�3 3 0 01 0 0 0

377777777777777529

Page 31: Curves and surfaces

� The corresponding blending functions arecalled the Bernstein Polynomials.Q(t) = (1� t)3P1+ 3t(1� t)2P2+ 3t2(1� t)P3+ t3P4

1 B4

B 2 B 3

B

1

1

f(t)

t

� Note symmetry

30

Page 32: Curves and surfaces

� Points are non-negative weighted average ofcontrol points.� If weights always sum to one, as here, thenwhole curve lies inside the convex hull ofthe control points.� Continuity at joins requires point andcontrol points on either side to be collinear.

31

Page 33: Curves and surfaces

Uniform Nonrational B-Splines� Originally, splines were strips of metal bentwith weights, and used to lay out sufaces ofcars, airplanes etc.�Metal strips have second order continuity.� The natural cubic spline is C2 continuouspolynomial that interpolates all the controlpoints. Non-local, and solution involvesinverting n + 1� n + 1 matrix.� Simpler B-splines are curve segmentswhose coe�cients depend on just a fewcontrol points.

32

Page 34: Curves and surfaces

� Approximate a series of m + 1 controlpoints P0; P1; :::Pm with m� 2 cubic curvesegments Q3; Q4; :::Qm.� Adjust parameters of each segment so thatrange of t is contiguous over whole curve.� Each segment is thus associated with arange of t.� Curve segments are joined at knots, and theparameter value at such a join is called theknot value. Initial and �nal points are alsoknots.� The quali�er uniform means knots arespaced regularly in t. Thus without loss ofgenerality, we can let the interval betweenknots be 1.

33

Page 35: Curves and surfaces

� Each segment is de�ned by 4 contiguouscontrol points. Lots of overlap.� Each control point a�ects 4 segments, somoving a control point moves the 4segments in the same direction.� By requiring C0, C1, and C2 continuity, wecan derive a basis matrix MBs and blendingfunctions for the geometry vector GBsconsisting of the 4 control points as before.GBsi =

2666666666666664Pi�3Pi�2Pi�1Pi

3777777777777775 ;MBs = 1626666666666666640 0 0 11 1 1 10 0 1 03 2 1 0

3777777777777775

34

Page 36: Curves and surfaces

� The blending functions, now applied tocontiguous groups of 4 points, are given byQ(t� ti) = (1� t)36 Pi�3+ 3t3 + 6t2 + 46 Pi�2+ �3t3 + 3t2 + 3t + 16 Pi�1+ t36 Pi

1

1

f(t)

t

B B

B-3 B

-2 -1

0

35

Page 37: Curves and surfaces

� Blending functions sum to one, so convexhull condition holds.� Provides C2 continuity, but at cost of less exibility.

36


Recommended