10
SECOND EDITION omputer Graphics С Version Donald Hearn Department of Computer Science and National Center for Supercomputing Applications University of Illinois M. Pauline Baker National Center for Supercomputing Applications University of Illinois PRENTICE HALL Upper Saddle River, New Jersey 07458

SECOND EDITION omputer Graphics - GBV

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SECOND EDITION omputer Graphics - GBV

SECOND EDITION

omputer Graphics С Version

Donald Hearn Department of Computer Science and National Center for Supercomputing Applications University of Illinois

M. Pauline Baker National Center for Supercomputing Applications University of Illinois

PRENTICE HALL Upper Saddle River, New Jersey 07458

Page 2: SECOND EDITION omputer Graphics - GBV

Contents

PREFACE

1 1 1-1

1-2 1-3

1-4

1-5

1-6

1-7

1-8

2 2-1

A Survey of Computer Graphics Computer-Aided Design

Presentation Graphics

Computer Art

Entertainment

Education and Training

Visualization

Image Processing

Graphical User Interfaces

Overview of Graphics Systems

Video Display Devices Refresh Cathode-Ray Tubes Raster-Scan Displays Random-Scan Displays Color CRT Monitors Direct-View Storage Tubes Flat-Panel Displays Three-Dimensional Viewing Devices

xvii

2 4

11 13

18

21

25

32

34

35

36 37

40 41 42 45 45 49

2-2

2-3

2-4

2-5

2-6

2-7

Stereoscopic and Virtual-Reality Systems

Raster-Scan Systems Video Controller Raster-Scan Display Processor

Random-Scan Systems

Graphics Monitors and Workstations

Input Devices Keyboards Mouse Trackball and Spaceball

Joysticks Data Glove Digitizers Image Scanners Touch Panels

Light Pens

Voice Systems

Hard-Copy Devices Graphics Software Coordinate Representations Graphics Functions Software Standards

PHIGS Workstations

Summary

References

Exercises

50

53 53 55

56

57

60 61 61 63 63 64 64 67 68

70

70

72

75 76 77 78

79

79

81

81

VII

Page 3: SECOND EDITION omputer Graphics - GBV

Contents

3 Output Primitives 83

3-1 3-2

3-3 3-4 3-5

3-6

3-7

3-8 3-9 3-10

3-11

3-12 3-13 3-14

Points and Lines Line-Drawing Algorithms DDA Algorithm Bresenham's Line Algorithm Parallel Line Algorithms Loading the Frame Buffer Line Function Circle-Generating Algorithms Properties of Circles Midpoint Circle Algorithm Ellipse-Generating Algorithms Properties of Ellipses Midpoint Ellipse Algorithm Other Curves Conic Sections Polynomials and Spline Curves Parallel Curve Algorithms Curve Functions Pixel Addressing and Object Geometry Screen Grid Coordinates Maintaining Geometric Properties of Displayed Objects Filled-Area Primitives Scan-Line Polygon Fill Algorithm Inside-Outside Tests Scan-Line Fill of Curved Boundary Areas Boundary-Fill Algorithm Flood-Fill Algorithm Fill-Area Functions Cell Array Character Generation

84 86 87 88 92 94 95 97 97 98

102 102 103 110 110 112 112 113

114 114

114 117 117 125

126 127 130 131 131 131

Л 4-1

4-2 4-3

4-4

4-5

4-6

4-7 4-8

Summary Applications References Exercises

Attributes of Output Primitives

134 136 140 140

143

Line Attributes Line Type Line Width Pen and Brush Options Line Color Curve Attributes Color and Grayscale Levels Color Tables Grayscale Area-Fill Attributes Fill Styles Pattern Fill Soft Fill Character Attributes Text Attributes Marker Attributes Bundled Attributes Bundled Line Attributes Bundled Area-Fill Attributes Bundled Text Attributes Bundled Marker Attributes Inquiry Functions Antialiasing Supersampling Straight Line Segments Pixel-Weighting Masks

144 144 146 149 149 152 154 155 157 158 158 159 162 163 163 167 168 168 169 169 170 170 171

172 174

VIII

Page 4: SECOND EDITION omputer Graphics - GBV

Contents

