• Nie Znaleziono Wyników

On new types of solid models and their visualization with ray tracing

N/A
N/A
Protected

Academic year: 2021

Share "On new types of solid models and their visualization with ray tracing"

Copied!
135
0
0

Pełen tekst

(1)

(to mssj.i^pss ®ff saüflcH mmMs

wMh m$ testa;

Jarke J. van Wijk

TR diss

1506

wsfcy PiRg§§

1

M

(2)

On new types of solid models

and their visualization

with ray tracing

(3)

On new types of solid models

and their visualization

with ray tracing

Proefschrift

ter verkrijging van de graad van doctor

in de technische wetenschappen aan de Technische Universiteit Delft. op gezag van de Rector Magnificus prof. dr. J.M. Dirken,

in het openbaar te verdedigen

ten overstaan van het College van Dekanen op dinsdag 28 oktober 1986

te 16.00 u u r door

Jarke Jan van Wijk

geboren te Alkmaar

ingenieur Industriële Vormgeving

Delft University Press 1986

TR dissï

1506

(4)

Dit proefschrift is goedgekeurd door de promotor prof. dr. D.J. McConalogue

Het werk beschreven in dit proefschrift is financieel ondersteund door het Delfts Hogeschoolfonds

(5)
(6)

Contents

Preface x i 1 Geometric modelling 1 1.1 Introduction 1 1.2 Fundamental techniques 2 1.3 Solid modelling 4 2 Ray tracing 11 2.1 Introduction 11 2.2 The basic principle 11 2.3 Ray-object intersection 14 2.4 Efficiency 17

2.5 Solid modelling using ray tracing 19 2.6 RAYMO 21

3 Translational and rotational sweeping 25 3.1 Introduction 25 3.2 Object definition 25 3.3 Translational sweeping 27 3.4 Conic sweeping 30 3.5 Rotational sweeping 32 3.6 Discussion 37 4 Sphere sweeping 41 4.1 Introduction 41 4.2 Intersection algorithm 42 4.3 Valid intersection points 45 4.4 Trajectory and radius 47 4.5 Discussion 50

(7)

vin Contents

5 Blending quadric surfaces 53 5.1 Introduction 53

5.2 Blending planes 55

5.3 Quadric surfaces 59

5.4 Blending cylinders and spheres 60

5.5 Boolean combinations 64 5.6 Ray tracing blends 67

5.7 Discussion 69

6 Bicubic patches f o r non-rectangular meshes 73 6.1 Introduction 73

6.2 The bicubic patch 75

6.3 Approximating non-rectangular meshes 79 6.4 Applications 87

6.5 Discussion 90

7 A solid modelling language 93 7.1 Introduction 93 7.2 Requirements 94 7.3 Description 96 7.4 Examples 101 7.5 Implementation 107 7.6 Discussion 110 8 Conclusions 113 8.1 General 113

8.2 New types of primitives 113 8.3 Procedural Modelling 115 8.4 Further research 116

(8)

Contents IX

S u m m a r y 119 S a m e n v a t t i n g 121 References 123 Curriculum vitae 129

Parts of this thesis are reworked versions of earlier publications:

Chapter 3:

Wijk, J.J. van, "Ray Tracing Objects Defined by Sweeping Planar Cubic Splines," ACM Transactions on Graphics, 3(3), July 1984, pp. 223-237. Chapter 4:

Wijk, J.J. van, "Ray Tracing Objects Defined by Sweeping a Sphere,"

Eurographics'84 Proceedings, K. B6 and H.A. Tucker (Eds.).

North-Holland, Amsterdam, September 1984, pp. 73-82. also in Computers &

Graphics, 9 ( 3 ) , September 1985, pp. 283-290.

Chapter 6:

Wijk, J.J. van, "Bicubic Patches for Approximating Non-Rectangular Control-Point Meshes," Computer Aided Geometric Design, 3(1), May 1986, p p . 1 - 1 3 .

Chapter 7:

Wijk, J.J. van, "SML: a Solid Modelling Language," Computer-Aided

(9)

XI

Preface

The design and manufacture of industrial products is a complex pro-cess. Putting a new product on the market is not simply the result of just a brilliant invention. It requires a usually lengthy process in which a vague concept is stepwise developed into an exact specification. The development of new products can be characterized as a continuous process of generating, analysing, and evaluating information. Informa-tion on, for instance, the needs and wants of potential end-users, the objectives and technical resources of the company, is gradually transformed into a specification of the geometry, materials, and manufacturing process of the new product. The efficiency of these activities can be improved by the application of computerized informa-tion processing.

The background of the work described in this thesis is the application of computers in industrial design. The central theme is twofold: first the development of techniques and tools for defining the geometry of a product and entering it into a computer; second, the development of techniques to generate high quality images of the entered product. In the first two chapters an introduction to these topics is given.

In chapter 1, an overview is presented of techniques for geometric modelling. From these techniques. Constructive Solid Geometry (CSG), a major technique in solid modelling, was chosen as a basis for further development. In CSG, an object is defined by applying the Boolean operations union, difference and intersection on transformed (translated, rotated, scaled) instances of a set of primitive objects, such as sphere, block and cylinder. It was chosen here because it offers a hierarchical approach to the definition of geometry, and it guarantees a valid and consistent description of the model.

Computer graphics plays an important role in geometric modelling. During the input of the model, graphical feedback is indispensable, because this enables the user to check whether the entered information has lead to the desired geometric model. Preferably, such pictures have

(10)

X l l Preface

to be generated within seconds, if necessary at the cost of the quality of the image.

Application of CAD in industrial design, however, also requires that high quality renderings of the geometric model can be made. High quality renderings are routinely used in industrial design, not only for presentation, b u t also to judge the aesthetic quality of the designed object. So, just as a mechanical engineer wants a package to evaluate the mechanical properties of his design, so an industrial designer needs one to generate accurate and realistic images of his object. Such images can partly replace the traditional photographs of prototypes.

Ray tracing was chosen for generating such images. This technique is described in chapter 2. The realism of images generated w i t h it is unmatched, because optical effects such as cast shadows, mirroring reflection and transparency can be handled easily, and also because the exact representation of the surface of the geometric model does not have to be converted into a polygon approximation. Further, the r a y tracing technique can easily be adapted to deal with models defined with CSG.

The geometric coverage of solid modellers using CSG is limited by the set of basic volumes t h a t it provides. A simple standard set of primi-tives does not suffice for application in industrial design, because here often free-form surfaces are used. The main subject of this thesis, treated in chapter 3 to 6, is therefore the extension of the geometric coverage of solid modellers using ray tracing. This requires, as is shown in chapter 2, the development of algorithms for calculating the intersections of a straight line w i t h a solid object.

In chapter 3, intersection algorithms are described for general prisms and surfaces of revolution. Chapter 4 is devoted to volumes t h a t result from sweeping a sphere through space. The definition and display of blends and fillets for cylinders and spheres is discussed in chapter 5. In chapter 6 an attempt is described to integrate free-form surface and solid modelling techniques. An important part of a geometric modeller t h a t often determines its acceptance is the user interface. In chapter 7 a procedural modelling language is presented t h a t allows a compact description of regular structures in geometric models. Finally, in chapter 8 the results are summarized and discussed.

(11)

1

1

Geometric modelling

1.1 I n t r o d u c t i o n

Most activities within a system for CAD/CAM (Computer Aided Design, Computer Aided Manufacturing) involve elaborate manipula-tions of geometric data. Generation of drawings, calculation of cutter tool paths, and calculation of mass properties of objects all require geometric information. The capabilities of a CAD/CAM-system are therefore strongly dependent on the type of representation of geometric data it provides, arid on the information that can be deduced from this representation.

A geometric modeller is that part of a CAD/CAM-system that takes care of the input, storage and conversion of geometric information. It occupies a central position in most CAD/CAM-systems because nearly all application programs use geometric information supplied by the modeller. A geometric modeller has to meet a large set of requirements that can be summarized as follows.

— The geometric coverage, i.e. the range of shapes that can be represented, should be adequate for the area of application where the modeller is to be used. In architecture and mechanical engineer-ing, almost all objects are bounded by planar and quadric surfaces, whereas in industrial design free-form surfaces are usual.

— The system has to provide easy-to-use and efficient tools for creat-ing and editcreat-ing geometric models.

— The internal representation should be complete and reliable, i.e. the stored information should provide accurate answers to geometric queries within a reasonable time. The time required for supplying geometric information, and the amount of data to be stored should be within reasonable bounds.

In spite of the progress resulting from the intensive research of the past 10 years, none of the currently available modelling techniques

(12)

2 Geometric modelling

meets all requirements simultaneously, presumably because these requirements are, at least partly, conflicting. In this chapter an over-view is given of the main representation schemes employed in geometric modelling. A thorough treatment can be found in [REQU80]*.

1.2 Fundamental techniques

The simplest modelling technique is wire-frame modelling, in which an object is represented as a set of lines ("wires") in space, representing its edges. This technique is a natural extension of 2-D drawing. The application of such models is limited, because they do not always pro-duce valid objects, and their interpretation is often ambiguous (Fig. 1.1). For instance, hidden lines removal is not possible in the absence of surface information.

Figure 1.1. Ambiguous wire-frame with three interpretations

(13)

Fundamental techniques 3

A logical next step is surface modelling. The object is represented by a collection of surface elements. Several types of elements can be used: fiat surfaces (polygons), analytical surfaces (for instance parts of spheres or cylinders) or more general free-form surfaces. Well-known techniques for defining such surfaces are the Bézier and B-spline methods. The input here is a mesh of control-points, which is con-verted to a smooth surface that either approximates or interpolates this mesh (Fig. 1.2). Extensive surveys of surface modelling techniques can be found in [FAUX79] and [BOHM84]. The shape domain is only lim-ited by the effort needed to enter enough control-points. Surface modelling is often used for aircraft and car design.

Figure 1.2. Control-point mesh and generated surface

However, the user is responsible for the validity of the resulting shape, since phenomena such as self-intersecting surfaces are usually not detected b y surface modelling systems, and there can be no guarantee t h a t the entered surfaces will enclose a bounded volume.

Solid modelling techniques, on the contrary, aim at the consistent and unambiguous representation of rigid solid objects. This is especially important if the output of the modeller is the input for another pro-gram, for instance one for numerical control. The requirement imposed is surprisingly simple: it m u s t be possible to determine for each point in space whether it is inside, outside or on the boundary of the solid object of interest. Only if this requirement is met, are opera-tions such as calculating the mass properties of an object possible.

(14)

4 Geometric modelling

Summarizing, three methods are used for describing the shape of objects: wire-frame modelling, surface modelling and solid modelling. These methods can be characterized by the basic elements used: lines (1-D), surfaces (2-D) and volumes (3-D). Each of these techniques has its own strengths, but solid modelling is the only one that guaran-tees a consistent and unambiguous description. This ensures that solid modelling will play a central role in the integrated CAD/CAM systems of the future.

1.3 Solid m o d e l l i n g

The three major representation schemes in solid modelling are Con-structive Solid Geometry, Boundary Representation, and Spatial Enumeration.

In Constructive Solid Geometry (CSG) the user is provided with a set of elementary volumes (or primitive objects) such as block, cylinder and sphere , that can be instantiated. These objects can be positioned and manipulated by applying transformations such as translation, rotation and scaling. Complex objects are defined by applying the Boolean operations union, difference and intersection on pairs of (com-posite or primitive) objects (Fig. 1.3). If the primitive objects have valid and consistent representations, then the CSG-approach guarantees that composite objects that result from transforming and combining these primitive objects are valid and consistent as well [REQU80]. A model defined by Constructive Solid Geometry is usually stored as a binary tree (Fig. 1.4). The transformed primitive objects are stored in the leaves of the tree, whereas Boolean operations are stored in nodes. A node represents the composite object that results from applying its Boolean operation to the objects on its left and right child-nodes, the root of the tree thus represents the complete object.

Several techniques can be used for the description of the primitive objects. The most common is via instantiation of a set of primitive volumes, but each of the other representation schemes discussed in this section can also be used. The primitives most often used are block, sphere, cylinder, cone, and torus, defined in a normalized form at the origin of the 3-D coordinate system used. An instance is created by specifying the name of the primitive and the parameters. For a

(15)

Solid modelling 5

block\J cylinder block-cylinder

cylinder-block blockf^ cylinder

Figure 1.3. Boolean operations

cylinder these would be the diameter and the height. The transforma-tions that are applied to these instances are usually represented b y a homogeneous 4 x 4 transformation matrix (see section 2.4). This matrix includes scaling information, so separate storage of sizes and diameters is not necessary.

A t a lower level the primitive volumes themselves can be represented as Boolean combinations of half-spaces. Here space is divided by a surface into two parts, one part t h a t is inside the object and one part t h a t is outside the object. A convenient w a y to describe a half-space is b y an inequality, here the set of points H that is inside the object is defined b y

H = { x lJF ( x ) < 0 }

(16)

6 Geometric modelling

I

■• difference -intersection «~. block cylinder

t

union

O

block

£l

cylinder

Figure 1.4. Object defined with CSG represented as a binary tree F ( x ) = Fix.y.z) = ax+by+cz+d

