Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Parametric Surfaces and Ray-Surface Intersections in Computer Graphics, Study notes of Computer Graphics

The essential procedures for rendering surfaces via ray tracing in computer graphics: computing surface normals and calculating ray-surface intersections. Four standard ways to represent surfaces are presented, including implicit equations, parametric equations, deformations of known surfaces, and specialized procedures. The focus is on parametric surfaces and their intersection with rays.

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-fbn-1
koofers-user-fbn-1 🇺🇸

10 documents

1 / 14

Toggle sidebar

Related documents


Partial preview of the text

Download Parametric Surfaces and Ray-Surface Intersections in Computer Graphics and more Study notes Computer Graphics in PDF only on Docsity! Lecture 18: Surfaces I -- The General Theory Thou hast set all the borders of the earth: Psalm 74:17 1. Surface Representations Recursive ray tracing is a technique for displaying realistic images of objects bordered by surfaces. To render surfaces via ray tracing, we require two essential procedures: we must be able to compute surface normals and we need to calculate ray-surface intersections. There are four standard ways to represent surfaces in Computer Graphics: implicit equations, parametric equations, deformations of known surfaces, and specialized procedures. In this lecture we shall review each of these general surface types and in each case explain how to compute surface normals and how to calculate ray-surface intersections. To facilitate further analysis, at the end of this lecture we shall also provide explicit formulas for mean and Gaussian curvature. 1.1 Implicit Surfaces. Planes, spheres, cylinders, and tori are examples of implicit surfaces. An implicit surface is the collection of all points P satisfying an implicit equation of the form € F(P) = 0. Typically, the function F is a polynomial in the coordinates € x, y,z of the points P. For example, a sphere can be represented by the implicit equation € F(x, y,z) ≡ x2 + y 2 + z2 −1 = 0. Generating lots of points along an implicit surface may be difficult because for complicated expressions F it may be hard to find points € P for which € F(P) = 0. On the other hand, determining if a point € P lies on an implicit surface is easy, since we need only check if € F(P) = 0. Moreover points on different sides of an implicit surface are distinguished by the sign of F; for closed surfaces € F(P) < 0 may indicate points on the inside, whereas € F(P) > 0 may indicate points on the outside. This ability to distinguish inside from outside is important in solid modeling applications. 1.2 Parametric Surfaces. Planes, spheres, cylinders, and tori are also examples of parametric surfaces. A parametric surface is a surface represented by parametric equations -- that is, to each point P on the surface, we assign a pair of parameter values € s,t so that there is a formula € P = P(s,t) for computing points along the surface. In terms of rectangular coordinates, the equation € P = P(s,t) is equivalent to three parametric equations for the coordinates: € x = p1(s,t), y = p2(s,t), z = p3(s,t) . In Computer Graphics, the functions € p1(s,t), p2(s,t), p3(s,t) are typically either polynomials or rational functions -- ratios of polynomials -- in the parameters € s,t . For example, a sphere can be represented by the parametric equations € x(s,t) = 2 s 1+ s2 + t2 y( s,t) = 2t 1+ s2 + t 2 z(s,t) = 1− s 2 − t 2 1+ s2 + t2 since it is easy to verify that € x 2(s,t) + y2(s,t) + z2(s,t) =1. Generating lots of points along a parametric surface is straightforward: simply substitute lots of different parameter values € s,t into the expression € P = P(s,t). Thus parametric surfaces are easy to display, so parametric surfaces are a natural choice for Computer Graphics. However, determining if a point € P is on a parametric surface is not so simple, since it may be difficult to determine whether or not there are parameters € s,t for which € P = P(s,t). 1.3 Deformed Surfaces. An ellipsoid is a deformed sphere; an elliptical cone is a deformed circular cone. Any surface generated by deforming another surface is called a deformed surface. The advantage of deformed surfaces is that deformations often permit us to represent complicated surfaces in terms of simpler surfaces. This device can lead to easier analysis algorithms for complicated shapes. For example, we shall see in the next lecture that ray tracing an ellipsoid can be reduced to ray tracing a sphere. If the original surface has an implicit representation € Fold (P) = 0 or a parametric representation € P = Sold (s,t) , then the deformed surface also has an implicit representation € Fnew (P) = 0 or a parametric representation € P = Snew(s,t) ; moreover, we can compute € Fnew (P) and € Snew(s,t) from € Fold (P) and € Sold (s, t) . In fact, if M is a nonsingular transformation matrix that maps the original surface into the deformed surface, then € Fnew (P) = Fold (P ∗M −1) (1.1) € Snew(s,t) = Sold (s,t) ∗M . (1.2) Equation (1.2) is easy to understand because M maps points on € Sold to points on € Snew . Equation (1.1) follows because P is a point on the deformed surface if and only if € P∗ M−1 is a point on the original surface. Thus € Fnew (P) = 0⇔ Fold (P ∗M −1) = 0. Equations (1.1) and (1.2) are valid for any affine transformation M of the original surface. Thus the map M can be a rigid motion -- a translation or a rotation -- so we can use Equations (1.1) and (1.2) to reposition as well as to deform a surface. 1.4 Procedural Surfaces. Fractal surfaces are examples of procedural surfaces. Typically fractals are not represented by explicit formulas; instead fractals are represented either by recursive procedures or by iterated function systems. Any surface represented by a procedure instead of a formula is called a procedural surface. Often surfaces that blend between other surfaces are 2 For rotations the transpose is equivalent to the inverse, so for rotations € Mu −T = Mu . Similarly, if € Mu is uniform scaling by the scale factor s, then € Mu −T is uniform scaling by the scale factor € 1 / s . However, for arbitrary transformations, € Mu −T can be very different from € Mu . Figure 1: A circle with its normal vectors, and the circle transformed into an ellipse by scaling non-uniformly by the factor 1/2 along the minor axis. Notice that, in general, non-uniform scaling does not map normal vectors to the circle to normal vectors to the ellipse. The general transformation formula for the normal vector is a consequence of the following observations. Since € Nold is orthogonal to € Sold , we know that the normal vector € Nold is perpendicular to the tangent vector € vold . Therefore by the properties of the dot product, € vold ∗Nold T = vold • Nold = 0. Now we seek a vector € Nnew such that € vnew ∗Nnew T = vnew •Nnew = 0. But we can easily verify that if € Nnew = Nold ∗ Mu −T , then € vnew ∗Nnew T = 0 because € vnew ∗Nnew T = vold ∗ Mu( ) ∗ Nold ∗Mu −T( ) T = vold ∗ Mu( )∗ Mu −1∗Nold T( ) = vold ∗NoldT = 0. To summarize: using affine coordinates, points and tangent vectors transform by the same rule: € (Pnew,1) = (Pold ,1) ∗M € (vnew,0) = (vold ,0)∗ M , but tangent vectors and normal vectors transform by different rules: 5 € vnew = vold ∗Mu € Nnew = Nold ∗ Mu −T . Moreover, inserting a zero affine coordinate for normal vectors will not work because the fourth coordinate of € (Nold ,0) ∗M −T is not zero. Thus normal vectors are qualitatively different from tangent vectors. The single term vector is not rich enough to capture the full diversity of different kinds of vectors. Both in differential geometry and in modern physics this distinction between tangent vectors and normal vectors is emphasized by calling tangent vectors covariant vectors and normal vectors contravariant vectors. 3. Ray-Surface Intersections Ray tracing a surface requires computing the intersection points of an arbitrary line with the surface as well as calculating the corresponding parameter values along the line of these intersection points. For implicit, parametric, and deformed surfaces, there are straightforward algorithms for finding these intersection points along with their corresponding parameter values. 3.1 Implicit Surfaces. Many of the surfaces encountered in recursive ray tracing have implicit representations € F(P) = 0. Let € L(t) = Q + t v be the parametric equation of a line. Then we can compute the parameters along the line of the intersection points of the ray and the implicit surface by solving the equation € F L( t)( ) = 0 . Substituting the roots of this equation into the parametric equation € L(t) = Q + t v for the line yields the actual intersection points. Thus we have the following intersection algorithm. Ray-Surface Intersection Algorithm -- Implicit Surfaces 1. Solve € F L( t)( ) = 0 . The roots € t = t1,K,tn are the parameter values along the line of the actual intersection points. 2. Compute € Ri = L(ti ) = Q + ti v , € i =1,K,n . The values € R1,K,Rn are the actual intersection points of the line and the surface. The bottleneck in this algorithm is clearly step 1, since the equation € F L( t)( ) = 0 may be difficult to solve. When the function F is a polynomial in the coordinates € x, y,z , then € F L( t)( ) = 0 is a univariate polynomial equation. For low degree polynomials (degree<5), there are explicit formulas for the roots; for high degree polynomials a numerical method can be used to solve this equation. Thus implicit polynomial surfaces are a natural choice for recursive ray tracing. 6 3.2 Parametric Surfaces. Ray tracing parametric surfaces is more difficult than ray tracing implicit surfaces. Let € S(u,v) = x(u,v),y( u,v),z(u,v)( ) be a parametric surface, and let € L(t) = P + t v be the parametric equation of a line. The line and the surface intersect whenever there are parameter values € t,u,v for which € S(u,v) = L( t). This equation really represents three equations -- one for each coordinate -- in three unknowns -- € t,u,v . Thus to find the intersection points of the line and the surface, we must solve three equations in three unknowns. Substituting the solutions in t into the parametric equation € L(t) = P + t v for the line or the solutions in € u,v into the parametric equations € S(u,v) = x(u,v),y( u,v),z(u,v)( ) of the surface yields the actual intersection points. Thus we have the following intersection algorithm. Ray-Surface Intersection Algorithm -- Parametric Surfaces 1. Solve € S(u,v) = L( t) for the parameters € t,u,v . That is, solve the three simultaneous equations: € x(u,v) = p1 + t v1 € y(u,v) = p2 + t v2 € z(u,v) = p3 + t v3. The roots € t = t1,K,tn are the parameter values along the line of the actual intersection points. 2. Compute € Ri = L(ti ) = P + ti v , € i =1,K,n , or equivalently € Ri = S(ui ,vi ), € i =1,K,n . The values € R1,K,Rn are the actual intersection points of the line and the surface. The bottleneck in this algorithm is again clearly step 1, since the simultaneous equations € S(u,v) = L( t) may be difficult to solve. We can simplify from three equations in three unknown to two equations in two unknowns in the following fashion. Let € N1,N2 be two linearly independent vectors perpendicular to v. Then € v •N1 = v • N2 = 0. Therefore dotting the equation € S(u,v) = L( t), with € N1,N2 eliminates t, the coefficient of v. We are left with two equations in two unknowns: € S(u,v) − P( ) •N1 = 0 € S(u,v) − P( ) •N2 = 0 which we now must solve for € u,v . Even with this simplification, however, we must still solve two non-linear equations in two unknowns. Thus, typically ray tracing for parametric surfaces, even for parametric polynomial surfaces, requires more sophisticated numerical root finding techniques than ray tracing for implicit surfaces. 3.3 Deformed Surfaces. Ray tracing deformed surfaces is often easy because the deformed surface is usually the image of a simple surface which we already know how to ray trace. Suppose that € Snew is the image under a nonsingular transformation matrix M of the surface € Sold -- that is, € Snew = Sold ∗ M . For ray tracing the key observation is that intersecting a line L with the surface € Snew is equivalent to intersecting the line € L∗ M−1 with the surface € Snew ∗M −1 = Sold . More precisely, a line L and the surface € Snew intersect at a point P if and only if the line € L∗ M−1 and the 7 € H = Trace(I ∗ II∗) 2Det(I) , (4.4) where € II∗ is the adjoint of € II . 4.3 Deformed Surfaces. If M is a nonsingular transformation matrix that maps some original surface in implicit or parametric form into a deformed surface, then by Equations (1.1) and (1.2) € Fnew (P) = Fold (P ∗M −1) € Snew(u,v) = Sold (u,v) ∗M . Since we already have formulas for the mean and Gaussian curvatures both for implicit and for parametric surfaces, we can calculate the mean and Gaussian curvature of deformed surfaces from their implicit or parametric equations -- that is, from € Fnew or € Snew . 5. Summary The three most common types for surfaces in Computer Graphics are implicit, parametric, and deformed surfaces. For each of these surface representations we have explicit formulas for the normal vectors and curvatures as well as straightforward algorithms for calculating ray-surface intersections. For easy reference we summarize these formulas and algorithms below. 5.1 Implicit Surfaces. Surface Representation € F(x, y,z) = 0 Normal Vector € N =∇F = ∂F ∂x ,∂F ∂y , ∂F ∂z       Hessian € hess(F) = ∂2F ∂x 2 ∂2F ∂x∂y ∂2F ∂x∂z ∂2F ∂x∂y ∂2F ∂y 2 ∂2F ∂y∂z ∂2F ∂x∂z ∂2F ∂y∂z ∂2F ∂z 2                   10 Gaussian Curvature € K = ∇F ∗ hess∗(F) ∗∇FT ∇F 4 = − Det hess(F) ∇F T ∇F 0         ∇F 4 , Mean Curvature € H = ∇F 2Trace hess(F )( ) −∇F ∗ hess(F)∗∇FT 2 ∇F 3 =∇ • ∇F ∇F       Ray-Surface Intersection Algorithm 1. Solve € F L( t)( ) = 0 . The roots € t = t1,K,tn are the parameter values along the line of the actual intersection points. 2. Compute € Ri = L(ti ) = P + ti v , € i =1,K,n . The values € R1,K,Rn are the actual intersection points of the line and the surface. 5.2 Parametric Surfaces. Surface Representation € P(s,t) = x( s,t), y(s,t), z(s,t)( ) Normal Vector € N = ∂P ∂s × ∂P ∂t = ∂x ∂s ,∂y ∂s ,∂z ∂s       × ∂x ∂t ,∂y ∂t ,∂z ∂t       First Fundamental Form € I = ∂P ∂s • ∂P ∂s ∂P ∂s • ∂P ∂t ∂P ∂s • ∂P ∂t ∂P ∂t • ∂P ∂t           Second Fundamental Form € II = ∂2P ∂s2 • N ∂ 2P ∂s∂t • N ∂2P ∂s∂t •N ∂2P ∂t 2 •N             Gaussian Curvature € K = Det(II) Det(I) 11 Mean Curvature € H = Trace(I ∗ II∗) 2Det(I) Ray-Surface Intersection Algorithm 1. Solve € S(u,v) = L( t) for the parameters € t,u,v . That is, solve the three simultaneous equations: € x(u,v) = p1 + t v1 € y(u,v) = p2 + t v2 € z(u,v) = p3 + t v3, or equivalently the two simultaneous equations € S(u,v) − P( ) •N1 = 0 € S(u,v) − P( ) •N2 = 0 where € N1.N2 are two linearly independent vectors perpendicular to v. The roots € t = t1,K,tn are the parameter values along the line of the actual intersection points. 2. Compute € Ri = L(ti ) = P + ti v , € i =1,K,n , or equivalently € Ri = S(ui ,vi ), € i =1,K,n . The values € R1,K,Rn are the actual intersection points of the line and the surface. 5.3 Deformed Surfaces. Surface Representation An implicit surface € Fold (P) = 0 or a parametric surface € Sold (u,v) = x(u,v),y( u,v),z(u,v)( ) together with a deformation matrix € M = Mu 0 v 1       . Implicit Representation Parametric Representation € Fnew (P) = Fold (P ∗M −1) € Snew(u,v) = Sold (u,v) ∗M Normal Vector € Nnew = Nold ∗ Mu −T Mean and Gaussian Curvatures From implicit or parametric representations. Ray-Surface Intersection Algorithm 1. Transform the line L by the matrix € M−1. If € L(t) = P + t v , then € L(t)∗ M−1 = P∗ M−1 + t (v ∗M−1) . 2. Find the intersection points € Q1,K,Qn and the corresponding parameter values € t = t1,K,tn of the intersection of the line € L(t)∗ M−1 and the surface € Fold or € Sold . 12