Area Sampling Straight Line Segments 174 Filtering Techniques 174 Pixel Phasing 175 Compensating for Line Intensity Differences 175 Antialiasing Area Boundaries 176

Summary 178

References 180

Exercises 180

5 Two-Dimensional Geometric

Transformations 183 5-1 Basic Transformations 184

Translation 184 Rotation 186 Scaling 187 Matrix Representations and Homogeneous Coordinates 188

Composite Transformations 191 Translations 191 Rotations 191 Scalings 192 General Pivot-Point Rotation 192 General Fixed-Point Scaling 193 General Scaling Directions 193 Concatenation Properties 194 General Composite Transformations and Computational Efficiency 195

5-4 Other Transformations 201 Reflection 201

Shear 203

5-5 Transformations Between Coordinate Systems 205

5-2

5-3

5-6 Affine Transformations

Transformation Functions

5-8 Raster Methods for Transformations

Summary

References

Exercises

Two-Dimensional Viewing

208

208

210

212

213

213

216

6-1

6-2

6-3

6-4

6-5

6-6

6-7

6-8

6-9

6-10

6-11

The Viewing Pipeline

Viewing Coordinate Reference Frame

Window-to-Viewport Coordinate Transformation

Two-Dimensional Viewing Functions

Clipping Operations

Point Clipping

Line Clipping Cohen-Sutherland Line Clipping Liang-Barsky Line Clipping Nicholl-Lee-Nicholl Line Clipping Line Clipping Using Nonrectangular Clip Windows Splitting Concave Polygons

Polygon Clipping Sutherland-Hodgeman Polygon Clipping Weiler-Atherton Polygon Clipping Other Polygon-Clipping Algorithms

Curve Clipping

Text Clipping

Exterior Clipping

Summary

References

Exercises

217

219

220

222

224

225

225 226 230 233

235 235

237

238 242 243

244

244

245

245

248

248

IX

Page 5: SECOND EDITION omputer Graphics - GBV

Contents

7 Structures and Hierarchical Modeling 250

7-1 Structure Concepts Basic Structure Functions Setting Structure Attributes

7-2 Editing Structures Structure Lists and the Element Pointer Setting the Edit Mode Inserting Structure Elements Replacing Structure Elements Deleting Structure Elements Labeling Structure Elements Copying Elements from One Structure to Another

7-3 Basic Modeling Concepts Model Representations Symbol Hierarchies Modeling Packages

7-4 Hierarchical Modeling with Structures Local Coordinates and Modeling Transformations Modeling Transformations Structure Hierarchies

Summary

References

Exercises

250 250 253

254

255 256 256 257 257 258

260

260 261 262 263

265

265 266 266

268

269

269

8 Graphical User Interfaces and Interactive Input Methods 271

-1 The User Dialogue Windows and Icons

Accommodating Multiple Skill Levels 273 Consistency 274 Minimizing Memorization 274 Backup and Error Handling 274 Feedback 275

8-2 Input of Graphical Data 276 Logical Classification of Input Devices 276 Locator Devices 277 Stroke Devices 277 String Devices 277 Valuator Devices 277 Choice Devices 279 Pick Devices 279

8-3 Input Functions 281 Input Modes 281 Request Mode 282 Locator and Stroke Input in Request Mode 282 String Input in Request Mode 283 Valuator Input in Request Mode 284 Choice Input in Request Mode 284 Pick Input in Request Mode 284 Sample Mode 285 Event Mode 285 Concurrent Use of Input Modes 287 Initial Values for Input-Device Parameters 287

Interactive Picture-Construction Techniques 288 Basic Positioning Methods 288 Constraints 288 Grids 289 Gravity Field 290 Rubber-Band Methods 290

272 Dragging 291 273 Painting and Drawing 291

8-4

8-5

x

Page 6: SECOND EDITION omputer Graphics - GBV

Contents

8-6

Q 7 9-1

9-2

К 1} 10-1

10-2 10-3

Virtual-Reality Environments Summary References Exercises

Three-Dimensional Concepts Three-Dimensional Display Methods Parallel Projection Perspective Projection Depth Cueing Visible Line and Surface Identification Surface Rendering Exploded and Cutaway Views Three-Dimensional and Stereoscopic Views Three-Dimensional Graphics Packages