but quadric or higher order equations also occur.

Considering complex objects as composites of more elementary objects is close to the w a y designers think. However, an obvious drawback of the CSG approach is the limited shape domain: the geometric coverage is restricted by the repertoire of primitive solids available.

Sweep primitives are a powerful extension to the repertoire of primi-tive solids: some 2-D or 3-D set of points —in practice some closed surface or volume— is moved through space in some prescribed w a y and thereby sweeps a volume. A general sweep primitive is usually specified by a contour, a closed 2-D curve t h a t encloses a set of points, and a trajectory, a 3-D space curve. In addition the point in the plane of the contour, through which the trajectory must pass, has to be defined, and the orientation of the contour relative to the trajectory

(17)

Solid modelling 7

E

y \

F, V2

faces edges vertices

Fi F2 F3

H

E1-E2-E3 Ei-Eu-Ee ErEs-E, Ez-E5-E6 Vi V2

v

3 V, *1 Ï1 Ï *2 Ï2 Z2 *3 Ï3 Z3 xi. y4 zu Ei E2 E3 Eu Es E6 Vi-V2 V1-V3 V2-V3 V2-V, V3-V, V,-K

Figure 1.5. Boundary representation of simple object

has to be specified. To this end, a triple of coordinate axes must be assigned to each point of the trajectory. In [KLOK86] two possible choices for moving coordinate frames are discussed. This general definition of sweeping is efficient in the sense that little input is required, but it is ill adapted to frequently occurring geometric calcu-lations, such as determination of the intersections with lines and sur-faces. However, two special cases of sweeping that are easier to handle are important for many applications: surfaces of revolution defined by a circular trajectory, and prisms, defined by a straight line trajectory. In a Boundary Representation (B-rep), the object is represented via a complete and consistent description of the surfaces that bound it. In general, a B-rep consists of a structured list of faces, edges and vertices

(18)

8 Geometric modelling

(Fig. 1.5). Geometrical information, for instance the coordinates of the vertices, as well as topological information, such as references from an edge to the faces intersecting at the edge, is stored and updated during the generation of the object. Boundary Representations are suitable for the generation of line drawings, and for the implementation of local operations, such as displacing a vertex or smoothing an edge, because all information on edges is explicitly available.

Figure 1.6. Example of spatial enumeration

Another representation scheme is Spatial Enumeration (SE-rep). Here the space embedding the object is divided into many small cubes, called voxels, and for each voxel a record exists of whether or not it belongs to the object (Fig. 1.6). A SE-rep requires a huge amount of data, if an accurate approximation of the model is desired. The amount of data can be reduced with octree methods [MEAG84]. The basic notion here is to subdivide space only at those locations where more detail is required. An octree representation can be obtained by applying the following procedure. Initially the object is conceptually enclosed by a single box. If this box is empty, or completely filled with material then it is marked as such, else it is subdivided into eight smaller boxes. Next for each of those boxes this process is applied recursively until the required precision is achieved. Spatial Enumera-tion is often used for biological and medical applicaEnumera-tions, because the irregular structure of the objects studied cannot be described satisfac-torily with other methods.

(19)

Solid modelling 9

The properties of the representation schemes discussed can be summar-ized as follows. The CSG representation is compact and guaranteed to be consistent. The B-rep is a more data-oriented representation, which is better suited for use by application programs. However, this representation requires much more storage, and manual input of such a model is a tedious task. The same holds, even to a greater extent, for the SE-rep.

None of these representation schemes is superior in all aspects, so mul-tiple representations of the same object are often used in CAD-systems. For instance, the user may be required to enter objects using CSG. This representation is stored, and also converted to a boundary model that is used for the applications. The conversion from CSG to Boundary Representation is not trivial and can be time-consuming, even if only planar surface elements are used.

(20)

11

2

Ray tracing

2.1 I n t r o d u c t i o n

Ray tracing is one of the oldest techniques for generating shaded pic-tures of 3-D objects [APPE68. MATH68]. However, its wide applicabil-ity is still unmatched by other techniques. In this chapter an overview is given of ray tracing. The basic technique is described in section 2. Section 3 is devoted to the crucial step in ray tracing, the calculation of the intersections of a line with an object. Some techniques for improv-ing the efficiency are discussed in section 4. Section 5 is devoted to the application of ray tracing in solid modelling, together with an over-view of the techniques described in this thesis. Section 6 describes an implementation of a solid modeller using ray tracing that was used as a test-bed for those techniques.

2.2 T h e b a s i c p r i n c i p l e

Ray tracing is based on intersecting the object with a bundle of rays. The simplest application is generating a shaded image of an object (Fig. 2.1). Suppose an eye-point and a geometric model of the object have been defined. An image of this object on a raster display, located between eye-point and object, can be generated by applying the follow-ing algorithm for each pixel (picture element) of the raster display. First a r a y (line) is calculated through eye-point and pixel. Next the intersections of this ray with the geometric model are calculated and sorted on depth. The intersection point closest to the eye-point belongs to the visible surface. A shading model [NEWM79. FOLE82] is applied to calculate the colour and intensity of the surface at the point of intersection. This colour and intensity are assigned to the pixel, or, if no objects are intersected by the ray, a background value is assigned. Simple shaded images can be generated much faster b y projective hid-den surface algorithms, such as depth-priority or scan-line algorithms

(21)

12 Ray tracing

Figure 2 . 1 . Ray tracing for generating shaded images

[NEWM79, FOLE82], because these algorithms exploit coherence in the geometric model and the image to reduce calculation times. However, these techniques are inadequate when the aim is high realism. Ray tracing provides a simple and elegant w a y to handle optical effects such as cast shadows, reflection, and transparency [WHIT80]. Another advantage of ray tracing is that the exact, analytical definition of the model can be used, while projective hidden surface algorithms require the model to be approximated by polygons.

The principle of ray tracing is to trace back the light rays t h a t are sent from the surface to the observer. To simulate cast shadows, reflection, and transparency this tracing process is continued, i.e. when a surface is hit, additional (or secondary) rays are cast for further investigations (Fig. 2.2). Cast shadows are simulated by casting a secondary r a y starting from the point of intersection in the direction of the light source. If this ray intersects an object, then the light source is omitted from the shading calculation, because obviously the light source is obscured by this object. Reflection (or mirroring) and transparency are treated by reflecting or refracting the primary ray according to basic laws of optics, to determine which object is visible in or through the surface of the object. If these secondary rays themselves hit a t r a n -sparent or mirroring object, again new rays are cast. This process is repeated recursively until all rays hit an opaque object or nothing, or until the'contribution to the reflected light is below a threshold (Fig. 2.3).

(22)

The basic principle 13 shadowing \ / ^ ^ I /reflection

V/////////%/////////

\ refraction

Figure 2.2. Simulation of cast shadows, reflection, and transparency Ray tracing is a point sampling technique, which somewhat limits its application. For example, for shadows cast when finite light sources are used, tracing just one ray does not suffice to determine whether such a light source is obscured. This ray can only return a yes-or-no answer, while the light source might be partly obscured. A solution is provided b y the distributed ray tracing technique [COOK84a]. Here not just one r a y , but a bundle of rays is cast per pixel. For each of these rays, secondary rays are cast to evaluate cast shadows. These secon-dary r a y s are distributed randomly over the projected surface of the light source. If nine secondary rays are used, ten levels of coverage can be detected. These few levels might lead to contouring, b u t this is prevented by the random distribution of the rays. The same principle can also be applied to simulate depth of field and motion blur, and to prevent aliasing. Another solution to eliminate point sampling artifacts is to use cones instead of rays, and to integrate over the cross-section of these cones [AMAN84]. The geometric calculations involved, however, are much more complex than for distributed ray tracing.

(23)

14 Ray tracing

I

F i g u r e 2.3. Ray tracing applied recursively. Numbers indicate the level of recursion

The use of ray tracing is not limited to graphics. A Boundary Representation or a CSG-representation of an object can be converted to a Spatial Enumeration representation by firing a bundle of parallel rays to the object and converting the resulting intervals to rows of voxels. In a similar way mass properties can be calculated.

Note that all techniques described in this section (except r a y tracing with cones) involve only one crucial step, namely calculation the inter-sections of a line with an object. This makes ray tracing an elegant and flexible method.

2 . 3 R a y - o b j e c t i n t e r s e c t i o n

The calculation of the ray-object intersection is treated in more detail here, because intersection algorithms form a central part of this thesis.

(24)

Ray-object intersection 15