Three-Dimensional f\ Object \J Representations

Polygon Surfaces Polygon Tables Plane Equations Polygon Meshes Curved Lines and Surfaces Quadric Surfaces Sphere Ellipsoid Torus

292 293 294 294

296 297 298 299 299

300 300 300

300

302

304 305 306 307 309 310 310 311 311 311

10-4

10-5 10-6

10-7

10-8

10-9

10-10

10-11

Superquadrics Superellipse Superellipsoid Blobby Objects Spline Representations Interpolation and Approximation Splines Parametric Continuity Conditions Geometric Continuity Conditions Spline Specifications Cubic Spline Interpolation Methods Natural Cubic Splines Hermite Interpolation Cardinal Splines Kochanek-Bartels Splines Bezier Curves and Surfaces Bezier Curves Properties of Bezier Curves Design Techniques Using Bezier Curves Cubic Bezier Curves Bezier Surfaces B-Spline Curves and Surfaces B-Spline Curves

Uniform, Periodic B-Splines Cubic, Periodic B-Splines Open, Uniform B-Splines Nonuniform B-Splines B-Spline Surfaces Beta-Splines Beta-Spline Continuity Conditions Cubic, Periodic Beta-Spline Matrix Representation Rational Splines

312 312 313 314 315

316

317

318 319

320 321 322 323 325 327 327 329

330 331 333 334 335 336 339 341 344 344 345

345

346 347

XI

Page 7: SECOND EDITION omputer Graphics - GBV

Contents

Conversion Between Spline Representations Displaying Spline Curves and Surfaces Horner's Rule Forward-Difference Calculations Subdivision Methods Sweep Representations Constructive Solid-Geometry Methods

10-16 Octrees 10-17 BSP Trees

Fractal-Geometry Methods Fractal-Generation Procedures Classification of Fractals Fractal Dimension Geometric Construction of Deterministic Self-Similar Fractals Geometric Construction of Statistically Self-Similar Fractals Affine Fractal-Construction Methods Random Midpoint-Displacement Methods Controlling Terrain Topography Self-Squaring Fractals Self-Inverse Fractals Shape Grammars and Other Procedural Methods Particle Systems Physically Based Modeling Visualization of Data Sets Visual Representations for Scalar Fields Visual Representations for Vector Fields Visual Representations for Tensor Fields

349

351 351 351 353 355

356

Visual Representations for Multivariate Data Fields 402 Summary 404 References 404 Exercises 404

Three-Dimensional

1* | Geometric and Modeling JL Transformations 407

362

362 363 364 364

367

369

372

373 376 378 385

387 390 393 395

11 11

11 11

11 11

11

-1 -2

-3 -4

-5 -6

-7

И ,1

Translation Rotation Coordinate-Axes Rotations General Three-Dimensional Rotations Rotations w i th Quaternions

Scaling Other Transformations Reflections Shears

Composite Transformations Three-Dimensional Transformati Functions Modeling and Coordinate Transformations Summary References Exercises

i Three-Dimensional • Viewing

408 409 409

413 419

420 422 422 423

423 j n

425

426 429 429 430

431

395 12-1 Viewing Pipeline 432 Viewing Coordinates 433

400 Specifying the View Plane 433 Transformation from World

401 to Viewing Coordinates 437

XII

Page 8: SECOND EDITION omputer Graphics - GBV

Contents

12-3

12-4

12-5

12-6

12-7

1 13-1

13-2

13-3

13-4

13-5

13-6

13-7

13-8

13-9

13-10

13-11

14-1

14-2

Projections 438 13-12 Parallel Projections 439 13.13 Perspective Projections 443

View Volumes and General Projection Transformations 447 General Parallel-Projection Transformations 452 General Perspective-Projection Transformations 454

Clipping 456 Normalized View Volumes 458 Viewport Clipping 460 Clipping in Homogeneous Coordinates 461

Hardware Implementations 463

Three-Dimensional Viewing

Functions 464

Summary 467

References 468

Exercises 468

Visible-Surface Detection Methods 469

Classification of Visible-Surface

Detection Algorithms 470 14-3

Back-Face Detection 471