The intersection calculation is most easily done if the primitive instancing technique (chapter 1) is used. Intersecting a line with a unit-sphere, centred on the origin is easier than with an ellipsoid arbi-trarily located in space. Instances of basic volumes can be defined via a reference to the t y p e of volume (for instance a unit-sphere) and a transformation matrix M. When a picture has to be made, the view matrix (transformation from view to world coordinates) can be con-catenated w i t h t h e matrix M, so that a single transformation is sufficient for transformation from view to local coordinates. The rela-tion between a point xw = [xw , yw , zw , ww ] in world coordinates and a

point x = [x , y , z , w ] in local coordinates is x = xwM

The standard convention in computer graphics of representing points by row-vectors, and transforming by post-multiplication is followed here. Homogeneous coordinates are used, since they allow translations and rotations to be combined in a single 4X4 matrix. The Cartesian coordinates of x are [x /w , y /w , z lw ]. Further information on homo-geneous coordinates and their application in computer graphics can be found in texts on computer graphics, e.g. [NEWM79, FOLE82]. A ray (or line) can be defined by

[xw , yw , zv , 1] = [cvx , cVj,, <vz , 1] + [vwx , v^y , vwz , 0]t or

The point cw is here the starting point of the ray, the vector vw defines

the direction of the ray, and t is the parameter along the ray. The ray is transformed to the local coordinates of the object b y

c = cw M and v = vw M

giving

x = c+vf.

Next the intersection of this r a y with a sphere is considered. For this calculation, standard Cartesian coordinates are used. A sphere with radius 1, centred around the origin, is defined by

x2+y2+z2-l = 0 or

(25)

16 Ray tracing

Substitution of the ray equation gives (c+vO<c+vf ) - l = 0 or