Depth-Buffer Method 472

A-Buffer Method 475

Scan-Line Method 476

Depth-Sorting Method 478

BSP-Tree Method 481

Area-Subdivision Method 482

Octree Methods 485

Ray-Casting Method 487 14-5

Curved Surfaces 488 Curved-Surface Representations 488 Surface Contour Plots 489

Wireframe Methods 490

Visibility-Detection Functions 490

Summary 491

References 492

Exercises 492

Illumination Models and Surface-Rendering Methods 494

Light Sources

Basic Illumination Models Ambient Light Diffuse Reflection Specular Reflection and the Phong Model Combined Diffuse and Specular Reflections with Multiple Light Sources Warn Model Intensity Attenuation Color Considerations Transparency Shadows

Displaying Light Intensities Assigning Intensity Levels Gamma Correction and Video Lookup Tables Displaying Continuous-Tone Images

Halftone Patterns and Dithering Techniques Halftone Approximations Dithering Techniques

Polygon-Rendering Methods Constant-Intensity Shading Gouraud Shading Phong Shading

496

497 497 497

500

504 504

505 507 508 511

511 512

513

515

516 516 519

522 522 523 525

XII I

Page 9: SECOND EDITION omputer Graphics - GBV

Contents

14-6

14-7

14-8

14-9

^ ^ K ^ ^ P

JL5

Fast Phong Shading

Ray-Tracing Methods Basic Ray-Tracing Algorithm Ray-Surface Intersection Calculations Reducing Object-Intersection Calculations Space-Subdivision Methods Antialiased Ray Tracing

Distributed Ray Tracing

Radiosity Lighting Model Basic Radiosity Model Progressive Refinement Radiosity Method

Environment Mapping

Adding Surface Detail Modeling Surface Detail with Polygons Texture Mapping Procedural Texturing Methods Bump Mapping

Frame Mapping

Summary

References

Exercises

• Color Models and Co f Applications

526

527 528

531

535 535 538 540

544 544

549

552

553

553 554

556 558 559

560

561

562

lor 564

15-6

15-7

15-8

15-9

15-10

1 fi 16-1

16-2

16-3

16-4

16-5

16-6

CMY Color Model

HSV Color Model

Conversion Between HSV and RGB Models

HLS Color Model

Color Selection and Applications

Summary

References

Exercises

Computer • Animation

Design of Animation Sequences

General Computer-Animation Functions

Raster Animations

Computer-Animation Languages

Key-Frame Systems Morphing Simulating Accelerations

Motion Specifications Direct Motion Specification Goal-Directed Systems Kinematics and Dynamics

Summary

References

Exercises

574

575

578

579

580

581

581

582

583

584

586

586

587

588 588 591

594 594 595 595

596

597

597

Properties of Light 565

Standard Primaries and the Chromaticity Diagram 568 XYZ Color Model 569

CIE Chromaticity Diagram 569

Intuitive Color Concepts 571

RGB Color Model 572

YIQ Color Model 574

jnL Mathematics for Computer Graphics 599

A-1 Coordinate-Reference Frames 600 Two-Dimensional Cartesian Reference Frames 600 Polar Coordinates in the xy Plane 601

XIV

Page 10: SECOND EDITION omputer Graphics - GBV

Contents

Three-Dimensional Cartesian Reference Frames Three-Dimensional Curvilinear Coordinate Systems

Solid Angle

Points and Vectors Vector Addition and Scalar Multiplication Scalar Product of Two Vectors Vector Product of Two Vectors

Basis Vectors and the Metric Tensor Orthonormal Basis

Metric Tensor

Matrices Scalar Multiplication and Matrix Addition Matrix Multiplication

602

602

604

605

607 607 608

609 609

610

611

612 612

A-5

A-6 A-7

A-8

A-9

Matrix Transpose Determinant of a Matrix

Matrix Inverse

Complex Numbers

Quaternions Nonparametric Representations

Parametric Representations

Numerical Methods Solving Sets of Linear Equations Finding Roots of Nonlinear

Equations Evaluating Integrals Fitting Curves to Data Sets

BIBLIOGRAPHY

INDEX

613 613 614

615

617 618

619

620 620

621

622 625

626

639