( V T >2 + 2 ( v c > + ( c c - 1 ) = 0

Solving this equation gives two roots 11 and 12. If these are complex, the ray does not intersect the sphere. If they are coincident, the ray touches the sphere, and distinct real roots denote two intersection points. If ti<t2 then the interval (t t2) denotes the interval of the

ray that is inside the sphere. Because a linear transformation is used, no transformation on the t 's has to be applied to determine the coordi-nates of the intersection points in world-coordicoordi-nates, so these points Pu-i a n d pw 2 are

P«. l = Cw + vw t x and P»-2 = cw+vwf2

-Certain primitive objects, such as cylinders, blocks and cones cannot be described by a single equation, so the intersection calculation is slightly more complex. This is illustrated by the intersection of a ray with a standard cylinder. The cylinder is considered as a set of three bounded surfaces, a bounded cylindrical surface and two flat disks, i.e.

Surface equations Bounds z = 0 x2+y2 < 1

z = 1 x2+y2 < 1

x2+y2 = 1 0 ^ z < 1

The intersections are found by calculating for each surface the inter-section of the ray with that surface, and testing whether the points found are within its bounds. Finally 11 and t2 are sorted.

Intersection procedures have been published for several other types of surfaces, including general algebraic surfaces [HANR83], surfaces with a superimposed density distribution [BLIN82], bicubic patches [KAJI82], and procedurally defined objects [KAJI83].

Ray tracing can also be used for CSG models that are represented by a binary tree, as described in chapter 1. To determine the parts of the ray that are within the composite object, the tree is traversed in

(26)

post-Ray-object intersection 17

order. At leaves the ray is intersected with the primitive object, which gives a (possibly empty) set of intervals. At nodes, the intervals that are within t h e left and right branches of the node are determined, and then they are combined according to the operation of the node. The complex task of evaluating the CSG model is hereby reduced to a one-dimensional problem, which can be solved in a simple and straightfor-w a r d straightfor-w a y [ROTH82] (Fig. 2.4). left right

^K

let?U right leftC\ right left-right

Figure 2.4. Boolean evaluation applied to one-dimensional intervals

2 . 4 E f f i c i e n c y

The main disadvantage of ray tracing is its excessive time consumption. The brute force character of r a y tracing can be illustrated by a simple calculation. If the raster display has a resolution of N by N pixels and there are M objects in the scene, then at least N2M intersection

calculations have to be performed. If N = 500 and M = 100, then 25 million intersection computations have to be performed.

(27)

18 Ray tracing

However, the efficiency can be improved considerably by using addi-tional techniques. First, instead of sending primary rays to determine for each pixel which surface is visible, a standard hidden surface algo-rithm can be used [WEGH84]. The results of this preprocessing are stored in a so-called item-buffer; for each pixel a number is stored that identifies the visible surface. The information in the item-buffer is equivalent to the result returned by the primary rays, but achieved at a much lower cost.

Another strategy is to use simple enclosures, such as boxes or spheres, around (composite or primitive) objects. During the ray tracing pro-cess, rays are first tested against these enclosures to avoid a more com-plex intersection calculation of the ray against the object(s) in the box [RUBI80, ROTH80]. In [WEGH84] a method for the optimal selection of bounding volumes is described.

In [GLAS84.TAMM84] the use of an octree as a spatial index is pro-posed. Starting with one cube that contains the whole scene, space is recursively subdivided into smaller cubes, until each cube contains a minimum number of objects or has a certain minimal size. The rays are first tested against cubes out of this data-structure to enable fast selection of candidate objects for intersection.

Coherence in the image-plane can also be used to improve the efficiency for primary rays. Enclosures are first calculated around primitive volumes, and these are then used to subdivide the image-plane into rectangles, where each rectangle encloses a sub-set of all objects. Next the image is made by evaluating the pixels within each rectangle. Only the objects enclosed by the current rectangle are considered for inter-section with primary rays, and the remainder of the model is ignored, thereby considerably improving the efficiency. This technique works also well for CSG-defined objects (see section 2.3), here f or each rec-tangle the binary tree is reduced by pruning all branches that are out-side the current rectangle [WOOD82. BRON84].

As well as improving the efficiency of the intersection calculation, the number of pixels that are evaluated can be reduced. Low resolution pictures can be used as a preview. In the stepwise refinement algo-rithm [BRON84, JANS84] 4mage-coherence_is exploited to reduce the number of evaluated pixels further. This algorithm starts by comput-ing the image at a low resolution, e.g. with squares of 8 X 8 pixels, and

(28)

Efficiency 19

subsequently refines this image to one with a higher resolution by sub-division of these squares into four sub-squares. The intensities of neighbouring sub-squares are compared, and intensities are only recom-puted if these are significantly different, under the assumption that areas with uniform shade belong to the background or a uniformly shaded surface. The subdivision process is continued until the final user-specified resolution is reached. It is possible to continue the pro-cess to sub-pixel level, resulting in an anti-aliased image. A disadvan-tage of this algorithm is that fine details may be lost in the final image due to too sparse sampling. In the context of previewing, however, the user is usually satisfied with a fast-generated image of low resolution with possibly some minor inadequacies.

2.5 Solid m o d e l l i n g u s i n g r a y t r a c i n g

Solid modellers based on CSG, using ray tracing for high quality visu-alization, can be configured in two ways, according to the underlying representation scheme for the primitive volumes that is chosen. First, internally a single general scheme can be adopted to describe all primi-tive volumes. The most important technique here is to use a Boundary Representation, i.e. to define all primitive volumes by sets of similar surfaces (polygons or patches) that represent their boundaries. The use of polygons requires that curved surfaces are approximated by large numbers of (flat) polygons, hence the term facetted modelling for this approach. An advantage is that just one intersection algorithm is required. Optimization of such a system, by improving the software or implementing parts of it in special purpose hardware, is therefore rela-tively easy, because all effort can be concentrated on this single inter-section algorithm. Further, fast visualization algorithms that use pro-jective methods also use approximations of objects by polygons [ATHE83, BRON85b, JANS85]. The use of the same geometric represen-tation for both fast visualization and ray tracing simplifies and unifies the total system. Another advantage is that the shape domain of the system can be extended without modification of the ray tracing software, because new primitives are implemented by adding algo-rithms that convert these new primitives to polygon approximations. The second approach is to use primitive instancing to represent primi-tive volumes, as described in section 1.3 and 2.3. Each type of

(29)

20 Ray tracing

primitive volume is treated separately here, i.e. for each type (block. sphere, cylinder, etc.) a special intersection algorithm has to be pro-vided. With this approach far less data per object are required than in facetted modelling. As an example, the exact representation of a sphere requires just four real numbers, while hundreds of polygons, each requiring several real numbers, are needed for a reasonable approximation. Obviously, it is easier and faster to calculate the inter-sections of a ray with an exact sphere than with a mosaic of polygons. Further, the use of the exact representation guarantees a smooth result, while the use of too few polygons gives a facetted appearance of the objects.

The second approach was used for the work described in this thesis. mainly because it gives better image quality. However, a simple stan-dard set of primitive volumes does not suffice for application in indus-trial design, because here free-form surfaces are often needed. The main subject of the work described in this thesis is therefore the exten-sion of the shape domain of solid modellers using ray tracing by developing intersection algorithms for new types of primitive volumes. The selection of new types of primitive volumes was guided by two considerations; first, these new types should cover shapes that fre-quently occur in design, and second, it should be possible to develop a reasonable efficient intersection algorithm. Sweep primitives, as men-tioned in chapter 1, are an obvious choice, because many shapes that are used in practice can be conveniently described as sweep objects. For practical application of sweeping, restrictions can be imposed on the shape of the contour or the trajectory. The types of shapes that result are useful in practice, and the corresponding intersection algo-rithms are much simpler than for general sweeping. In chapter 3, three types of sweeping are discussed where the shape of the trajectory is restricted; translational sweeping, conic sweeping and rotational sweep-ing. In chapter 4, sphere sweeping is discussed. Here the shape of the trajectory can be chosen freely, but the contour (the object) to be swept is fixed. Chapter 5 deals with blends, localized smooth transi-tions between primitive objects.

The topics of chapter 6 and 7 are less directly related to ray tracing. In chapter 6 a technique for defining solid objects bounded by free-form surfaces is described. The bicubic patch was selected here as a

(30)

Solid modelling using ray tracing 21

basic element, because this is a reasonable compromise between mathematical complexity and freedom of shape. User-input of geometric models is discussed in chapter 7, where a procedural model-ling language is presented.

2.6 RAYMO

A system in the spirit of [ROTH82] was implemented that served as a test-bed for the new modelling and ray tracing techniques described in this thesis. This system was called RAYMO, which is derived from the terms ray tracing and modelling. The ray tracing algorithm was used to generate shaded pictures of objects defined by Constructive Solid Geometry. In this section an overview of the initial version of this system is given.

For the definition of the solid model the following options can be used. A first set of primitive objects consists of block, cylinder, sphere, cone and torus. These objects can be translated, rotated, scaled, and skewed. Skewing changes the angles between the object axes. The objects can be combined with the Boolean operations union, intersec-tion and difference. Further, each object is assigned a code that identifies the material texture of the object. This code can be specified by the user, otherwise a default value is used. The properties of the materials (e.g. reflection and colour) are specified in the drawing phase. To specify the primitive objects that constitute the solid model the user has to prepare a file that contains a sequence of commands, i.e. mnemonics that describe the type of object or manipulation, followed by parameters. As an example, a cylinder with a rounded top is specified by

cyl10 20 sph 10

mov z 20

The meaning of these commands is obvious. The Boolean combination of these primitives is specified in the drawing phase by entering a Boolean expression, which permits the user to draw various Boolean combinations of the component primitives. This type of interface

(31)

22 Ray tracing

worked well for simple objects (say less than 25 primitive volumes) and test purposes. Further, experience of the system in student courses revealed that such a set of simple commands is relatively easy to learn and understand by novice users. For more complex objects, however, more powerful means are required for the input of the model. This has lead to the development of SML (Solid Modelling Language), described in chapter 7.

JfiSk JÊSÊL J f i k

* * •

V k ^ ^ ^ ^HÉ^^^F V É ^ ^ ^

É3Ê^" ÊSSÊf* 42BP*>

A- • r mt

^ ■ ^ ^B» ^ B

-Figure 2.5. Nine pictures of the same pot with different illuminations and material properties

After the input of the geometry of the object, shaded pictures can be made of that object. These shaded pictures are defined by three sets of parameters that control the projection, the illumination, and the sur-face properties. Because it is hard to guess at the outset what the optimal setting of these parameters will be, an interactive interface was implemented. When the system is started, all parameters are ini-tialized to their default values. The user can give a command to draw a shaded picture, and, after evaluation of the result, change the param-eters, and redraw the picture. This process is repeated until the user is satisfied. Each parameter has a corresponding three-letter command,

(32)

RAYMO 23

which can be invoked in three modes: a new setting can be entered, the current setting can be requested, or the setting can be reset to a default value.

Figure 2.6. Examples of optical effects

The projection is controlled with three parameters: the eye-point (where to look from), the centre-point (where to look to), and the viewing angle. Further a choice can be made between parallel and per-spective projection. Two types of illumination can be used; first, ambient light to account for non-directed uniform background light, and second, point sources of light. For each light-source the lumi-nance, and the direction (source at infinity) or position (local light-source) can be specified. For calculating the intensity and colour of the surfaces, the Torrance-Sparrow shading model [BLIN77] is used. The values of the parameters used by this model can be selected by the user. For each material, the coefficients for diffuse and specular reflection, the roughness of the surface, and the colour can be modified (Fig. 2.5). Further options include the generation of shadows, and display of mirroring and transparent objects with refraction (Fig. 2.6) [WHIT80].

(33)

24 Ray tracing

Several techniques were implemented to improve the efficiency [ROTH82.BRON84, JANS84]. The option for low resolution pictures was an especially useful tool, because this reduced image generation time, during the definition phase of the model and the picture, from hours to minutes.

The package is written in Pascal and runs on a DEC PDP-11/44 under RSX/llM. The graphics device used is a Grinnell GMR 270 image p r o -cessing display system w i t h a 5 1 2 x 5 1 2 x 8 frame buffer. The pictures shown in thig thesis were taken directly from screen.

(34)

25

3

Translational and rotational sweeping

3.1 I n t r o d u c t i o n

In this chapter intersection algorithms are presented for three types of sweep defined objects with a simple trajectory. For objects defined by translational sweeping (prisms) the trajectory is a straight line, and for objects defined by rotational sweeping (surfaces of revolution) a circle. Conic sweeping is similar to translational sweeping, but the contour is scaled as it is swept along the trajectory. The technique described here is similar to that developed by Kajiya [KAJI83]: in both the 3-D intersection problem is reduced to a 2-D problem. The difference lies in the description of the contour; Kajiya uses strip trees (a piecewise linear curve), while the technique described here uses cubic splines.

3.2 O b j e c t d e f i n i t i o n

An instance of a simple sweep defined object can be represented by three entities;

— a specification of the type of sweeping, — a transformation matrix M,

— a plane contour.

The first item is one of the three types: translational, rotational, or conic sweeping. Figure 3.1 shows three objects, generated by perform-ing these three operations on the same contour. Formal descriptions will be given in the following sections. In the chosen instancing tech-nique, each object is defined in a local axis frame in a standard way. For example, in translational sweeping the contour lies initially in the base z = 0 and is translated to lie finally in the plane z = 1. This enables the use of a standard local intersection algorithm. Information on the size and position of each object is stored in the associated 4 x 4

(35)

26 Translational and rotational sweeping

Figure 3.1. Objects denned by translational, rotational, and conic sweeping homogeneous'matrix M.

A convenient w a y to define a free form contour is to use splines. Here the contour is entered as a sequence of points, along with a specification of the kind of curve desired. Next a smooth curve is gen-erated that approximates or interpolates these points by applying a technique such as the Bézier or B-spline method [FAUX79. BOHM84]. A cubic B-spline curve approximating the entered points is continuous in curvature, and mathematically simple, and thus provides a good compromize between mathematical complexity and ease and flexibility of use.

Because the intersection procedures operate on the piecewise polyno-mial description of the splines, the input has to be converted into a linear list of segments, each defining a piece of the curve. These seg-ments are defined in a 2-D axis frame ( u , v ). A segment is defined as the set of points r ( j )= [ru (s ), rv ( J )] with 0 < s < 1. As an example of

the conversion from control-points to the piecewise polynomial representation, suppose that P0. Pi. P2 , and P% are four consecutive

(36)

Object definition 27 - 1 3 - 3 1 3 - 6 0 4 - 3 3 3 1 1 0 0 0 ^ 0 Pi Pi P3

uniform cubic B-spline, then the polynomial representation of the corresponding span is

r ( j ) = [s3 s2 s 1]

The intersection algorithms require the following information for each segment:

— the degree of the two polynomials ru (s ) and rv (s ), which is three

if a cubic spline is used;

— the coefficients of ru (s ) and rv (s );

— a rectangle (um i n, umdiX. vm i n, vm a x) that encloses the segment.

Instead of a description of the contour itself, a pointer to the first ele-ment can be included in the description of the object, which enables several objects (with different M's) to point to the same contour, resulting in considerable savings in memory for regular patterns of objects.

Just as it is possible to give a global description of a sweep-defined object, so is it equally possible to give a general outline of the intersec-tion algorithm. The algorithm consists of the following steps:

— transform the ray to local coordinates;

— project the ray on the local (u , v ) contour plane;

— calculate the intersections of the projected ray w i t h the contour; — determine, if applicable, intersections with the base and cap plane; — calculate normals at intersection points;

— transform the results back, to view coordinates.

In t h e following sections, this algorithm is elaborated for each t y p e of object.

3.3 T r a n s l a t i o n a l s w e e p i n g

The local geometry of an object defined by translational sweeping is shown in Fig. 3.2. The boundary consists of the following parts: — a base plane, consisting of the points inside the contour, with the u

(37)

-28 Translational and rotational sweeping

and v -axis coinciding with the x - and y -axis, and z = 0; — a cap plane, defined similarly, but with z = 1;

— the side surfaces of the object. A transformed ray is defined by

[x ,y ,z ] = [cx, cy , cz ] + [vx . vy . vz ] t. (3.1)

The intersections of this ray with the object are determined as follows. First, the parameter values t\ and r2 where the ray intersects the planes z = 0 and z = 1 are calculated from

ti= -cz/vz, t2= l-cz/vz.

These values are stored in increasing order in an array IntPnt of inter-section points. The smaller value is denoted t min, the larger by t max. Kajiya [KAJI83] proposes an inside-contour test to check whether these points are valid intersection points. This test, however, can be omit-ted, as is shown later.

F i g u r e 3.2. Translational sweeping

Next the intersection points with the side surfaces are determined by processing the segments that occur in the list. The projection of the ray on the (u , v )-plane is

(38)

Translational sweeping 29

For each segment a simple rectangle test is carried out to determine whether t h i s ray intersects the segment. Denoting the left-hand side of (3.2) b y P(u,v), then if vxvy>0. intersection occurs if

^("min. vm a x) and P(vmax. vm i n) have different signs. If vxvy < 0 ,

intersection occurs if P(.umin, vm i n) and P(,umix, vm a x) have different

signs (Fig. 3.3).

IUmin, V/naxJ

[UmaxVmin] J ^

'umaxymaxl

l Umin i Vminl

Figure 3.3. Rectangle test applied for translational and conic sweeping If intersection occurs, the polynomials ru (s ) and rv ( J ) of the segment

are substituted in (3.2), resulting in an equation in s. The degree of this polynomial equation is equal to the degree of the contour. If cubic splines are used, the roots can be found analytically. Coincident roots correspond w i t h the ray touching the boundary of object. These roots can be ignored, because in most applications only intersections w i t h the volume are relevant. For each root s0 satisfying 0^s0< 1,

t = (rB (s Q) — cx )/vx

is inserted into its proper ordered position in the array of intersection points provided that t > t ^^ After each segment has been tested in this w a y , a sorted array of n intersection points is obtained. The posi-tion of tmax in the array is denoted by im a x- For simplicity, in the

remainder of this section £m a x is assumed to be the intersection point

w i t h the plane z = 0. Selection of the valid intersection points is done w i t h the following algorithm:

(39)

30 Translational and rotational sweeping

i f odd (n —i m a x) t h e n n := imax else n := imax— 1;

i f odd (ra ) t h e n begin

n := n — 1;

for i := 1 t o n do IntPnt[i] := 7/ifPnf [i + l ] end;

This algorithm is based on the fact that the spaces defined by z ^ 0 a n d

z ^ 1, and the area within the (extended) side surfaces can be viewed

as half-spaces. The object can then be viewed as the intersection of these three half-spaces. Further, solid objects have the property t h a t the number of points of intersection of a line with such objects is even. If now the number of intersections of the r a y with the side surfaces beyond t m a x is odd, then the intersection point with the plane z — 0 is

inside the half-space planes and thus a valid point. If so, only t h e points beyond the plane z = 0 are deleted, else these points and t h e base point IntPnt [i m a x] are deleted. The first point of intersection

IntPnt [l], the intersection point of the r a y with the cap plane, is

treated similarly. If the number of intersection points that result from the previous step is odd, then IntPnt [ l ] is invalid and t h u s deleted. After applying this algorithm, the number of intersection points is even. The inside-contour test, which is necessary if the object is viewed as a boundary model, can be omitted for the intersection points with base and cap plane, if the object is viewed as a Boolean combination of half-spaces.

When vx = 0 and vy = 0 (top view), or when vz = 0 (side view) t h e

preceding method breaks down. A practical solution is to give these parameters, if necessary, a very small absolute value and process t h e m further in the standard way.

Calculation of the normal [nx ,ny,nz] at the intersection points is

trivial. For points on the side surfaces, the corresponding roots s0 a n d

the differentials of the polynomials ru (.s ) and rv (s ) are used:

d rv( j0) dr„Cr0)

d j ' ds

[nx.ny.nz\- [ — — . — . OJ

3.4 C o n i c s w e e p i n g

(40)

Conic sweeping 31

swept along the z -axis. An simple extension of the translation sweep is to combine translation of the contour with scaling, by multiplying the x - and y -coordinates by z . This is the basic idea of conic sweep-ing. Figure 3.4 shows an object resulting from a conic sweep.

Figure 3.4. Conic sweeping

Its boundary surface consists of two parts: the cap plane, defined as for translational sweeping, and the side surface. The local contour axis frame (u . v ) is a function of z . The relation of a point [x , y , z ] on a side surface w i t h the (u , v )-coordinates is defined by

x = zu and y = zv.

Substitution of t h e transformed r a y (3.1) gives

(yx t +cx ) = (yz t +cz )u and

(Vyt+Cy) = (yzt+cz)v.

Elimination of t from these equations yields

(cyVz—CzVj)u — (CXVZ— CzVx) v + ( cxVy— CyVx) = 0 .

Thus, the projected ray can be written as a linear equation in u and v , which can be processed in the same w a y as for translational sweeping. The value of t for a root 5 o can be calculated with

(41)

32 Translational and rotational sweeping

ru (so)cz—cx

vx-ru(s0)vz

Treatment of the cap plane is simple. Only points satisfying *min^ t <*max (with t min and £m a x as defined in section 3.3) are stored

in the array of intersection points. If the total number of intersection points is odd, then the point where the ray intersects the cap plane is included.

Figure 3.5. Calculation of the normal n for conic sweeping

Calculation of the normal is slightly more complex than for transla-tional sweeping (Fig. 3.5). A normal n on a side surface is perpendicu-lar to a tangent vector a of the contour and to a vector b joining the origin and the point rCr0)- These follow from

dr„Cy0) drv bo) . ,

a = [ — . — , 0] , and

ós ds

b = [ru(s0), rv(.s0), 1 ] .

The normal is the vector product of a and b : n = a X b .

3.5 Rotational sweeping

(42)

Rotational sweeping 33

3.6. The local v-axis is coincident with the z-axis, while the w-axis rotates in the XOY -plane. The problem now is to project a ray. as defined in (3.1), onto the (u , v )-plane.

Figure 3.6. Rotational sweeping

Consider the (w, v )plane when the angle between the u axis and x -axis has a certain value 0. W h a t is known about the intersection point

[x.y.z] of the ray with the ( w . v ) - p l a n e ? First, since v = z , the

value of t is

t = ( v - c j / vz (3.3)

The distance of the point [x.y.z] from the z -axis is u, so

u2 = x2 + y2 or

u 2 = (cx +vx t )2 + (c, + vy t )2. (3.4)

Substitution of (3.3) into (3.4) yields

a v2 + bv + c - du2 = 0 with (3.5)

a = v2 + v2.

b = 2(vz(yxcx+VyCy)— cza), c = (v*cz— vzcx)2 + (yycz-vzCy)2.

(43)

34 Translational and rotational sweeping

d = v / .

Again an equation in u and v , now of second degree, is obtained. S u b -stitution of the polynomials ru (s ) and rv is ) of degree d yields an

equation in s of degree 2d. The roots of this equation are the parame-ter values of the contour where the ray inparame-tersects the object. When cubic splines are used, the roots of a sixth degree equation have to be found, which has to be done numerically.

The problem t h a t m u s t be solved is to locate the real roots of a high-degree polynomial within the interval [0,1]. Additionally, it is assumed that no a priori knowledge about the number of roots and their position exists. In rendering the object in scan-line order without optical effects the coherence between adjacent rays might be used, b u t in ray tracing w i t h simulated effects such as cast shadows, t r a n -sparency etc., the coherence is minimal, due to the more or less random w a y in which the rays are cast. Another important requirement on the root finder is an almost unconditional stability, since each error might result in an erroneously coloured pixel.

Several techniques for locating roots were studied and implemented. The best results, in terms of computational efficiency, were achieved w i t h Sturm's method [RALS78]. A short outline is given here. The kernel of the method is formed by the Sturm sequence. Consider the sequence of functions Fi (x ), i — 1, . . . , m where

JF1( x ) = Fix),

F2ix) = F ' ( x ) ,

Fj_1( x ) = QJ-I(X)FJ(X)- Fj+1(x). j = 2, . . . , m - l .

Fm-i(x ) = Qm- i O )Fm (x ),

where Q,/-iCx) is the quotient and i ^+ 1( x ) is the negative of t h e

remainder when Fj-iix") is divided by Fj ( x ) , and m = d + 1

id = degree of polynomial). If V ( x0) is defined as the number of

changes of sign of -F,(x0), i = 1, . . . ,m, then the number of distinct

real zeros of the polynomial Fix) in the interval [a, b] is equal to

V(a)-VQ>\

This theorem can be used to locate the roots of a polynomial b y repeated subdivision of the interval [0,1]. For each sub-interval the number of roots n is counted. If n ^ 2 , the interval is divided further,

(44)

Rotational sweeping 35

if n = l . straightforward bisection (by checking the sign of .FOc)) is used, else the interval is omitted. The process is continued until the intervals have a predefined minimal length. The calculation of V (x ) can be speeded up b y using the recurrence relation between the func-tions F; (x ). Instead of calculating the value of each Ft Gc ) separately,

the linear terms Qj (.x ) and the constant Qm can be used:

Fm( x ) : = Qm(x):

Fm-i(x} Fj-idx)

= Qm^(x)Fm(x>.

= Qj^{x)F){x)- FJ+1U). j = m - 1 , . . . ,2

F i g u r e 3.7. Projected r a y for rotational sweeping, with several rectangles. Numbers in rectangles refer to the algorithm in section 3.5, thick edges and dotted vertices denote tested items.

To bypass unnecessary determinations of, and working with, sixth-degree polynomials, a simple rectangle test is applied first. Equation (3.5) defines a hyperbola. The computation is simplified, without loss of generality, by restricting u to nonnegative values. The base point

[hu , hv ] of the hyperbola is given by

K = iiAac-b^/AadY1,

hv = ~b/2a.

(45)

36 Translational and rotational sweeping

different relative positions of the rectangle around the tested segment. Numbers in rectangles refer to the following test, and thick edges and dotted vertices denote tested items. The test applied, assuming t h a t the values for a ,b , c , d, hu, and hv are defined, is

f u n c t i o n OutRect: boolean ;

{ OutRect is t r u e if the rectangle ( am i n. um a x, vm i n, vm a x ) }

{ is not intersected by the projected ray with equation } { av2 + bv + c - du2 = 0 }

function InsHyp (w , v : real): boolean ; {InsHyp is true, if the point [u , v ] } {lies inside the hyperbola }

begin

InsHyp := (a*v +b )*v + c - d*it*u < 0

end; {InsHyp} begin

if umiX<hu t h e n OutRect := trne{ case 1 } else if vm i n> / iv t h e n begin i f InsHyp (umax,vmia) t h e n begin if Umin>hu

t h e n OutRect := InsHyp (wmin, vmax){ case 2,3 }

else OutRect := false{ case 4 } end else OutRect := true { case 5 } end else

(46)

Rotational sweeping 37 begin i f vmax<-'lv t h e n begin if InsHyp(umzx, vm a x) t h e n begin

t h e n OutRect := InsHyp(umin vmax){ case 6,7 }

else OutRect := false{ case 8 } end else OutRect := true [ case 9 } e n d else

i f InsHyp(umin, vm i n)

t h e n OutRect := InsHyp(umia, vm a x){ case 10,11 }

else OutRect := false{ case 12 } end

end; {OutRect}

If an intersection point is found, the resulting value of t is given by (3.3). The normal on the surface can then be determined as follows. The normal lies in the plane through the z-axis and the intersection point, so t h e projection of the normal on the plane z = 0 is given by:

nx = cx + vxt, ny = cy + vyt.

To determine nz , first a normal on the contour is calculated:

—drvCr0) _ d ru( j0)

"• * '

Uv

5T"

The z -component of the normal follows then from

nz nv = — or 0ix 2+ny 2 )* "" ( nx 2+ n / )% riy nz = — . nu

This is illustrated in Fig. 3.8. 3.6 D i s c u s s i o n

Some methods are presented for calculating the intersection of a ray w i t h objects defined by sweeping a spline contour along simple trajec-tories. Figure 3.9 to 3.11 show some examples of applications. The control knob, shown in Fig. 3.9, is a good example of the use of objects

(47)

38 Translational and rotational sweeping

Figure 3.8. Calculation of normal n for rotational sweeping

defined by sweeping as primitive elements in a solid modelling system. It was modelled b y taking the intersection of a rotational and a t r a n s -lational sweep. The red mark was made by subtracting a small sphere. Figure 3.10 shows a countersink bore, modelled by intersecting a cone and a conical sweep. Three light sources, cast shadows, and mirroring reflection were used. Figure 3.11 shows a glass, modelled by rotational sweeping.

It is hard to determine whether using splines is more efficient than using strip trees for the contour [KAJI83]. The definition with splines does require fewer evaluations for a contour, but the calculations involved per evaluation are more complex. However, images that are made with the method presented here are of a better quality, because no linear approximation of free-form contours is required.

Intersection of the ray with the base and cap planes can be handled easy and elegantly by viewing objects defined by translational sweep-ing as the intersection of three half spaces. By representsweep-ing a 3-D r a y by an equation in two variables, efficient rectangle tests can be developed that exploit the half-space nature of these equations.

Other sweep-defined objects that could, in principle, be handled by the methods described in this chapter can arise from generalizations of

(48)

Discussion 39

Figure 3.9. Control knob

(49)

40

'«•<•'.".

^«1»

Figure 3.11. Glass

conic sweeping. Instead of both the x - and y -coordinates being scaled together, each coordinate could be separately scaled by separate general functions of z. However, it would be more difficult to find meaningful applications for these kind of shapes than to develop the necessary algorithms. In contrast, general sweeping, i.e. sweeping a contour along an arbitrary trajectory in 3-D space, is an obviously useful extension. In the next chapter objects defined by sweeping a sphere are discussed as a partial and meaningful advance in this direction.

(50)

41

4

Sphere sweeping

4.1 I n t r o d u c t i o n

In the previous chapter it was shown that when constraints are imposed on the trajectory, simple and elegant intersection algorithms for objects defined by sweeping free-form contours can be developed. At the same time, the types of objects that can be defined with those techniques are quite useful in practice, despite the constraints on the shape of the trajectory. This suggests that it would be profitable to examine the natural counterpart of such objects: objects defined by sweeping a simple contour along a more general trajectory. The next question that arises is which type of contour is most convenient. The major problem in using free-form trajectories is that when the contour is swept along the trajectory, its orientation with respect to the trajectory has to be specified. A natural choice for the local axis-frame is the Frenet-axis-frame. In [BRON85a] an algorithm is presented for ray tracing generalized cylinders, i.e. objects defined by sweeping a free-form contour along a free-form trajectory, where the Frenet frame is used to fix the orientation of the contour. The initialization of this intersection algorithm requires the location of the roots of polyno-mials of degree 14 and 12 (or degree 6 and 2 if the trajectory is planar), and then the actual intersection points are located by subdivi-sion of the contour. However, specification of the orientation in space can be avoided, and a computationally less expensive algorithm can be developed, if the contour is replaced by a volume that is fully sym-metric, i.e. a sphere.

In this chapter objects that result from sweeping a sphere of varying radius along a 3-D trajectory are discussed. In section 2 this class of shapes is described more formally, and an intersection algorithm is given. In section 3 an algorithm is presented to eliminate invalid inter-section points that arise when the shape is self-intersecting. In inter-section 4 the use of splines both to define the trajectory and the varying

(51)

42 Sphere sweeping

radius is discussed. Again the spatial intersection problem can be transformed into the problem of locating the roots of a polynomial. In the last section, examples of applications are shown, and the results are discussed.

4.2 Intersection algorithm

A sphere can be defined by four entities: the coordinates (rx, ry. rz ) of

its centre r and its radius a. These entities are parametrized by a parameter u, with

"min ^ " ^ "max» and a function F(.x., u ) is defined by

F(x, u ) = I x— r(u ) 12 — a2(u ), where

Ipl = VjTp.

The equation F (x, u )= 0 defines a one-parameter family of spheres, resulting from sweeping a sphere from r(um i n) to r(um a x) along a tra-jectory r ( u ) , with radius a(w), as shown in Fig. 4.1. The swept volume is defined as follows: a point x lies inside the volume if there exists a value u for which F(x, u ) < 0 .

Figure 4.1. Shape definition: a parametrized sphere

The problem now is to calculate the intersection of a ray with this volume. Substitution of a ray defined by

(52)

STELLINGEN

1

Bij het afbeelden van geometrische modellen met behulp van straalvolgen is het gebruik van de exacte representatie van het model doelmatiger dan het gebruik van een lineaire benadering. 2

Het definiëren van afrondingen op basis van paren van halfruimtes is bruikbaar voor het afronden van randen, maar niet voor het afronden van hoekpunten.

- A.E. Middleditch en K.H. Sears,

Computer Graphics 19(3), 161-170, (1985). 3

Bij het gebruik in een modelleersysteem van objecten gedefinieerd door het bewegen van een contour langs een trajectorie, is het meestal toereikend om een eenvoudige (lineaire of kwadratische) representatie te gebruiken voor de contour en/of de trajectorie.

4

De huidige technieken voor het definiëren van geometrische modellen zijn goed geschikt voor het vastleggen van een ontwerp, maar minder bruikbaar voor het ontwikkelen van een ontwerp.

5

Voor het bepalen van de reële wortels van een polynoom in een begrensd interval zijn de methodes van Sturm en Descartes doelmatiger dan de methode van Laguerre.

- J.T. Kajiya, Computer Graphics 16(3), 245-254, (1982).

6

Bij geometrisch modelleren en computer grafiek zijn bijzondere gevallen, zoals bijvoorbeeld samenvallende vlakken, eerder regel dan uitzondering.

Cytaty

Powiązane dokumenty

Further, in the main case (large p 1 and small q), we are able to get an improvement by removing the restriction that the map constructed is 1-1 (Lemmas 10 and 11).. As for the

The most famous recent result is in the area of extending P t -sets and is due to Baker and Davenport [1], who used Diophan- tine approximation to show that the P 1 -set {1, 3, 8,

A necessary and sufficient conditions are given for the set of algebraic elements of a semisimplo commutative Banach algebra to be closed.. In this paper we are

From this it follows

The common “definition” of a set as a collection of distinct objects considered as an object itself turns out to be inadequate and leads to certain paradoxes (we will discuss that

[r]

In the rough set context, this approach would pose the problem of evaluating the truth state of a

For a differential inclusion with Lipschitz right hand side without state constraints, several papers [2, 5, 6, 9–11] yield results on the relaxation theorem and some other