Exploration of Computer Graphics 1774694433, 9781774694435

"The book ""Exploration of Computer Graphics"" walks students through the process of creating t

185 19 14MB

English Pages 245 [248] Year 2022

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Cover
Title Page
Copyright
ABOUT THE EDITOR
TABLE OF CONTENTS
List of Figures
List of Abbreviations
Preface
Chapter 1 Introduction to Computer Graphics
1.1. Introduction
1.2. Graphics Areas
1.3. Major Applications
1.4. Graphics APIS
1.5. Graphics Pipeline
1.6. Numerical Issues
1.7. Efficiency
1.8. Designing and Coding Graphics Programs
1.9. Painting and Drawing
1.10. Components of Three-Dimensional Graphics
References
Chapter 2 Two-Dimensional Computer Graphics
2.1. Introduction
2.2. Pixels, Coordinates, and Colors
2.3. Shapes
2.4. Transforms
2.5. Hierarchical Modeling
2.6. Java Graphics2d
References
Chapter 3 Two-Dimensional Graphics Test Bed
3.1. Introduction
3.2. Details of the Test Bed
3.3. Animation
3.4. Interaction
3.5. Application of the Test Bed
References
Chapter 4 Lights and Materials for Computer Graphics
4.1. Introduction
4.2. Introduction to Lighting
4.3. Light and Material in Opengl 1.1
4.4. Image Textures
4.5. Lights, Camera, Action
References
Chapter 5 Introduction to 3D Computer Graphics
5.1. Introduction
5.2. Transformations in 3D
5.3. Lighting and Material
5.4. Textures
References
Chapter 6 Raster Images
6.1. Introduction
6.2. Raster Devices
6.3. Pixels, Images, and Geometry
6.4. RGB Color
6.5. Alpha Compositing
References
Chapter 7 Data Structures for Graphics
7.1. Introduction
7.2. Triangle Meshes
7.3. Scene Graphs
7.4. Spatial Data Structures
7.5. BSP Trees for Visibility
References
Chapter 8 Computer Animation
8.1. Introduction
8.2. Principles of Animation
8.3. Keyframing
8.4. Deformations
8.5. Character Animation
References
Index
Back Cover
Recommend Papers

Exploration of Computer Graphics
 1774694433, 9781774694435

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

Exploration of Computer Graphics

EXPLORATION OF COMPUTER GRAPHICS

Edited by: Adele Kuzmiakova

ARCLER

P

r

e

s

s

www.arclerpress.com

Exploration of Computer Graphics Adele Kuzmiakova

Arcler Press 224 Shoreacres Road Burlington, ON L7L 2H2 Canada www.arclerpress.com Email: [email protected]

e-book Edition 2023 ISBN: 978-1-77469-597-5 (e-book)

This book contains information obtained from highly regarded resources. Reprinted material sources are indicated and copyright remains with the original owners. Copyright for images and other graphics remains with the original owners as indicated. A Wide variety of references are listed. Reasonable efforts have been made to publish reliable data. Authors or Editors or Publishers are not responsible for the accuracy of the information in the published chapters or consequences of their use. The publisher assumes no responsibility for any damage or grievance to the persons or property arising out of the use of any materials, instructions, methods or thoughts in the book. The authors or editors and the publisher have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission has not been obtained. If any copyright holder has not been acknowledged, please write to us so we may rectify. Notice: Registered trademark of products or corporate names are used only for explanation and identification without intent of infringement.

© 2023 Arcler Press ISBN: 978-1-77469-443-5 (Hardcover)

Arcler Press publishes wide variety of books and eBooks. For more information about Arcler Press and its products, visit our website at www.arclerpress.com

ABOUT THE EDITOR

Adele Kuzmiakova is a machine learning engineer focusing on solving problems in machine learning, deep learning, and computer vision. Adele currently works as a senior machine learning engineer at Ifolor focusing on creating engaging photo stories and products. Adele attended Cornell University in New York, United States for her undergraduate studies. She studied engineering with a focus on applied math. Some of the deep learning problems Adele worked on include predicting air quality from public webcams, developing a real-time human movement tracking, and using 3D computer vision to create 3D avatars from selfies in order to bring online clothes shopping closer to reality. She is also passionate about exchanging ideas and inspiring other people and acted as a workshop organizer at Women in Data Science conference in Geneva, Switzerland.

TABLE OF CONTENTS

List of Figures.........................................................................................................xi List of Abbreviations.............................................................................................xv Preface........................................................................................................... ....xvii Chapter 1

Introduction to Computer Graphics........................................................... 1 1.1. Introduction......................................................................................... 2 1.2. Graphics Areas.................................................................................... 3 1.3. Major Applications.............................................................................. 4 1.4. Graphics APIS...................................................................................... 6 1.5. Graphics Pipeline................................................................................ 7 1.6. Numerical Issues................................................................................. 9 1.7. Efficiency........................................................................................... 11 1.8. Designing and Coding Graphics Programs......................................... 12 1.9. Painting and Drawing........................................................................ 17 1.10. Components of Three-Dimensional Graphics................................... 22 References................................................................................................ 27

Chapter 2

Two-Dimensional Computer Graphics..................................................... 37 2.1. Introduction....................................................................................... 38 2.2. Pixels, Coordinates, and Colors......................................................... 38 2.3. Shapes............................................................................................... 46 2.4. Transforms......................................................................................... 52 2.5. Hierarchical Modeling....................................................................... 58 2.6. Java Graphics2d................................................................................. 63 References................................................................................................ 67

Chapter 3

Two-Dimensional Graphics Test Bed....................................................... 77 3.1. Introduction....................................................................................... 78 3.2. Details of the Test Bed........................................................................ 80

3.3. Animation.......................................................................................... 84 3.4. Interaction......................................................................................... 86 3.5. Application of the Test Bed................................................................ 86 References................................................................................................ 90 Chapter 4

Lights and Materials for Computer Graphics............................................ 95 4.1. Introduction....................................................................................... 96 4.2. Introduction to Lighting..................................................................... 96 4.3. Light and Material in Opengl 1.1..................................................... 105 4.4. Image Textures................................................................................. 113 4.5. Lights, Camera, Action..................................................................... 116 References.............................................................................................. 124

Chapter 5

Introduction to 3D Computer Graphics................................................. 135 5.1. Introduction..................................................................................... 136 5.2. Transformations in 3D...................................................................... 136 5.3. Lighting and Material....................................................................... 143 5.4. Textures........................................................................................... 146 References.............................................................................................. 149

Chapter 6

Raster Images......................................................................................... 153 6.1. Introduction..................................................................................... 154 6.2. Raster Devices................................................................................. 155 6.3. Pixels, Images, and Geometry.......................................................... 162 6.4. RGB Color....................................................................................... 166 6.5. Alpha Compositing.......................................................................... 168 References.............................................................................................. 171

Chapter 7

Data Structures for Graphics................................................................. 177 7.1. Introduction..................................................................................... 178 7.2. Triangle Meshes............................................................................... 178 7.3. Scene Graphs.................................................................................. 184 7.4. Spatial Data Structures..................................................................... 187 7.5. BSP Trees for Visibility...................................................................... 188

viii

References.............................................................................................. 191 Chapter 8

Computer Animation.............................................................................. 195 8.1. Introduction..................................................................................... 196 8.2. Principles of Animation................................................................... 198 8.3. Keyframing...................................................................................... 202 8.4. Deformations................................................................................... 209 8.5. Character Animation........................................................................ 210 References.............................................................................................. 217

Index...................................................................................................... 225

ix

LIST OF FIGURES Figure 1.1. Computer graphics has three key elements Figure 1.2. Computer graphics uses Figure 1.3. Graphical representation of medical imaging Figure 1.4. Levels of graphics application programming interfaces Figure 1.5. Graphical depiction of an API’s functionality Figure 1.6. The OpenGL graphics pipeline comprises of the such five steps Figure 1.7. Dynamic pipeline Figure 1.8. Computer graphic program Figure 1.9. Float vs. double Figure 1.10. Three-dimensional graphics depiction Figure 2.1. 12-by-8-pixel grids containing rows or column numbers. The rows on the left are marked as top to bottom, while those on the right are counted from bottom to top Figure 2.2. Illustration of anti-aliasing Figure 2.3. Two lines are produced utilizing HTML canvas graphics and amplified significantly. The columns were to be black with such a one-pixel beam width Figure 2.4. A diagram of transmissions Figure 2.5. Some of the possibilities are shown Figure 2.6. The two ellipse radii for the form on the right Figure 2.7. The ellipse on the left with its enclosing rectangle, as well as its centerline and radii Figure 2.8. The patterns on the left are drawn in the direction indicated, and the amount that winds around each area is displayed as an integer within the region Figure 2.9. Forms with two slopes and two designs Figure 2.10. “Graphics” filled with a design on above as well as covered with a slope and brushed with solid black on the bottom Figure 2.11. A coordinate transform is used to map the window to the viewport Figure 2.12. Image depicts an item that is created in its object reference frame and then transferred into the reference frame using three separate modeling transforms Figure 2.13. A picture is manipulated by moving, cropping, and spinning it Figure 2.14. F is drawn by using coordinates

Figure 2.15. The x-coordinates range from 0 to 12 and the y-coordinates range from 0 to 8. A 12-by-8-pixel grid includes x-coordinates ranging from 0 to 12 as well as y-coordinates ranging from 0 to 8 Figure 3.1. Top: A polyline in the plane. Middle: Each segment has been divided into thirds, and the division points have been marked with dots. Bottom: The middle thirds of the segments are connected together to form a new, smoother polyline Figure 3.2. The Testbed2D application running. All the things in the large graph-paper window are drawn by the Window1.xaml.cs code and are not described in the XAML file Figure 3.3. When we thicken the vertex join at the top, we must miter it, as shown in the middle. At the bottom, the miter is limited Figure 4.1. Two forms of reflection are crucial in various 3D graphics techniques Figure 4.2. Diagrammatic illustration of specular reflection Figure 4.3. Image depicts eight rounds that vary just in their shininess substance attribute value Figure 4.4. The sun is a directed source of light being so far off that the sun’s beam of light are almost straight whenever they reach the Earth Figure 4.5. Example of a normal vector Figure 4.6. Representation of normal vectors in two dimensions Figure 4.7. Graphical illustration of six items with picture textures Figure 4.8. Graphical illustration of a scene graph Figure 5.1. This graphic demonstrates that when the normal vectors of an object undergo a similar shear transformation as the object itself, the resultant vectors would not be perpendicular to the object Figure 5.2. This lighting diagram depicts the four vectors that were employed in the calculation Figure 5.3. On a cube, a graphical illustration of mapping Figure 6.1. Image depicts how a LED display operates Figure 6.2. The subpixels of blue, green, and red inside a pixel of a flat-panel display Figure 6.3. When the liquid crystal cell is in its active state (top), it rotates the polarization of the light, which allows it to flow through the front polarizer. When the cell is in its inactive state (bottom), the front polarizer blocks any light from passing through the rear polarizer Figure 6.4. Functioning of a liquid crystal display (LCD) Figure 6.5. An ink-jet printer’s functioning Figure 6.6. The functionality of digital cameras Figure 6.7. The majority of color digital cameras employ a color-filter array comparable to this Bayer mosaic. Every pixel is capable of measuring green, blue, or red light xii

Figure 6.8. A 4-pixel by 3-pixel screen’s coordinates. It is worth noting that the y-axis in certain APIs would point downward Figure 6.9. The additive mixing principles for red, green, and blue colors Figure 6.10. The RGB color cube in three dimensions, with its faces unfurled. Every RGB hue can represent a point on the cube Figure 7.1. Internal edges of non-manifold (left) and manifold (right) manifolds Figure 7.2. Interior vertices of non-manifold (left) and manifold (right) manifolds Figure 7.3. Boundary conditions near the margin of a manifold Figure 7.4. Triangles (B,A,C) with (D,C,A) are orientated consistently, but triangles (B,A,C) or (A,C,D) are orientated imperfectly Figure 7.5. A three-triangle meshes having four vertices, shown with independent triangles on the left with common vertices on the right Figure 7.6. A bigger triangular mesh has an indexed triangle mesh as part of its representation Figure 8.1. The action diagrams Figure 8.2. A classic illustration of the squash and stretch concept in action Figure 8.3. While keyframing (on the top) fosters elaborate action preparation, straightahead action (on the bottom) produces a more spontaneous outcome Figure 8.4. For the same scenario, you may utilize several patterns of setting keys (black circles). There are likely to be more frames before and after this section Figure 8.5. Although only data at frame locations are of importance, the animator’s keys are used to fit a continuous curve f(t). The pace of parameter change is defined by the derivative of this function, which is initially obtained automatically by the fitting technique Figure 8.6. Utilizing TCB controls to edit the default interpolating spline (middle column) Figure 8.7. All three movements follow the same two-dimensional route and fulfill the set of keys at the black triangles’ tips

xiii

LIST OF ABBREVIATIONS API

application program interface

CT

computed tomography

DPI

dots per inch

FFD

free-form distortion

HDR

high dynamic range

IDE

integrated development environment

IK

inverse kinematics

LDR

low dynamic range

LOD

level of detail

PPI

pixels per inch

RGB

red-green-blue

TINs

triangle irregularity networking

PREFACE This book is designed for students who have a strong programming background but no prior computer graphics knowledge. It has a few unique elements that you won’t find in other beginner courses. This book places a considerable emphasis on using a graphics API to create computer graphics programs, specifically using the OpenGL API. Many of the core algorithms and approaches that are in use today may be found in this book. The exploration of computer graphics is addressed to the extent that it helps students grasp technical concepts with ease and confidence. Real-world examples are used throughout the book to create a bridge between technical concepts and real-world use cases. We are convinced that the knowledge gained from API-based graphics programming will assist you in understanding the significance of these algorithms and approaches. Additionally, it will provide you with the necessary tools to interface with them more confidently, even though you may just be starting out in this area. This book introduces students, researchers, and practitioners to many of the key concepts in computer graphics. Several of these concepts have previously been published in publicly accessible scientific papers, technical reports, textbooks, and lay newspaper pieces. The benefit of creating a textbook after a concept has appeared is that its longterm influence may be better understood and placed in a broader perspective. Our goal has been to approach topics with as much complexity as feasible (which means removing notions that are no longer as significant), while still exposing the students to the subject in a clear and elegant manner. This book provides extensive knowledge because it takes the straight and narrow road through what is absolutely necessary for comprehending how pictures are shown on screens utilizing the complementary methodologies of ray tracing and rasterization. The easiest approach to producing pictures of 3D scenes is ray tracing, which is addressed first, followed by the mathematical machinery necessary for the graphics pipeline, and finally, the pipeline itself. After that, the “outer core” includes concepts like sampling theory, texture mapping, spatial data structures, and splines that would normally be covered in an introductory session. We’ve tried to maintain the casual, intuitive manner of presentation that defines earlier versions while also enhancing consistency, precision, and completeness. We believe that the reader will find the end product to be an engaging platform for a range of computer graphics courses. The book is broken up into eight different chapters. The reader will get an introduction to computer graphics starting from the most fundamental level in the first chapter. The second chapter presents an in-depth analysis of the two-dimensional computer and offers information that is exhaustive on two-dimensional computer graphics. The twodimensional graphics test bed is addressed in some depth throughout Chapter 3.

In Chapter 4, further depth is devoted to the lighting and components that are necessary for computer graphics. The reader is provided with the necessary background information in Chapter 5, which is devoted to the presentation of three-dimensional computer graphics. In Chapter 6, we get a demonstration of the raster graphics with high levels of detail. The data structure for the computer graphics is explained in minute detail in Chapter 7, which may be found here. In the last chapter, the emphasis is placed on computer animation.

CHAPTER

1

INTRODUCTION TO COMPUTER GRAPHICS

CONTENTS 1.1. Introduction......................................................................................... 2 1.2. Graphics Areas.................................................................................... 3 1.3. Major Applications.............................................................................. 4 1.4. Graphics APIS...................................................................................... 6 1.5. Graphics Pipeline................................................................................ 7 1.6. Numerical Issues................................................................................. 9 1.7. Efficiency........................................................................................... 11 1.8. Designing and Coding Graphics Programs......................................... 12 1.9. Painting and Drawing........................................................................ 17 1.10. Components of Three-Dimensional Graphics................................... 22 References................................................................................................ 27

2

Exploration of Computer Graphics

1.1. INTRODUCTION The use of any computer to generate and alter pictures is referred to as computer graphics. This chapter explains how to employ algorithmic and mathematical methods to generate a wide range of visuals, including realistic visual impacts, useful technical drawings, and stunning computer animations (Jones, 1985). Graphics may be 2D or 3D, depending on their use case. The images may be entirely synthetic (that is, they are created artificially) or produced by modifying photos. That book is devoted to basic mathematics and algorithms, particularly those that are utilized to create synthetic pictures of 3D objects and settings (Foley et al., 1994). Knowledge of computer hardware, file formats, and graphics APIs is required to generate computer graphics. Because computer graphics is such a fast-moving industry, the details of that expertise have always been changing. As a result, we try to prevent relying on any particular hardware or API in the chapter in order to make the book inclusive and accessible to a wide audience. The content should be supplemented with suitable documentation for the reader’s hardware and software settings (Figure 1.1) (Blundell, 2008).

Figure 1.1. Computer graphics has three key elements. Source: https://www.javatpoint.com/computer-graphics-tutorial.

Luckily, the environment of computer graphics contains sufficient common vocabulary and concepts for the topic in this chapter to transfer well to the majority of situations. This chapter outlines certain fundamental terms and gives historical context and sources of information on computer graphics (Angel & Shreiner, 2011).

Introduction to Computer Graphics

3

1.2. GRAPHICS AREAS This is risky to impose classifications on any topic, but most computer graphics professionals will agree on the following primary areas (Hughes et al., 2014): •

Modeling: It is concerned with the mathematical definition of texture and shape features in a computer-storable format. A coffee mug, for instance, may be defined as a collection of arranged 3D points, accompanied by an interpolation algorithm to link the points and a reflection model that specifies how light plays with the mug (Bartels et al., 1995). • Rendering: It is a term inherited from art and deals with the creation of shaded images from 3D computer models. • Animation: It is a method that uses sequences of pictures to create the appearance of movement. Animation employs rendering and modeling but adds the main issues of movement through time that are not typically addressed in standard rendering and modeling. There have been several more fields that incorporate computer graphics, and it is a question of opinion if these constitute core graphics topics. These will all be mentioned briefly in the book. These connected fields consist of the following (Angel and Shreiner, 2014): •



1. 2.

Consumer Interaction: This entails the interface among input devices like the mouse and the application, tablets, the user’s visual feedback, and any additional sensory feedback. Historically, this field is related to graphics since graphics researchers were among the first to have accessibility to the now-ubiquitous I/O devices. Virtual Reality: The purpose of virtual reality is to immerse the consumer in a three-dimensional virtual environment. This often necessitates stereo graphics and head motion response. Additionally, sound, and force feedback must be included for complete virtual reality. Since this field demands sophisticated three-dimensional graphics and display technologies, this is frequently related to graphics (Buss and Buss, 2003). Visualization: It aims to provide people with comprehension of complicated data through visual presentation. Frequently, graphical concerns must be resolved in a visualization issue. Image Processing: It involves the alteration of two-dimensional pictures and is utilized in the realms of both vision and graphics.

Exploration of Computer Graphics

4

3.

4.

Three-Dimensional Scanning: Using range-finding technology, three-dimensional scanning generates measurable threedimensional models. These models are important for producing visually rich visuals, and their processing frequently needs graphics algorithms. Computational Photography: It is the application of computer vision, computer graphics, and image processing techniques to allow novel techniques of photographing objects, sceneries, and settings (Foley et al., 1996).

1.3. MAJOR APPLICATIONS Almost every activity may make utilization of computer graphics, however, the following industries are the largest users of computer graphics technology (Figure 1.2) (Vidal et al., 2006):

Figure 1.2. Computer graphics uses. Source: https://quicklearncomputer.com/wp-content/uploads/2021/06/Applications-of-Computer-Graphics-Uses.webp.

1. 2.

Video Games: Progressively, video games employ complex three-dimensional models and rendering techniques. Cartoons: Frequently, cartoons are produced straight from three-dimensional models. Numerous classic two-dimensional animations include 3D-rendered backdrops, which enable a continually shifting viewpoint without requiring a great deal of artist time (Papathomas et al., 1988).

Introduction to Computer Graphics

3.

4. 5.

6.

7.

5

Visual Effects: The majority of computer graphics technologies are employed in the creation of visual effects. Almost every contemporary film employs digital compositing to combine independently recorded backgrounds and foregrounds. In addition, some films employ three-dimensional modeling and animation to create synthetic settings, objects, or even individuals that the vast majority of spectators would never guess are not genuine (Schneider, 1978). Animated Films: This employs a number of the same methods as visual effects, however, without necessarily aiming for realistic graphics. CAM and CAD: Computer-aided manufacturing (CAM) and Computer-aided design (CAD) – these areas employ computer technology to design components and products on the computer and then guide the production process utilizing such virtual designs. Numerous mechanical components, for instance, are developed in a three-dimensional computer modeling program and then automatically manufactured on a computer-controlled milling machine (Marsh et al., 1986). Simulation: This may be viewed as a realistic video game. A flight simulator, for instance, employs advanced three-dimensional visuals to recreate the sensation of piloting an airplane. These simulations may be particularly valuable for initial training in safety-critical domains, like driving, and situation training for experienced consumers, like training for certain fire-fighting circumstances that have been too expensive or risky to build physically (Samet, 1990). Medical Imaging: Using scanned patient information, medical imaging provides visuals with significance. A computed tomography (CT) dataset, for instance, consists of a vast three-dimensional rectangular arrangement of density values. Computer graphics are utilized to generate shaded pictures that assist physicians in extracting the most pertinent facts from such datasets (Figure 1.3) (Debertin and Goetz, 1992).

Exploration of Computer Graphics

6

Figure 1.3. Graphical representation of medical imaging. Source: https://www.enterpriseai.news/2019/12/02/medical-imaging-gets-anai-boost/.

8.

Information Visualization: It generates data of pictures that are not always “natural” in appearance. The price movement of 10 distinct stocks, for instance, does not have an apparent visual representation, but creative graphing methods may assist humans in detecting patterns in that kind of data (Case, 1971).

1.4. GRAPHICS APIS Interacting with a graphics application program interface (API) is a crucial component of utilizing graphics libraries. An API is a standard set of functions that conduct a set of related operations, and a graphics API is a standard set of functions that execute fundamental activities like drawing pictures and three-dimensional surfaces into screen windows (Figure 1.4) (Pulli, 2006).

Figure 1.4. Levels of graphics application programming interfaces. Source: https://asawicki.info/news_1601_lower-level_graphics_api_-_what_ does_it_mean.html.

Introduction to Computer Graphics

7

Each graphics software must provide two APIs: a graphics API for visual output and a user-interface API for receiving input from the user. For graphics and user-interface APIs, there have been two prominent paradigms. The 1st is an integrated method, as demonstrated by Java, in which graphics and user interface toolkits have been combined into portable packages that have been completely supported and standardized as part of the language (Gokhale et al., 2013). The 2nd is illustrated by Direct three-dimensional and OpenGL, in which the drawing commands are part of a software library related to a language like C++ and the user-interface software is a separate entity that varies from system to system. It is difficult to build portable code in this method, albeit for basic systems, a portable library layer might be used to encapsulate the system-specific user-interface code. The core graphics calls would be much the same regardless of API, and the principles in this chapter would apply (Figure 1.5) (Mark et al., 2003).

Figure 1.5. Graphical depiction of an API’s functionality. Source: https://www.techjunkie.com/new-graphics-apis-future-pc-gaming/.

1.5. GRAPHICS PIPELINE Nowadays, each desktop PC has a robust three-dimensional graphics pipeline. It is a specialized hardware or software subsystem for drawing three-dimensional primitives in viewpoint effectively. Such systems are often tuned for three-dimensional processing triangles having common vertices. The fundamental pipeline operations translate the three-dimensional vertex

8

Exploration of Computer Graphics

locations to the two-dimensional screen coordinates and shade the triangles so that they seem real and in the correct back-to-front sequence (Figure 1.6) (Hitchner and Sowizral, 2000).

Figure 1.6. The OpenGL graphics pipeline comprises of such five steps. Source: https://www.researchgate.net/figure/The-graphics-pipelinein-OpenGL-consists-of-these-5-steps-in-the-new-generation-of-cards_ fig1_235696712.

Drawing triangles in legal back-to-front order was once the most significant research challenge in computer graphics, but it is now virtually always addressed using the Z-buffer, which employs a particular memory buffer to resolve the problem in a brute-force fashion (Lindholm et al., 2008). It turns out that the geometric manipulation that is used in the graphics pipeline can be accomplished almost entirely in a 4D coordinate space that is composed of three traditional geometric coordinates and a fourth homogeneous coordinate that helps with perspective viewing. This discovery was made after it was discovered that the graphics pipeline uses a 4D coordinate space. These four-dimensional coordinates may be changed by utilizing four-vectors and four-by-four matrices. Therefore, the graphics pipeline includes a significant amount of gear for effectively processing and synthesizing matrices and vectors in their many forms. When it comes to understanding computer graphics, this 4D coordinate system is without a doubt the most difficult intellectual obstacle to overcome. It is also one of the most elegant and sophisticated creations that are utilized in the field of

Introduction to Computer Graphics

9

computer science. Each graphics book devotes a significant portion of the first chapter to discussing these coordinates (Wilkens, 2001). The number of triangles being drawn has a significant impact on how quickly pictures may be created. It is useful to reduce the number of triangles needed to depict a model as many applications place a greater emphasis on the degree to which the model may be interacted with than on its esthetic qualities. When viewed from a greater distance, the model requires a lower number of triangles to create the same effect as when seen from a more intimate vantage point. In light of this, it appears that it would be beneficial to represent a model with a variable level of detail (LOD) (Figure 1.7) (He et al., 2008).

Figure 1.7. Dynamic pipeline. Source: http://romain.vergne.free.fr/teaching/IS/SI03-pipeline.html.

1.6. NUMERICAL ISSUES Numerous visual applications are essentially three-dimensional numerical codes. Frequently, quantitative concerns are critical in such applications. In the “good old days,” it was quite difficult to address these difficulties in a portable and robust way because computers had multiple internal depictions for numbers and, to make matters worse, handled exceptions in inconsistent manners (Calabrese et al., 2010). Thankfully, nearly all contemporary

Exploration of Computer Graphics

10

computers adhere to the IEEE floating-point standard (IEEE Standards Association, 1985). This enables the programmer to make several useful hypotheses regarding the handling of certain numeric circumstances. Although IEEE floating-point offers numerous characteristics that are useful for developing numerical algorithms, just a handful are essential for the majority of visual scenarios. First and foremost, it is essential to recognize that IEEE floating-point has three “special” values for real numbers (Lourenço, 1998): •

Infinity (∞): This number is the legitimate number and is greater than all other numbers that are legitimate. • Minus Infinity (–∞): This number is the legitimate number and is smaller than all other numbers that are legitimate. • Not a Number (NaN): It is an incorrect integer that results from an illegal operation, such as a number divided by zero. The creators of IEEE floating-point made several programming decisions that are exceedingly handy. In addressing exceptions like division by zero, several of them correlate to the three exceptional values listed previously. In such situations, an exception is reported, but the programmer may often disregard it. In particular, the following principles about division by infinite values hold for any +ve real number a (Desmorat et al., 2007): +a/(+∞) = +0 –a/(+∞) = –0 +a/(–∞) = –0 –a/(–∞) = +0 Other oprations that involve infinite values function as expected (Żak and Krawczuk, 2011). Likewise, given +ve, the following is true: ∞+∞ = +∞ ∞–∞ = NaN ∞×∞ = ∞ ∞/∞ = NaN ∞/a = ∞ ∞/0 = ∞ 0/0 = NaN

Introduction to Computer Graphics

11

In a Boolean statement with infinite values, the rules have been as predicted: • All finite valid numbers are smaller than +∞. • All finite valid numbers are greater than –∞. • –∞ is smaller than +∞. The rules for expressions with NaN values are straightforward: • Any mathematical expression containing NaN returns NaN; • Any Boolean statement containing NaN is false. Possibly the most advantageous feature of IEEE floating-point is how divide-by-zero has been managed; for each +ve real integer a, the following rules about division by zero values hold (LeFloch, 2010): +a/+0 = +∞ –a/+0 = –∞ Several math operations become significantly easier if the programmer follows the IEEE guidelines. Consider the following expression: Lenses and resistors can produce such expressions. If divide-by-zero caused the program to crash (as it did in several systems before IEEE floatingpoint), two if statements will be needed to check for tiny or zero values of b or c. Conversely, if b or c is zero, we would receive a zero value for a, as expected, with IEEE floating-point. Using the Boolean characteristics of NaN is another typical way for avoiding special tests. Take a look at the following code segment (De Luca and Magnus, 2011): a = f(x) if (a is greater than 0) then take action. Although the function f may return “ugly” values like ∞ or NaN, the if condition remains well-defined: a = NaN or a = –∞ is false, but a = +∞ is true. With care in determining which values are returned, the if can frequently make the correct decision without the need for further tests. This results in programs that are smaller, more resilient, and more effective (Coroneo et al., 2011).

1.7. EFFICIENCY There have been no magic formulas for improving the efficiency of code. Efficiency is accomplished by making rigorous decisions, and these tradeoffs vary depending on the design of your program. For the time being, however,

Exploration of Computer Graphics

12

a fair heuristic is that programmers must focus on memory access patterns rather than operation numbers. That’s the polar opposite of 20 years ago, the finest heuristic. Since the memory speed has not kept up with the speed of CPUs, this changeover has occurred. As long as this tendency continues, the value of constrained and coherent memory access for optimization will only grow. A feasible strategy for writing quick code is to follow the steps below in order, taking just the steps that are required (Foley et al., 1994): •

Write the code in as simple a manner as feasible. Rather than storing intermediate findings, compute them as required; • Compile most efficiently; • Find major bottlenecks using whatever profiling tools are available; • Analyze data structures in an attempt to enhance locality. Whenever feasible, data unit sizes should correspond to the page/ cache size of the target architecture; • Analyze the assembly code produced by the compiler for lost efficiencies if profiling indicates bottlenecks in numerical operations. Modify source code to fix any identified issues. The initial step is the most vital among these. Many “optimizations” make the program more difficult to read without improving performance. Particularly, the effort spent optimizing code upfront is often better spent fixing problems or adding functionality. Also, be cautious of advice from outdated sources; certain classic methods, like utilizing integers rather than reals, can no longer improve performance, as newer CPUs may typically do floating-point calculations as quickly as integer operations. Profiling is required in all circumstances to determine the value of optimization for a given system and compiler (Huang et al., 2009).

1.8. DESIGNING AND CODING GRAPHICS PROGRAMS In graphics programming, several common techniques are typically beneficial. In this part, we offer certain implementation tips that you can find useful when you apply the particular methods (Figure 1.8) (Hoines, 1987).

Introduction to Computer Graphics

13

Figure 1.8. Computer graphic program. Source: https://www.javatpoint.com/computer-graphics-programs.

1.8.1. Class Design Classes or procedures for geometric things, like matrices and vectors, and graphical entities, like RGB colors and pictures, are essential for any graphics software. These procedures must be made as hygienic and effective as feasible. Displacements and locations have distinct operations, for example, multiplying a location by one-half makes no geometric sense yet multiplying a displacement by one-half does make sense (DeRose, 1989; Goldman, 1985). This subject generates hours of intense argument among graphics professionals, but for the sake of illustration, let us suppose that we would not create a distinction (Taxén, 2004). This indicates that the following fundamental classes must be written: •

Vector2: A class for storing x and y components of a twodimensional vector. Such elements must be stored in a length-2 array such that an indexing operator may be effectively handled. You must include subtraction, addition, cross product, dot product, multiplication, and division of scalars (Chen et al., 2007).

Exploration of Computer Graphics

14

• • •





Vector3: It is a 3D vector class that is similar to vector2. H Vector: A vector having 4 identical elements. RGB: Three elements are stored in RGB color. RGB subtraction, RGB addition, RGB multiplication, scalar division, and scalar multiplication must all be included (Zhu and Wu, 2021). Transform: A 4 by 4 transformation matrix. Include a matrix multiplication and member functions that may be applied to directions, locations, and surface normal vectors. Image: A two-dimensional RGB pixel array with an output operation. You may or may not wish to include orthonormal bases, classes for intervals, and coordinate frames as well (Bialac, 1985).

1.8.2. Float vs. Double The key to efficiency, according to modern architecture, is to keep memory usage low and sustain coherent memory access. This indicates utilizing data with single precision. To avoid numerical difficulties, however, doubleprecision arithmetic is recommended. The disadvantages vary depending upon the software, but having a default in your class specifications is useful (Figure 1.9) (Smits, 1998).

Figure 1.9. Float vs. double. Source: https://techdifferences.com/difference-between-float-and-double.html.

1.8.3. Debugging Graphics Programs If you inquire around, classic debuggers are becoming less and less popular as programers gain expertise. One factor for this is that utilizing these debuggers for complicated programs is more difficult than utilizing them for simple applications. Another reason is that the toughest errors are conceptual

Introduction to Computer Graphics

15

ones, in which the incorrect item is implemented, and it is possible to waste a lot of time going through variable values without seeing them. Many debugging methods have shown to be particularly beneficial with graphics (Fan and Li, 2020).

1.8.4. The Scientific Method There has been an alternative to typical debugging in graphics programs which is frequently quite beneficial. The disadvantage is that this is quite identical to what computer programmers are trained not to do early in their careers, so you could feel “bad” if you do it: we generate a picture and look for flaws. Then we come up with a hypothesis about what is causing the issue and put it to the test. In ray-tracing software, for instance, we can have a lot of black pixels that appear to be random. When most people construct a ray tracer, they run into the classic “shadow acne” issue. Traditional debugging is not going to help us here; instead, we need to understand that the shadow rays have been striking the shaded surface (Volino and Magnenat-Thalmann, 2001). We may see that the color of the black areas is the ambient color, implying that the direct lighting has been absent. Because direct illumination can be switched off in shadow, certain spots may be mistakenly labeled as in shadow when they are not. We might disable the shadowing check and recompile to verify this theory. This will imply that these are bogus shadow tests, and we may go on with our investigation. The fact that we never had to recognize a false value or fully determine our conceptual error is one of the main reasons why this technique may occasionally be a useful practice. Alternatively, we experimented to pinpoint our conceptual blunder. It usually just takes a few attempts to figure out what is wrong, and this form of debugging is fun (Wickham, 1991).

1.8.5. Images as Coded Debugging Output The output picture is often the simplest method for extracting debugging information from graphics software. If you just need to know the value of a variable for a portion of a calculation that executes for each pixel, you may temporarily change your software to transfer that value straight to the output picture and skip the remainder of the computations (Johnsson et al., 2012). If you believe an issue involving surface normals is producing shading issues, you may transfer the normal vectors straight to the picture (x becomes red, y becomes green, and z becomes blue), giving a color-coded depiction of the vectors utilized in your computation. Alternatively, if you believe a value is

16

Exploration of Computer Graphics

occasionally outside of its valid range, have your application write bright red pixels when this occurs (Doolittle, 1987). Other typical methods include coloring the image by the ID numbers of the items, or coloring pixels by the amount of effort they took to calculate (when they have not been meant to be apparent) (Belavina et al., 2020).

1.8.6. Using a Debugger There are still times when there is no alternative for witnessing exactly what is going on, especially when the scientific approach appears to have led to a contradiction. The problem is that graphics programs sometimes include many iterations of the identical code (once every pixel, for example, or once per triangle), making it impossible to debug from the start. And the most challenging flaws are generally only found when complex inputs are used. Setting a “trap” for the problem is a good idea. To begin, verify that your software is deterministic by running it in a single thread and ensuring that all random integers are generated from fixed seeds. Then, figure out which pixel or triangle is showing the issue, and place a statement before the code you believe is erroneous that would only be run in that situation. If you notice that pixel (126, 247) has the issue, for example, add (Shen et al., 1996): if x = 126 and y = 247 then, print “blarg!” You may enter the debugger immediately before the pixel you are interested in is calculated if you place a breakpoint on the print command. Certain debuggers provide a “conditional breakpoint” function that allows you to do the same thing without changing the code (Ferwerda, 2003). A classic debugger is beneficial for locating the location of a crash when the application crashes. Furthermore, using assertions and recompiles, you must start retracing through the program to see where it went wrong. Such assertions must be kept in the software in case you introduce other flaws later. This implies you will not be using the typical step-by-step method since that will be adding valuable assertions to your software (Ranon and Urli, 2014).

1.8.7. Data Visualization for Debugging Since your software calculates a lot of intermediate outcomes before it eventually goes wrong, it is sometimes difficult to grasp what it is doing. The

Introduction to Computer Graphics

17

problem is comparable to a scientific experiment with a large amount of data, and one approach is the same: develop beautiful graphs and representations for yourself to grasp the data (Kakadiaris et al., 2007). For example, in a ray tracer, you may build code to display ray trees so you can see which routes contributed to a pixel, or you might construct plots in an image resampling procedure to show all the spots where samples are being obtained from the input. Whenever it comes time to improve your software, the work invested in creating code to see its inner state pays off in a greater knowledge of its behavior (Dyer, 1982).

1.9. PAINTING AND DRAWING This book focuses on 3D graphics, with the majority of the effort going into creating a 3D model of a scene. In virtually all circumstances, however, a computer graphics project will result in a 2D image. Direct generation and modification of 2D pictures is, obviously, a significant issue in and of itself. Furthermore, many concepts are transferable from 2 to 3 dimensions. As a result, it makes sense, to begin, with 2D graphics (Yun-Jie and Hui-Xiang, 1991). Pixels are the elements that make up a picture on a computer screen. A rectangular grid of pixels is organized in columns and rows on the screen. Because the pixels are so little, it is difficult to discern them separately. In reality, they become nearly undetectable on many ultra-high-resolution monitors. Every pixel may only display one color at a time. Most modern screens employ 24-bit color, which allows a color to be described using three 8-bit values that represent the color’s blue, green, and red levels. Every color that may be seen on a screen is composed of a mix of such three “primary” hues. Other formats, like grayscale, are feasible, in which each pixel is a different shade of gray and the pixel color is determined by a single integer that specifies the gray level on a black-to-white scale. Commonly, 256 hues of gray have been utilized (Pang et al., 1987). Initial computer screens employed indexed color, which might only show a limited number of colors, generally 256 or 16. There has been a numbered list of available colors for an indexed color display, and the color of a pixel has been indicated by an integer indicating the color’s position in the list. In any scenario, the color values for all of the pixels on the screen have been kept in a frame buffer, which is a big block of memory. Changing the picture on the screen necessitates altering the frame buffer’s color values. The screen is repainted numerous times per second, thus the pixels’ colors

18

Exploration of Computer Graphics

on the screen are altered to match practically quickly after the color values in the frame buffer are updated, and the displayed image changes (Whitted, 1983). The fundamental model of raster graphics is a computer screen utilized in this manner. Technically, the name “raster” relates to the mechanism utilized on earlier vacuum tube computer monitors: An electron beam will pass across the pixels, causing them to light. Strong magnets were used to shift the beam over the screen, deflecting the electrons’ course. Because the brighter the beam, the brighter the pixel’s light, the brightness of the pixels might be regulated by changing the electron beam’s intensity. The intensity of the electron beam was determined using the color values contained in the frame buffer. (Each pixel on a color screen featured a green dot, a red dot, and a blue dot, all of which had been individually lighted by the beam) (McCracken, 2006). In the same way, a contemporary flat-screen computer display is not a raster. There is no electron beam in motion. Various kinds of screens have various mechanisms for controlling pixel colors. The screen, however, has still been composed of pixels, and the color values for all of them are recorded in a frame buffer. Raster graphics is defined as an image made up of a grid of pixels with numeric color values for every pixel (Stork, 2009; Lin et al., 1981). Although pixels have been used to depict pictures on a computer screen, choosing individual pixel colors has not been necessarily the best method to produce an image. Another option is to identify the fundamental geometric objects, like triangles, circles, lines, and rectangles, that it includes. Vector graphics are defined by this concept: Represent a picture as a list of geometric forms included inside it. Shapes can contain properties, such as the width of a line or the color that fills a rectangle, to make things more interesting. Simple geometric forms cannot be used to create every image. This method will not be appropriate for a photograph of a stunning sunset (or for almost any other type of photograph) (Faure Walker, 2006). It is, nevertheless, suitable for a wide range of visuals, including architectural plans and scientific representations. Vector images were even utilized directly on computer displays early in the history of computing. Raster displays had been too sluggish and costly to be useful when the 1st graphical computer screens were built. Luckily, vacuum tube technology might be used differently: the electron beam might be made to draw a line on the screen directly by sweeping the beam along the same line (Chan et

Introduction to Computer Graphics

19

al., 2002; Yuan, 1990). A presentation list of lines that must appear on the screen will be stored in a vector graphics display. Because a spot on the screen would only light for a brief while after being illuminated via electron beam, the graphics display will repeatedly cycle through the display list, redrawing all of the lines on the list. It will simply be necessary to update the items on the display list to change the picture. However, if the display list became too lengthy, the image will begin to flicker since a line will have a possibility to fade before its next turn was repainted, causing the image to flicker (Sýkora et al., 2009). But here is the point: For an image which may be represented as a limited number of geometric forms, the amount of data required to show the picture with a vector representation is substantially less than using a raster representation. Consider a picture composed of 1,000-line segments. Only the coordinates of 2,000 points, the line endpoints, are required for a vector representation of the image (Fontana et al., 2002). Only a few kilobytes of RAM will be required. Much more memory will be required to store the image in a frame buffer for a raster display. A vector display, likewise, might draw lines on the screen faster than a raster display might replicate the identical picture from the frame buffer to the screen. (Although, due to their capacity to display all forms of pictures pretty effectively, raster displays swiftly superseded vector displays as much as they became fast and affordable) (Hanrahan and Haeberli, 1990). In certain fields of computer graphics, the distinction between vector and raster graphics still exists. It may be observed, for instance, in the distinction between 2 types of image-creation systems: drawing programs and painting programs. The image has been shown as a grid of pixels in a painting application, and the client constructs an image by allocating colors to pixels (Ohbuchi et al., 2002). This can be accomplished by using a “drawing tool” that functions similarly to a paintbrush, or by employing tools that create geometric objects like lines or rectangles. However, with a painting application, the goal is to color individual pixels, and only the pixel colors have been kept. To illustrate, imagine you are using painting software to create a home, then adding a tree in front of it. If you remove the tree, all that remains is a blank background, not a home. In truth, the image did not contain a “home” only individual-colored pixels that the viewer would interpret as a picture of a house (Salomon, 2006; Edelsbrunner and Mücke, 1994).

20

Exploration of Computer Graphics

The consumer builds a picture in a drawing application by adding geometric forms, and the image has been depicted as a list of such shapes. If you set a home shape (or a set of forms that make up a house) in the picture and then add a tree shape on top of it, the house will remain since it is saved in the image’s list of shapes. The home would remain in the image if the tree is removed, precisely as it was before the tree had been installed. Moreover, you must be capable to choose one of the image’s forms and move or resize it, therefore, drawing applications provide a more comprehensive set of editing options than painting programs. (Although, the opposite is also true) (Lee, 1999; Kaiser et al., 1995). Although one or another seems to be generally dominant, a useful tool for picture production and modification may include features of drawing and painting. A drawing application, for instance, may enable the users to insert a raster-type picture and consider it as one shape. A painting application may allow the user to generate “layers,” which have independent pictures that may be stacked on top of one another to form the final image. The layers may then be modified similarly to how forms are manipulated in a drawing application (thus, you may retain your home and tree on distinct layers, even though the house is behind the tree in the image) (Freedman and Relan, 1992). Adobe Illustrator and Adobe Photoshop are two popular graphics tools. Photoshop is a painting application, whereas Illustrator is mostly a drawing program. Gimp, a GNU image-processing application, is a great option for Photoshop in the free software field, whereas Inkscape is a great free drawing program (Greene, 1985). In the world of graphics file formats, the distinction between vector and raster graphics is evident. A picture can be represented as data in a file in a variety of ways. The representation should meet certain exact, recognized standards if the original picture is to be retrieved from the bits saved in the file. A graphical file format is an example of such a standard. PNG, GIF, WebP, JPEG, and SVG are some of the most common graphics file types (Hertzmann et al., 2001; Badler and Bajcsy, 1978). The most common image formats on the Web include PNG, GIF, and JPEG, although most browsers also support SVG and the new WebP format. PNG, GIF, WebP, and JPEG are all raster graphics formats, which means that every pixel in an image is represented by a color value. Although GIF is an obsolete file format that has mainly been replaced by PNG, GIF pictures may still be seen on the internet. (Because the GIF format permits moving graphics,

Introduction to Computer Graphics

21

GIFs have been frequently utilized on Web pages for basic animations.) With a maximum of 256 colors, GIF employs an indexed color model. PNG pictures may be indexed or full 24-bit color, however, JPEG images must be full color (Zhu, 2022; Guo et al., 2020). A raster image might require a significant quantity of data to depict. The data, on the other hand, generally have a lot of redundancy, and it may be “compressed” to make it smaller. Lossless data compression is used by PNG and GIF, which implies that the original picture may be properly retrieved from the compressed data. JPEG employs a lossy data compression technology, which implies that the picture recovered from a JPEG file is not identical to the original; certain data has been lost. This may not seem like a smart idea, but the distinction is typically barely visible, and lossy compression usually allows for a larger decrease in compressed data size (Ugli and Ugli, 2022). JPEG is typically good for photographic photos, although it is not as good for photographs with sharp edges among colors. It is particularly awful for line drawings and pictures with text; for this kind of image, PNG is the preferred format. Lossy and lossless compression are also possible with WebP. SVG, on either hand, is a vector graphics format at its core (raster images may be included in SVG images). SVG is a 2D vector graphics picture description language based on XML. SVG refers to “Scalable Vector Graphics,” and the term “scalable” refers to one of vector graphics’ advantages: When the image size is raised, there has been no loss of quality (Schkolne et al., 2001; Brown, 1979). Any scale may be utilized to portray a line between 2 points, and it will still be the same geometric line. If, on either hand, you attempt to significantly expand the size of a raster image, you would then discover that you do not have sufficient color values for all of the pixels in the new picture. Every original picture pixel would be enlarged to encompass a rectangle of pixels in the scaled image, resulting in multi-pixel blocks of homogeneous color. SVG pictures are a suitable choice for web browsers and graphical components on your computer’s desktop due to their scalability. SVG pictures are increasingly being used for desktop icons in several desktop systems (Yang et al., 2016). A coordinate system is used to specify a digital image, regardless of its format. A coordinate system establishes a relationship between numerical values and geometrical points. Every point in 2D is given a pair of integers known as the coordinates of the point. Even though the labels “x” and “y” are arbitrary, the 2 coordinates of a point have been commonly referred to as its x and y coordinates. A raster picture is a 2D grid of pixels that have

22

Exploration of Computer Graphics

been organized into columns and rows (Osadcha et al., 2021; Frey et al., 1979). As a result, it features a natural coordinate system whereby each pixel correlates to a pair of numbers indicating the column and row wherein the pixel is located. (In this basic example, there has been debate about whether the rows must be numbered from bottom to top or top to bottom.) It is only normal to utilize real-number coordinates for a vector picture. To a certain extent, an image’s coordinate system is arbitrary; such that the same picture may be represented utilizing several coordinate systems. I am not going to speak anything about coordinate systems right now, but they will be a big part of the book, and they are much more essential in 3D than they are in 2D (Shilkrot et al., 2015).

1.10. COMPONENTS OF THREE-DIMENSIONAL GRAPHICS When we look into three-dimensional graphics, we discover that the most frequent techniques have much more popular with vector graphics than they do use raster graphics. This is because vector drawings are composed of lines rather than pixels. To put it another way, the contents of a picture are often described as a list of geometrical objects. The method in question is sometimes referred to by the term “geometric modeling.” The first step in the process is to build what is known as an “artificial 3D world” using a set of basic geometric forms that are organized in a 3-dimensional place. The look of the items in the world may be determined by a combination of the qualities those objects possess and the global features of the environment. In many cases, the spectrum of fundamental forms is quite constrained, consisting of possibly only line segments, points, and triangles at most (Sutton et al., 2000). If this is not itself regarded to be a fundamental form, a more complicated shape, like a sphere or polygon, may be constructed from a set of more primary shapes or its approximation may be created using this method. The scene is first projected from 3 dimensions down to 2 dimensions, which results in the creation of a 2D representation of the scene. The act of projecting an image onto a surface is analogous to taking a snapshot of the environment. Let us take a closer look at how everything operates by breaking it down into its parts (Figure 1.10) (Garg and Walker, 1990).

Introduction to Computer Graphics

23

Figure 1.10. Three-dimensional graphics depiction. Source: https://xd.adobe.com/ideas/principles/emerging-technology/3d-graphic-design-definition-and-principles/.

Let’s start with geometry. To begin, we have an empty three-dimensional space or “world.” This is helpful to visualize any image in your mind even though it simply exists in a conceptual sense. A coordinate system is required for the area, one that assigns three numbers to every point in the area. These numbers are commonly referred to as the x, y, and z coordinates of the point (Lucente, 1997). The term “world coordinates” refers to this particular set of coordinates. Our goal is to create a setting within the world that is composed of geometric shapes and items. For instance, we may indicate a line segment inside the scene by providing the coordinates of its two ends, and we may specify a triangle by providing the coordinates of its three vertices. Similarly, we may specify a point by providing its coordinates. The simplest building blocks that we have to deal with are referred to as geometric primitives. Some examples of geometric primitives are triangles and line segments. However, in most circumstances, the term “primitive” refers to just the most fundamental forms, like triangles and lines. This is because distinct graphics systems make accessible distinct collections of primitive (Kajiya & Kay, 1989). A complicated scene may have a huge number of primitives; therefore, creating the scene by supplying specific coordinates for every individual primitive will be quite laborious. The solution, just like any programmer would expect, is to group primitives into reusable elements. For instance, we could make a geometric model of a wheel for a scenario with numerous

24

Exploration of Computer Graphics

autos. Four wheels and models of other elements may be utilized to simulate a car. Then we’d be able to utilize many copies of the car model in the scenario. It’s worth noting that a geometric model may be utilized as an element in more complicated models once it has been created. This process is referred to as hierarchical modeling (Szirmay-Kalos, 1995). Let’s suppose we’ve made a model of a wheel out of geometric primitives. The coordinates of all of the primitives in the model of a vehicle would have to be modified when that wheel is placed into place. Thus, what have we achieved by constructing the wheel? The point is that each of the wheel’s coordinates is modified similarly. To put the wheel in the car, all we have to do is provide a single adjustment that is applied to the entire wheel. A geometric transformation can be thought of as a correction that is applied on the image. This transformation is a tool to change the orientation, size, or location of a geometric object. Whenever we make an automotive model, we make only one wheel (Langridge, 1974). The wheel model is then transformed four times to add four copies of the wheel to the car. Likewise, we may use different transformations on the same automobile model to add multiple cars to a scene. Scaling, translation, and rotation have been the three most fundamental types of geometric transforms. A scaling transform has been utilized to change the object size, making it smaller or bigger by a certain amount (Kai, 1994). A rotation transformation has been utilized to change the orientation of an object by rotating it around a specified axis at a particular angle. A translation transformation has been utilized to change an object’s location by displacing it by a specified amount from its initial position. We shall 1st encounter these changes in two dimensions, where they have been easier to comprehend, in this book. However, they become indispensable in three-dimensional graphics (Smith et al., 1992). Then there is the appearance. Geometric forms are not particularly intriguing on their own. You must have the ability to customize the look. Assigning characteristics to geometric objects does this. Color is an apparent property, but achieving a realistic appearance is far more difficult than simply giving color to every primitive. Rather than talking about color in three-dimensional graphics, we commonly talk about the material. The term “material” describes the characteristics that define a surface’s intrinsic visual aspect. In simple terms, this refers to how the surface interacts with light that strikes it. A fundamental hue, as well as additional attributes like

Introduction to Computer Graphics

25

roughness, shininess, and transparency, may be found in material properties (Brown, 1979). The texture is among the types of material properties that may be quite helpful. In the broadest sense, a texture may be defined as a method of altering the material qualities from one location on a surface to another. The most typical application of texture is to enable the employment of a variety of colors at various spots. The use of a two-dimensional picture as a texture is a common method for accomplishing this (Pérez et al., 2015). It is possible to apply the picture to a surface in such a way that it gives the appearance that it was “painted” onto the surface. On the other hand, “texture” may also refer to varying values for characteristics such as  ”transparency” or “bumpiness.” Textures provide us with the ability to add information to a scene without having to utilize a large number of geometric primitives; rather, you may utilize a smaller number of textured primitives. Textures also enable us to create more complex scenes. Material is an inherent quality of an object, yet the actual look of the object is contingent not only on the material itself but also on the context in which it has been viewed. In the actual world, there has been nothing visible until there is a certain source of illumination in the surrounding area (Kopperman et al., 1991). When it comes to threedimensional graphics, the same rule applies: a scene needs to have simulated lighting added to it. In any given situation, there may be more than one source of light. Every individual source of light may produce its color, level of brightness, and position in space. After then, the material qualities of the items in the picture would affect how the light from such sources interacts with them. The support for illumination in a graphics system may range from being quite straightforward to be extremely complicated and laborintensive to compute (Fairchild et al., 2013). Producing two-dimensional representations of three-dimensional environments is generally the purpose of three-dimensional graphics. Projection and viewing are required to make the transition from threedimensional to two-dimensional. When observed from a variety of vantage points, the world has a whole new appearance. When establishing a point of view, it is necessary to describe both the location of the viewer and the direction in which the viewer is looking at the scene (Ohtake et al., 1995). It is also important to indicate an “up” direction, which refers to a direction that would result in the picture being oriented such that it points upwards. One way to think about it is as if one were placing a “virtual camera” into the action. After the view has been established, the two-dimensional version of the globe may be projected onto it to show how it appears from that

26

Exploration of Computer Graphics

vantage point. The act of projecting anything is comparable to capturing a photograph with a camera (Caendish et al., 1985). The final stage in the process of creating three-dimensional images is to apply colors to each pixel that makes up the two-dimensional image. The production of a picture as a whole is described as “rendering the scene,” and the technique that we are currently discussing is termed “rasterization” (Cagan et al., 1998). In several situations, the final objective is to produce an animation, which is made up of a series of pictures that depict the globe at various moments. Small changes occur from one picture in the sequence to the next in an animation. While in an animation, almost every feature of a scene may alter, such as transformations, basic coordinates, material attributes, and perspective (Kuo et al., 2014). For instance, an object may be made to expand throughout an animation by gradually raising the scale factor in the object’s scaling transformation. Changing the perspective during an animation may create the illusion of moving or soaring through the environment. However, calculating the necessary modifications might be tricky. There are a variety of strategies that can aid in the calculations. The employment of a “physics engine” that calculates the interaction and motion of objects based on physics rules is among the most crucial (Artzy et al., 1981).

Introduction to Computer Graphics

27

REFERENCES 1.

Angel, E., & Shreiner, D., (2011). Teaching a shader-based introduction to computer graphics. IEEE Computer Graphics and Applications, 31(2), 9–13. 2. Angel, E., & Shreiner, D., (2014). Interactive Computer Graphics with WebGL (Vol. 1, pp. 2–9). Addison-Wesley Professional. 3. Artzy, E., Frieder, G., & Herman, G. T., (1981). The theory, design, implementation, and evaluation of a three-dimensional surface detection algorithm. Computer Graphics and Image Processing, 15(1), 1–24. 4. Badler, N., & Bajcsy, R., (1978). Three-dimensional representations for computer graphics and computer vision. In: Proceedings of the 5th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 153–160). 5. Bartels, R. H., Beatty, J. C., & Barsky, B. A., (1995). An Introduction to Splines for Use in Computer Graphics and Geometric Modeling (Vol. 1, p. 2). Morgan Kaufmann. 6. Belavina, T., Gorskaya, T., & Goulkanyan, M., (2020). Engineering and computer graphics for effective training in a construction university. In: IOP Conference Series: Materials Science and Engineering (Vol. 890, No. 1, p. 012173). IOP Publishing. 7. Bialac, R. N., (1985). Analysis of the Effectiveness and Efficiency of Business Decision-Making Using Computer Graphics (Vol. 1, pp. 2– 7). University of Cincinnati. 8. Blundell, B. G., (2008). An Introduction to Computer Graphics and Creative 3-D Environments (Vol. 1, pp. 1–9). Springer Science & Business Media. 9. Brown, B. E., (1979). Computer graphics for large scale two-and threedimensional analysis of complex geometries. In: Proceedings of the 6th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 33–40). 10. Brown, R. A., (1979). A computerized tomography-computer graphics approach to stereotaxic localization. Journal of Neurosurgery, 50(6), 715–720. 11. Buss, S., & Buss, S. R., (2003). 3D Computer Graphics: A Mathematical Introduction with OpenGL (Vol. 1, p. 9). Cambridge University Press.

28

Exploration of Computer Graphics

12. Caendish, J. C., Field, D. A., & Frey, W. H., (1985). An approach to automatic three‐dimensional finite element mesh generation. International Journal for Numerical Methods in Engineering, 21(2), 329–347. 13. Cagan, J., Degentesh, D., & Yin, S., (1998). A simulated annealing-based algorithm using hierarchical models for general three-dimensional component layout. Computer-Aided Design, 30(10), 781–790. 14. Calabrese, A., Almeida, J. P., & Pinho, R., (2010). Numerical issues in distributed inelasticity modeling of RC frame elements for seismic analysis. Journal of Earthquake Engineering, 14(S1), 38–68. 15. Case, M. E., (1971). The Applications of Computer Graphics in Industry and Implications for Drafting Curriculum on the College Level (Vol. 1, pp. 2–9). 16. Chan, C., Akleman, E., & Chen, J., (2002). Two methods for creating Chinese painting. In: 10th Pacific Conference on Computer Graphics and Applications, 2002: Proceedings (Vol. 1, pp. 403–412). IEEE. 17. Chen, W., Shi, Y. Q., & Xuan, G., (2007). Identifying computer graphics using HSV color model and statistical moments of characteristic functions. In: 2007 IEEE International Conference on Multimedia and Expo (Vol. 1, pp. 1123–1126). IEEE. 18. Coroneo, M., Montante, G., Paglianti, A., & Magelli, F., (2011). CFD prediction of fluid flow and mixing in stirred tanks: Numerical issues about the RANS simulations. Computers & Chemical Engineering, 35(10), 1959–1968. 19. De Luca, G., & Magnus, J. R., (2011). Bayesian model averaging and weighted-average least squares: Equivariance, stability, and numerical issues. The Stata Journal, 11(4), 518–544. 20. Debertin, D. L., & Goetz, S. J., (1992). Applications of Computer Graphics to Instruction in Agricultural Economics (No. 1637-2016135105) (Vol. 1, pp. 2). 21. Desmorat, R., Kane, A., Seyedi, M., & Sermage, J. P., (2007). Two scale damage model and related numerical issues for thermo-mechanical high cycle fatigue. European Journal of Mechanics-A/Solids, 26(6), 909–935. 22. Doolittle, J. A., (1987). Using ground‐penetrating radar to increase the quality and efficiency of soil surveys. Soil Survey Techniques, 20, 11–32.

Introduction to Computer Graphics

29

23. Dyer, C. R., (1982). The space efficiency of quadtrees. Computer Graphics and Image Processing, 19(4), 335–348. 24. Edelsbrunner, H., & Mücke, E. P., (1994). Three-dimensional alpha shapes. ACM Transactions on Graphics (TOG), 13(1), 43–72. 25. Fairchild, K. M., Poltrock, S. E., & Furnas, G. W., (2013). SemNet: Three-dimensional graphic representations of large knowledge bases. In: Cognitive Science and Its Applications for Human-Computer Interaction (Vol. 1, pp. 215–248). Psychology Press. 26. Fan, M., & Li, Y., (2020). The application of computer graphics processing in visual communication design. Journal of Intelligent & Fuzzy Systems, 39(4), 5183–5191. 27. Faure, W. J., (2006). Painting the Digital River: How an Artist Learned to Love the Computer, 1, 2–6. 28. Ferwerda, J. A., (2003). Three varieties of realism in computer graphics. In: Human Vision and Electronic Imaging VIII (Vol. 5007, pp. 290–297). SPIE. 29. Foley, J. D., Van, D. A., Feiner, S. K., Hughes, J. F., & Phillips, R. L., (1994). Introduction to Computer Graphics (Vol. 55, pp. 1–7). Reading: Addison-Wesley. 30. Foley, J. D., Van, F. D., Van, D. A., Feiner, S. K., Hughes, J. F., & Hughes, J., (1996). Computer Graphics: Principles and Practice (Vol. 12110, pp. 3–9). Addison-Wesley Professional. 31. Fontana, R., Greco, M., Materazzi, M., Pampaloni, E., Pezzati, L., Rocchini, C., & Scopigno, R., (2002). Three-dimensional modelling of statues: The Minerva of Arezzo. Journal of Cultural Heritage, 3(4), 325–331. 32. Freedman, K., & Relan, A., (1992). Computer graphics, artistic production, and social processes. Studies in Art Education, 33(2), 98– 109. 33. Frey, A. E., Hall, C. A., & Porsching, T. A., (1979). An application of computer graphics to three-dimensional finite element analyses. Computers & Structures, 10(1, 2), 149–154. 34. Garg, A., & Walker, P. S., (1990). Prediction of total knee motion using a three-dimensional computer-graphics model. Journal of Biomechanics, 23(1), 45–58.

30

Exploration of Computer Graphics

35. Gokhale, A., Ganapathy, V., & Padmanaban, Y., (2013). Inferring likely mappings between APIs. In: 2013 35th International Conference on Software Engineering (ICSE) (Vol. 1, pp. 82–91). IEEE. 36. Greene, R., (1985). The drawing prism: A versatile graphic input device. In: Proceedings of the 12th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 103–110). 37. Guo, C., Bai, T., Lu, Y., Lin, Y., Xiong, G., Wang, X., & Wang, F. Y., (2020). Skywork-DaVinci: A novel CPSS-based painting support system. In: 2020 IEEE 16th International Conference on Automation Science and Engineering (CASE) (Vol. 1, pp. 673–678). IEEE. 38. Hanrahan, P., & Haeberli, P., (1990). Direct WYSIWYG painting and texturing on 3D shapes: (An error occurred during the printing of this article that reversed the print order of pages 118 and 119. While we have corrected the sort order of the 2 pages in the DL, the PDF did not allow us to repaginate the 2 pages.). ACM SIGGRAPH Computer Graphics, 24(4), 215–223. 39. He, B., Fang, W., Luo, Q., Govindaraju, N. K., & Wang, T., (2008). Mars: A MapReduce framework on graphics processors. In: Proceedings of the 17th International Conference on Parallel Architectures and Compilation Techniques (Vol. 1, pp. 260–269). 40. Hertzmann, A., Jacobs, C. E., Oliver, N., Curless, B., & Salesin, D. H., (2001). Image analogies. In: Proceedings of the 28th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 327–340). 41. Hitchner, L. E., & Sowizral, H. A., (2000). Adapting computer graphics curricula to changes in graphics. Computers & Graphics, 24(2), 283– 288. 42. Hoines, E., (1987). A proposal for standard graphics environments. IEEE Computer Graphics and Applications, 7(11), 3–5. 43. Huang, S., Xiao, S., & Feng, W. C., (2009). On the energy efficiency of graphics processing units for scientific computing. In: 2009 IEEE International Symposium on Parallel & Distributed Processing (Vol. 1, pp. 1–8). IEEE. 44. Hughes, J. F., Van, D. A., McGuire, M., Foley, J. D., Sklar, D., Feiner, S. K., & Akeley, K., (2014). Computer Graphics: Principles and Practice (Vol. 1, pp. 2–7). Pearson Education.

Introduction to Computer Graphics

31

45. Johnsson, B., Ganestam, P., Doggett, M. C., & Akenine-Möller, T., (2012). Power efficiency for software algorithms running on graphics processors. In: High Performance Graphics (Vol. 1, pp. 67–75). 46. Jones, T. A., (1985). Interactive computer graphics: FRODO. In: Methods in Enzymology (Vol. 115, pp. 157–171). Academic Press. 47. Kai, C. C., (1994). Three-dimensional rapid prototyping technologies and key development areas. Computing & Control Engineering Journal, 5(4), 200–206. 48. Kaiser, M. K., Montegut, M. J., & Proffitt, D. R., (1995). Rotational and translational components of motion parallax: Observers’ sensitivity and implications for three-dimensional computer graphics. Journal of Experimental Psychology: Applied, 1(4), 321. 49. Kajiya, J. T., & Kay, T. L., (1989). Rendering fur with three dimensional textures. ACM SIGGRAPH Computer Graphics, 23(3), 271–280. 50. Kakadiaris, I. A., Passalis, G., Toderici, G., Murtuza, M. N., Lu, Y., Karampatziakis, N., & Theoharis, T., (2007). Three-dimensional face recognition in the presence of facial expressions: An annotated deformable model approach. IEEE Transactions on Pattern Analysis and Machine Intelligence, 29(4), 640–649. 51. Kopperman, R., Meyer, P. R., & Wilson, R. G., (1991). A Jordan surface theorem for three-dimensional digital spaces. Discrete & Computational Geometry, 6(2), 155–161. 52. Kuo, C. C., Lu, H. L., Leardini, A., Lu, T. W., Kuo, M. Y., & Hsu, H. C., (2014). Three‐dimensional computer graphics‐based ankle morphometry with computerized tomography for total ankle replacement design and positioning. Clinical Anatomy, 27(4), 659–668. 53. Langridge, R., (1974). Interactive three-dimensional computer graphics in molecular biology. In: Computers in Life Science Research (Vol. 1, pp. 53–59). Springer, Boston, MA. 54. Lee, J., (1999). Simulating oriental black-ink painting. IEEE Computer Graphics and Applications, 19(3), 74–81. 55. LeFloch, P. G., (2010). Kinetic relations for under compressive shock waves. Physical, mathematical, and numerical issues. Nonlinear Partial Differential Equations and Hyperbolic Wave Phenomena, 526, 237–272.

32

Exploration of Computer Graphics

56. Lin, V. C., Gossard, D. C., & Light, R. A., (1981). Variational geometry in computer-aided design. ACM SIGGRAPH Computer Graphics, 15(3), 171–177. 57. Lindholm, E., Nickolls, J., Oberman, S., & Montrym, J., (2008). NVIDIA Tesla: A unified graphics and computing architecture. IEEE Micro, 28(2), 39–55. 58. Lourenço, P. B., (1998). Experimental and Numerical Issues in the Modeling of the Mechanical Behavior of Masonry (Vol. 1, pp. 1–4). 59. Lucente, M., (1997). Interactive three-dimensional holographic displays: Seeing the future in depth. ACM SIGGRAPH Computer Graphics, 31(2), 63–67. 60. Mark, W. R., Glanville, R. S., Akeley, K., & Kilgard, M. J., (2003). Cg: A system for programming graphics hardware in a C-like language. In: ACM SIGGRAPH 2003 Papers (Vol. 1, pp. 896–907). 61. Marsh, J. L., Vannier, M. W., Bresina, S., & Hemmer, K. M., (1986). Applications of computer graphics in craniofacial surgery. Clinics in Plastic Surgery, 13(3), 441–448. 62. McCracken, C. R., (2006). Issues in computer graphics education. In: ACM SIGGRAPH 2006 Educators Program (Vol. 1, pp. 29-es). 63. Ohbuchi, R., Otagiri, T., Ibato, M., & Takei, T., (2002). Shape-similarity search of three-dimensional models using parameterized statistics. In: 10th Pacific Conference on Computer Graphics and Applications, 2002: Proceedings (Vol. 1, pp. 265–274). IEEE. 64. Ohtake, T., Abe, R., Kimijima, I., Fukushima, T., Tsuchiya, A., Hoshi, K., & Wakasa, H., (1995). Intraductal extension of primary invasive breast carcinoma treated by breast conservative surgery. Computer graphic three‐dimensional reconstruction of the mammary duct‐lobular systems. Cancer, 76(1), 32–45. 65. Osadcha, K. P., Osadchyi, V. V., Kruglyk, V. S., & Spirin, O. M., (2021). Digital drawing and painting in the training of Bachelors of Professional Education: Experience of blended learning. In: Digital Humanities Workshop (Vol. 1, pp. 141–147). 66. Pang, Y. J., Yang, S. X., & Chi, Y., (1987). Combining computer graphics with Chinese traditional painting. Computers & Graphics, 11(1), 63–68.

Introduction to Computer Graphics

33

67. Papathomas, T. V., Schiavone, J. A., & Julesz, B., (1988). Applications of computer graphics to the visualization of meteorological data. In: Proceedings of the 15th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 327–334). 68. Pérez, S., Tubiana, T., Imberty, A., & Baaden, M., (2015). Threedimensional representations of complex carbohydrates and polysaccharides—SweetUnityMol: A video game-based computer graphic software. Glycobiology, 25(5), 483–491. 69. Pulli, K., (2006). New APIs for mobile graphics. In: Multimedia on Mobile Devices II (Vol. 6074, p. 607401). SPIE. 70. Ranon, R., & Urli, T., (2014). Improving the efficiency of viewpoint composition. IEEE Transactions on Visualization and Computer Graphics, 20(5), 795–807. 71. Salomon, D., (2006). Transformations and Projections in Computer Graphics (Vol. 233, pp. 2–7). London: Springer. 72. Samet, H., (1990). Applications of Spatial Data Structures: Computer Graphics, Image Processing, and GIS (Vol. 1, p. 24). Addison-Wesley Longman Publishing Co., Inc. 73. Schkolne, S., Pruett, M., & Schröder, P., (2001). Surface drawing: Creating organic 3D shapes with the hand and tangible tools. In: Proceedings of the SIGCHI Conference on Human Factors in Computing Systems (Vol. 1, pp. 261–268). 74. Schneider, J. B., (1978). Applications of computer graphics in the transportation field. Computer Graphics, 1(13), 2–8. 75. Shen, H. W., Hansen, C. D., Livnat, Y., & Johnson, C. R., (1996). Isosurfacing in span space with utmost efficiency (ISSUE). In: Proceedings of Seventh Annual IEEE Visualization’96 (Vol. 1, pp. 287–294). IEEE. 76. Shilkrot, R., Maes, P., Paradiso, J. A., & Zoran, A., (2015). Augmented airbrush for computer aided painting (CAP). ACM Transactions on Graphics (TOG), 34(2), 1–11. 77. Smith, G. S., Curtis, J. P., & Edwards, C. M., (1992). A method for analyzing plant architecture as it relates to fruit quality using threedimensional computer graphics. Annals of Botany, 70(3), 265–269. 78. Smits, B., (1998). Efficiency issues for ray tracing. Journal of Graphics Tools, 3(2), 1–14.

34

Exploration of Computer Graphics

79. Stork, D. G., (2009). Computer vision and computer graphics analysis of paintings and drawings: An introduction to the literature. In: International Conference on Computer Analysis of Images and Patterns (Vol. 1, pp. 9–24). Springer, Berlin, Heidelberg. 80. Sutton, M. A., McNeill, S. R., Helm, J. D., & Chao, Y. J., (2000). Advances in two-dimensional and three-dimensional computer vision. In: Photomechanics (Vol. 1, pp. 323–372). Springer, Berlin, Heidelberg. 81. Sýkora, D., Dingliana, J., & Collins, S., (2009). Lazybrush: Flexible painting tool for hand‐drawn cartoons. In: Computer Graphics Forum (Vol. 28, No. 2, pp. 599–608). Oxford, UK: Blackwell Publishing Ltd. 82. Szirmay-Kalos, L., (1995). Theory of Three-Dimensional Computer Graphics (Vol. 590, pp. 2–10). Budapest: Akadémiai Kiadó. 83. Taxén, G., (2004). Teaching computer graphics constructively. Computers & Graphics, 28(3), 393–399. 84. Ugli, D. S. D., & Ugli, A. B. I., (2022). Modular technology of teaching engineering computer graphics to future teachers drawing. Current Research Journal of Philological Sciences (2767–3758), 3(01), 101– 107. 85. Vidal, F. P., Bello, F., Brodlie, K. W., John, N. W., Gould, D., Phillips, R., & Avis, N. J., (2006). Principles and applications of computer graphics in medicine. In: Computer Graphics Forum (Vol. 25, No. 1, pp. 113–137). 9600 Garsington Road, Oxford, OX4 2DQ, UK.: Blackwell Publishing Ltd. 86. Volino, P., & Magnenat-Thalmann, N., (2001). Comparing efficiency of integration methods for cloth simulation. In: Proceedings: Computer Graphics International 2001 (Vol. 1, pp. 265–272). IEEE. 87. Whitted, T., (1983). Anti-aliased line drawing using brush extrusion. In: Proceedings of the 10th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 151–156). 88. Wickham, K. L., (1991). Computer interactive graphics fitting of efficiency curves for Ge detectors. Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment, 300(3), 605–610. 89. Wilkens, L., (2001). A multi-Api course in computer graphics. Journal of Computing Sciences in Colleges, 16(4), 66–73. 90. Yang, L., Xu, T., & Wu, E., (2016). Animating Strokes in Drawing Process of Chinese Ink Painting, 1, 2–9.

Introduction to Computer Graphics

35

91. Yuan, X., (1990). Three-dimensional electromagnetic scattering from inhomogeneous objects by the hybrid moment and finite element method. IEEE Transactions on Microwave Theory and Techniques, 38(8), 1053–1058. 92. Yun-Jie, P., & Hui-Xiang, Z., (1991). Drawing Chinese traditional painting by computer. In: Modeling in Computer Graphics (Vol. 1, pp. 321–328). Springer, Tokyo. 93. Żak, A., & Krawczuk, M., (2011). Certain numerical issues of wave propagation modeling in rods by the spectral finite element method. Finite Elements in Analysis and Design, 47(9), 1036–1046. 94. Zhu, H., (2022). The optimization function of computer image technology in processing oil painting creation. Wireless Communications and Mobile Computing, 1, 4–9. 95. Zhu, J., & Wu, P., (2021). Towards effective BIM/GIS data integration for smart city by integrating computer graphics technique. Remote Sensing, 13(10), 1889.

CHAPTER

2

TWO-DIMENSIONAL COMPUTER GRAPHICS

CONTENTS 2.1. Introduction....................................................................................... 38 2.2. Pixels, Coordinates, and Colors......................................................... 38 2.3. Shapes............................................................................................... 46 2.4. Transforms......................................................................................... 52 2.5. Hierarchical Modeling....................................................................... 58 2.6. Java Graphics2d................................................................................. 63 References................................................................................................ 67

38

Exploration of Computer Graphics

2.1. INTRODUCTION Here, we start our studies of computer graphics by focusing on a twodimensional example. Computer graphics concepts are easier and simpler to understand in a 2D environment rather than in a 3D setting. However, the majority of the concepts taught in this section are equally applicable in 3D. The chapter begins with four components that look at 2D graphics broadly, without focusing on a specific computer program or visuals API (Reichenbach et al., 2004). The programming samples in such parts are presented in pseudocode, which should become intelligible to anybody studying this book which has some coding skills. We’ll examine 2D graphics in three different languages in the following three parts: Java with Graphics2D, JavaScript using HTML graphics, and SVG. We’ll explore whether any of the broad concepts from previously in the chapter are used in such languages (Sutton et al., 2000).

2.2. PIXELS, COORDINATES, AND COLORS In a 2D picture, color is allocated to every location in the system. A set of numerical values may be used to identify a location in 2D. Additionally, colors may be supplied quantitatively. Nevertheless, the numbering of points and colors is rather random. Therefore, we must pay some attention to learning coordinate systems as well as modeling software, that assigns integers to points as well as colors, respectively (Akeley, 1993).

2.2.1. Pixel Coordinates A digital picture is composed of columns and rows of pixels. A pixel inside this kind of image may be described by specifying its column and row. A pixel’s values consist of a combination of numbers representing the column integer as well as the number of rows. For instance, the pixel with points (3,5) will be located in the third column and fifth row. Columns are typically ordered from left to right, beginning with 0. The majority of graphical systems, such as the ones discussed in this section, count rows from top to bottom, beginning with zero. Others, such as OpenGL, simply rank the rows from bottom to top (Figure 2.1) (Sims, 1991).

Two-Dimensional Computer Graphics

39

Figure 2.1. 12-by-8-pixel grids containing rows or column numbers. The rows on the left are marked as top to bottom, while those on the right are counted from bottom to top. Source: https://math.hws.edu/graphicsbook/c2/s1.html.

Notice specifically that the pixel specified by a particular spot (x,y) is dependent on the coordinate system used. Prior to identifying a specific point, it is always necessary to identify the coordinates being used. Pixels, not points, are designated by column or row numbers. Statistically, a pixel consists of an unlimited number of points. The objective of computer animation is not to color pixels, but rather to build and modify pictures (Heckbert, 1982; Burt and Perrett, 1995). Idealistically, a picture must be characterized by assigning a color to every point, not merely every pixel. Pixels are estimation units. If we assume that there is a genuine, ideal picture that we wish to portray, then every image generated by painting pixels is an interpretation. This has several ramifications. Consider the case whenever we wish to create a line. A geometrical line lacks thickness and is thus undetectable. Therefore, we need to create a thick line section with a certain width. Consider that such width of the line ought to be one pixel (Xalilova and Rixsiboev, 2021). Except if the line is parallel or perpendicular, it is impossible to create it by painting pixels. A diagonal geometrical line would partly overlap certain pixels. It is impossible to create a pixel partially black and partially white.

40

Exploration of Computer Graphics

While attempting to create a line using just black and white pixels, a stairway effect is created (Rowland and Perrett, 1995). That image is an instance of a phenomenon known as “aliasing. Aliasing may also be observed in the contours of on-screen figures as well as the lateral or twisted borders among any two sections of a different hue. (The word aliasing most likely originates from the idea that perfect pictures are easily expressed using real-number coordinates. When attempting to depict an image utilizing pixels, numerous real-number values map to the similar integer pixel coordinates; these realnumber locations may be thought of as variable names or “aliases” for the similar pixel (Foley et al., 1996). Antialiasing refers to approaches that are meant to lessen aliasing’s effects. Whenever a pixel is partly covered by a form, it is color ought to be a combination of the shape’s color and the backdrop color. While creating a black line on a white backdrop, the color of a pixel that is half covered by the arc is gray, along with the color of gray depending on the percentage of the pixel that is filled. (In reality, it is impractical to calculate this area precisely for every pixel, hence an approximation is employed) (Sajadi et al., 2009). On the left is a geometrical line, and on the right are two estimations of the same line created by shading pixels. The bars are significantly enlarged such that the specific pixels can be seen. The column on the right utilizes antialiasing, but the line in the center does not (Figure 2.2) (Hart, 2001).

Figure 2.2. Illustration of antialiasing. Source: https://www.quora.com/What-is-Anti-aliasing.

Two-Dimensional Computer Graphics

41

Antialiasing does not guarantee a flawless picture, but it can help to lessen the “jaggies” produced by aliasing (at minimum, when it is observed on a standard scale). Other complications arise when converting realnumber values to pixels. What position in a pixel, for instance, must equate to arithmetic values like (3,5)? What is the pixel’s center? Is it among the pixel’s corners? In practice, we consider the numerals to relate to the pixel’s top-left side. Numeric coordinates relate to the arcs among pixels instead of the pixels directly, according to the other mode of thinking about that now. However, whenever a geometrical form is created, this still does not indicate what pixels are impacted (Figure 2.3) (Bailey and Glassner, 2004).

Figure 2.3. Two lines are produced utilizing HTML canvas graphics and amplified significantly. The columns were to be black with such a one-pixel beam width. Source: https://usefulangle.com/post/17/html5-canvas-drawing-1px-crispstraight-lines.

The upper line has been drawn from location (100,100) to point (100,100). (120,100). Whenever a one-pixel line is painted on canvas images, it stretches one-half pixel on each end of the infinitely small geometrical line. As a result, the top line has been drawn halfway inside one line of pixels as well as halfway in another. The antialiasing graphics technology generated the line by making adjacent sets of pixels gray (Segal et al., 1992). The bottom line has been drawn from the location (100.5,100.5) to the position (100.5,100.5). (120.5,120.5). The arc in this example runs precisely along the one-pixel line, which is tinted black. The gray pixels at the bottom line’s ends are attributed to the reason that the arc only reaches midway into the pixel now at extremities. Various graphics systems may display

42

Exploration of Computer Graphics

similar lines uniquely (Heidrich et al., 1999). You may play around with pixels as well as antialiasing in the active sample c2/pixel-magnifier.html. On the online websites of the online edition of this book, there are active demonstrations. The demonstrations may also be found in the examples folder if you already have saved the webpage. (Notice that you may get additional data about how to utilize some of the other active demonstrations that come with this book by clicking the question mark symbol in the top left corner) (Bresenham, 1996). The idea that pixels are not whatever they seem to be complicates things even more. Pixels have shrunk in size in recent years! The amount of pixel resolution on a projection device’s panel may be quantified in terms of PPI (pixels per inch) or DPI (dots per inch). Early displays had a resolution of about 72 PPI (Engel et al., 2001). Pixel values are easily visible at such a level and a normal visual range. Many screens used to have about 100 PPI, however, today’s high-resolution screens may well have 200, 300, or perhaps even 400 PPI. Single pixels could not more be differentiated at the greatest resolutions (Chen and Williams, 1993). If we employ coordinate systems that rely on pixels, the idea that pixel values exist in a variety of lengths is a difficulty. On a 400 PPI panel, a picture made using 100 PPI would seem small. At 100 PPI, just one line looks OK, although, at 400 PPI, just one bar is likely quite narrow (Omer and Werman, 2004). In truth, the term “pixel” is not always used to relate to the diameter of a real pixel in several graphics’ technologies. Rather, it is merely an additional measuring device that the system determines to be acceptable. (A pixel on a windows computer is generally one-tenth of an inch.) The figure could be nearer to 1/160 inch on a cellphone, which is normally seen from a closer range. Moreover, whenever a user implies magnification to a website page, the significance of pixels as a measurement system might alter) (Poco et al., 2017). Pixels create issues that have yet to be fully resolved. Luckily, vector graphics, which we should largely employ therefore in the book, are enough of an issue. Pixels also become a concern for vector images in image preprocessing, the process of converting a vector picture into pixels for viewing. Any appropriate coordinate may be used to make the vector picture. It depicts a resolution-independent, ideal picture. A rasterized picture is a good estimate of the perfect version, yet the screen technology can handle

Two-Dimensional Computer Graphics

43

the estimate (Liu et al., 2012).

2.2.2. Real-Number Coordinate Systems In two-dimensional images, you are provided a rectangle within which to create visuals of primitive people. On the rectangle, components are described to use a coordinate. The application-appropriate coordinate system must be selectable (Pulli et al., 1998). If the rectangle depicts a layout for a 15-foot-by-12-foot room, for instance, you may be using a coordinate wherein the measurement system becomes a foot, as well as the location data, as well as the location data, varies from zero to 15 in the straight line and 0 to 12 in the vertical plane. In this situation, feet instead of pixels are the standard measurement, and one foot might equate to several pixels in the picture (Saito et al., 2019). In practice, the values of a pixel would be real values instead of integers. In reality, it is preferable to exclude pixels and just consider picture elements. A point would possess a set of real-number values. Simply give the linear values for the right and left edges of the rectangles as well as the longitudinal values for the upper and lower to describe the coordinates for a rectangular (Ertl, 1996). Such numbers will be referred to as left, right, top, and bottom. They are often referred to as xmin, xmax, ymin, and ymax, although there is no cause to suppose, for instance, that upper is below lower. We may need a coordinate system where the longitudinal coordinate grows from bottom to top as opposed to top to bottom. In this situation, the top corresponds to the largest y-value rather than the least (McDonnell and Mueller, 2008). It would also be beneficial to provide a function like a set coordinate system that allows the programmer to define the coordinate they want to use (left, right, bottom, top). The graphics system will subsequently be accountable for properly converting the specified coordinate system’s values to pixel coordinates. Thus, a procedure may not exist, hence it is important to observe how the change is performed manually. Examine the entire situation (Dony and Wesolkowski, 1999). With the values for a location in one coordinate, we wish to determine the similar point’s coordinates in another coordinate system. (Keep in mind that a coordinate is just a method for assigning numerical values to places. It is all about the points!) Assume that the lateral and vertical boundaries of the first coordinate are oldLeft, oldRight, oldTop, and oldBottom, and also that the boundaries of the other coordinate are newLeft, newRight, newTop, and newBottom. Assume that

44

Exploration of Computer Graphics

a point in the first coordinate has dimensions (oldX, oldY). We would like to determine the point’s new coordinates (newX, newY) in the second coordinate system. Next, the equations for newX and newY are provided by (Majumder and Stevens, 2004): newX = newLeft + ((oldX – oldLeft)/(oldRight – oldLeft)) * (newRight – newLeft)) newY = newTop + ((oldY – oldTop)/(oldBottom – oldTop)) * (newBotom – newTop) oldX is situated at a particular proportion of the gap between oldLeft and newX oldRight. This fraction is represented by: ((oldX – oldLeft)/(oldRight – oldLeft)) The formula for newX simply specifies that it should be located at a similar percentage of the interval between newLeft and newRight. You may also test if the formulae work whenever oldX is similar to oldLeft or oldRight, and so when oldY is equivalent to oldBottom or oldTop. As an instance, assume we would like to translate real-number cartesian coordinates with boundaries left, right, top, as well as bottom to pixel location ranging from 0 to 800 on the left as well as from 0 to 600 on the right. In such a scenario, newLeft, and newTop are both zero, and the calculations are straightforward (Wallach et al., 1994). newX = ((oldX – left)/(right – left)) * 800 newY = ((oldY – top)/(bottom – top)) * 600 This returns newX and newY as actual figures, which must be adjusted or trimmed to integers if we want numeric positions for pixels. Also important is the transition from pixel location to real figure values. For instance, if the picture is shown on a computer monitor and you wish to respond to clicks of the mouse, you would likely receive the mouse locations in the form of numeric pixel location, but you will have to translate such pixel values through your coordinate. However, you will seldom need to perform the modifications manually, since the majority of graphic APIs give a higherlevel method for defining transformations (Figure 2.4) (Mohring et al., 2004).

Two-Dimensional Computer Graphics

45

Figure 2.4. A diagram of transmissions.

2.2.3. Aspect Ratio The width-to-height proportion of a rectangle is called its aspect ratio. A rectangle with a 2:1 aspect ratio is double as broad as it is high, whereas a rectangle with a 4:3 aspect ratio is 4/3 the breadth of the altitude. While aspect ratios are commonly stated in the format width: height, I would refer to the proportion width/height as the word. The aspect ratio of a square is one. The width of a rectangle with an aspect ratio of 5/4 and a height of 600 is 600*(5/4), or 750 (Garces et al., 2012). The aspect ratio is another property of a reference frame. If the coordinate system’s azimuth and elevation boundaries are left, right, bottom, and top, respectively, the aspect ratio is the exact number of (right-left)/(top-bottom) (Magnenat et al., 2015). Whenever the reference system is applied to a rectangle with a similar aspect ratio, one component in the horizontal plane has a similar apparent height as a component in the vertical position whenever seen in that rectangle. There will be some deformation if the aspect ratios do not match. For instance, the form specified by the equation x2 + y2 = 9 ought to be round, but this is only valid if the (x,y) reference system’s aspect ratio equals the sketching area’s aspect ratio (Carr and Hart, 2002). Using distinct length measures in the longitudinal and transverse directions is not necessarily a negative concept. Assume, though, that you wish to employ positions with left, right, bottom, as well as top bounds while

46

Exploration of Computer Graphics

maintaining the aspect ratio. Based on the form of the screen rectangle, you may need to alter the numbers of left and right, as well as bottom and top, to fit the aspect ratios: Later in this section, we will go more into geometric transforms, as well as we will see more computer code for building up coordinate systems (Ledley et al., 1990).

2.3. SHAPES We have been discussing low-level graphics notions, including pixels as well as coordinates, but we should not have to operate at those levels very often. Rather than dealing with new pixels, most graphics system enables you to deal with higher-level structures like triangles and circles. And instead of dealing with coordinates, a majority of the difficult work with exact location is performed through transformations. We will examine a few of the greater features that 2D graphics APIs normally offer from this and the subsections (Goel et al., 1991).

2.3.1. Basic Shapes Some simple forms may be produced using only one command in a graphics API, but more complicated designs would need numerous operations. The definition of a fundamental shape differs from one API to the next. The only fundamental forms in the WebGL API, for instance, are dots, lines, and triangles. Lines, rectangles, as well as ovals are considered fundamental in this area (Kung et al., 1985). I truly mean “line segment,” which is a linear fashion section that connects two locations in the level. The simplest basic form is a one-pixelwide line section with no antialiasing. Color pixels sit along infinitely small geometrical reference lines to create it (Barnsley et al., 1988). A line-drawing algorithm must pick what pixels to color precisely. Bresenham’s technique for a pencil sketch, one of the earliest computer graphics algorithms, offers an extremely fast approach for doing so. I will not go into these reduced specifics here, but they are worth digging up if you need some to understand more of what graphics technology has to perform at a fundamental level. In every event, lines are much more difficult to work with. One problem is antialiasing. Another factor is the line width. It is possible to draw a rectangle out of a broad line (Patil and Ravi, 2005). Other qualities, or features, may impact the look of lines. What must occur at the end of a very long line, for example? A curved “cap” on the edges of the line would enhance its look. A square cap—that is, expanding

Two-Dimensional Computer Graphics

47

the line by 1⁄2 the breadth of the line—could also be useful. Another concern is how horizontal lines must be linked when they intersect as sections of a bigger form. Lines made comprised of dashes and dots are supported by several graphics’ programs (Figure 2.5) (Franklin and Barr, 1981).

Figure 2.5. Some of the possibilities are shown. Source: https://www.khanacademy.org/economics-finance-domain/microeconomics/basic-economic-concepts-gen-micro/production-possibilities/a/theproduction-possibilities-frontier-and-social-choices-cnx-2.

Three broad lines with really no caps, a round hat, and a square cap appear on the left. The portion of the geometrical line is seen as a dashed line. (The style without capitalization is known as “butt.”) There are four lines with distinct patterns of dashes and dots to the right. There are three types of lines connected in the middle: corners, curved, and beveled. The fundamental rectangle form has transverse and longitudinal sides. (Typically, a slanted rectangle is created by performing a rotation.) A rectangle of this kind may be characterized by two points, (x1,y1) and (x2,y2), which indicate the ends of one of its diagonals (Teichmann and Capps, 1998). Alternatively, dimensions may be provided in addition to a singular baseline (x,y). In this scenario, the width and length must be positive; otherwise, the rectangle will be blank. If y grows from top to bottom, the reference value (x,y) would be the upper-left edge of the rectangle, and if y rises from bottom to top, it’ll be the lower left edge. Assume you are provided the coordinates (x1,y1) and (x2,y2) and wish to create the rectangle they define. Consider that the sole rectangular shape instruction accessible to you needs a point (x,y), width, and height. x has to be the lesser of x1 and x2 for this command, and the widths may be calculated as the exact amount

48

Exploration of Computer Graphics

of x1 − x2. Likewise for y as well as the height. DrawRectangle from the coordinates (x1,y1) and (x2,y2) in pseudocode: x = min ( x1, x2 ) (Chazelle, 1985): x = min(x1, x2) y = min(y1, y2) width = abs(x1 – x2) height = abs(y1 – y2) DrawRectangle(x, y, width, height) Allowing rounded edges is a popular modification to rectangles. For a “round rect,” elliptical arcs substitute the corners. The amount of round may be chosen by providing the ellipse’s azimuth and elevation radii. The following are instances of round rects (Figure 2.6) (Sharf et al., 2007).

Figure 2.6. The two ellipse radii for the form on the right. Source: https://www.coursehero.com/study-guides/boundless-algebra/the-circle-and-the-ellipse/.

My last fundamental form is the oval. (Ovals are sometimes known as ellipses.) The oval shape is a complete curve with two radii. We suppose that the radii of a basic ellipse are horizontal and vertical. You may specify an oval with this attribute by providing the rectangle that includes it. Alternately, it may be stated by providing its midpoint and the transverse and longitudinal radii (Figure 2.7) (Li et al., 2015).

Two-Dimensional Computer Graphics

49

Figure 2.7. The ellipse on the left with its enclosing rectangle, as well as its centerline and radii. Source: https://www.joshuanava.biz/engineering-3/methods-of-drawing-anellipse.html.

The rightmost oval is a round. A ring is just an ellipse whose two radii are of equal length. If ovals are unavailable as fundamental forms, they might be represented by sketching several two lines. The sequence required for an accurate estimate varies on the oval’s size. It is beneficial to possess this skill. Consider an oval with a midpoint of (x,y), a horizontal radius of (r1), and a vertical radius of (r2). The simple equation for the oval’s points is (Nguyen-Phuoc et al., 2018): (x + r1*cos(angle), y + r2*sin(angle)) The units of measurement are radians and sin and cos are the sine and cosine functions, respectively. Using this technique, we may produce a certain number of points and then link them with line segments to approximate an oval. Assuming angles are measured in radians and pi represents the mathematical constant in pseudocode (Hanrahan & Haeberli, 1990), Design oval with center (x,y) and horizontal and vertical radii r1 and r2: between I = 0 and numberOfLines:: angle1 = i * (2*pi/numberOfLines) angle2 = (i+1) * (2*pi/numberOfLines) a1 = x + r1*cos(angle1) b1 = y + r2*sin(angle1) a2 = x + r1*cos(angle2)

50

Exploration of Computer Graphics

b2 = y + r2*sin(angle2) Draw Line from (x1,y1) to (x2,y2) Obviously, for a circle, r1 equals r2 is sufficient. First time using the sine and cosine functions, but not the last. Because they are associated with circles, circular motion, and rotation, these functions play a crucial role in computer graphics. They will reappear when we discuss transformations in the subsequent section (Liu et al., 2010).

2.3.2. Stroke and Fill In a drawing, there are two methods to create a form. It may be created by drawing several distinct strokes. Or, if the form is closed, like a rectangle or an oval, it may be filled. A line is created by dragging a pen down the line. A rectangle or oval is drawn by dragging a pen with its perimeter. Fill a shape involves coloring all of the points included inside the form. It is likely to stroke and seals a similar form, in which case the inside and contour of the shape might have distinct appearances (Owada et al., 2003). Whenever a form crosses itself, such as the two patterns in Figure 2.8, it is unclear what must be considered the shape’s core. There are at minimum two distinct filling procedures for this form. Both are dependent on what is known as the winding number. The winding number of a form about a point is, approximately speaking, the number of times the form winds anticlockwise all-around spot in the positive direction. A winding number may be negative whenever the winding orientation is counterclockwise (Saito and Takahashi, 1990).

Figure 2.8. The patterns on the left are drawn in the direction indicated, and the amount that winds around each area is displayed as an integer within the region. Source: https://www.chegg.com/homework-help/questions-and-answers/general-circulation-1-using-figure-64-fill-wind-flow-arrows-correspond-windsmove-global-c-q67156517.

Two-Dimensional Computer Graphics

51

The designs are still seen with the two fill rules that apply. The fill rule for the forms in the middle is to paint any area with an integer winding number. For the forms on the right, the principle is to color areas with an odd number of cycles; areas with an even number of cycles are not colored. Unanswered is the problem of what will be used to fill a form. It may be completed with colors, but other filling kinds, such as designs and slopes, are also available (Frisken et al., 2000). Typically, a model consists of a little picture. Whenever utilized to fill a form, a pattern may be replicated vertically and horizontally as many times as required to enclose the object. A slope is comparable to graduation and it is a method for varying color from spot to spot, however, the colors are calculated rather than extracted from a picture. There are several variants on the fundamental concept because there is always a section of varying hue along a line. The color is given at the ends of the reference line and maybe at extra locations; the color is approximated between these points (Van den Doel and Pai, 1998). Additionally, the color may be extended to additional locations on the path that includes the line but lies external to the reference line, whether by replicating the patterns from the reference line or by stretching the color from the closest terminal. For a linear slope, the color stays unchanged along lines orthogonal to the normal reference line, resulting in solid white lines of color in that orientation. In a radial slope, the color stays unchanged around circles that are located on one of the line segment’s ends. Furthermore, this does not exhaust the options. Here is a form filed with various slopes and two designs to offer you a sense of what designs and slopes may appear like (Figure 2.9) (Johnson, 1996).

Figure 2.9. Forms with two slopes and two designs. Source: https://www.cuemath.com/geometry/two-point-form/.

The first form must be completed with a two-color linear slope, whereas the second employs a radial curve. Not all designs and slopes are confined to filling shapes. Stroking a form is identical to filling a strip of pixels all along

52

Exploration of Computer Graphics

the shape’s border, which may be accomplished with a slope or design rather than a single color (Schwarzkopf, 1991). I will conclude by mentioning that a sequence of text may be regarded as a form for the sake of sketching it. The contour of the letters defines the shape’s perimeter. Text is created by filling up this shape. In certain graphics programs, it is also feasible to outline the text-defining form with a stroke. In the picture below, the word “Graphics” is covered with a design on top as well as a slope and solid black on the bottom (Figure 2.10) (Podolak et al., 2006).

Figure 2.10. “Graphics” filled with a design on above as well as covered with a slope and brushed with solid black on the bottom. Source: https://design.tutsplus.com/tutorials/how-to-create-a-printable-birthday-card-template-in-photoshop--cms-35730.

2.4. TRANSFORMS We spoke about reference frames as well as how values may be transformed from one method to the other. We will take a deeper look at that concept in this part, as well as how geometrical transforms may be utilized to put graphical objects in a reference frame (Strzodka and Telea, 2004).

2.4.1. Viewing and Modeling In a typical system, a picture will be seen in rectangles comprised of pixels with their native pixel position. The view is the name given to this rectangle. We have a collection of geometric figures that are specified in a dissimilar reference frame, usually one that employs real-number dimensions instead of decimals. The “scene” or “globe” that we wish to see is made up of such

Two-Dimensional Computer Graphics

53

objects, and the values that we are using to describe the scene are termed world parameters (Krikke, 2004). In 2D images, the globe is represented by a plane. It is impossible to depict the whole infinite plane in a single image. To show in the picture, we must choose a rectangle region in the plane. This rectangular region will be referred to as the screen, or sight window. The window is mapped to the viewport using a spatial transformation (Figure 2.11) (Muraki, 1993).

Figure 2.11. A coordinate transform is used to map the window to the viewport. Source: https://www.geeksforgeeks.org/window-to-viewport-transformationin-computer-graphics-with-implementation/.

The coordinate conversion is represented by T in this diagram. T is a function that transforms pixel values T(x,y) in the screen to reference frame (x,y) in a certain window. (I made the viewpoint as well as window distinct sizes to stress that they are not quite the similar thing, even though they display the similar things; in fact, they do not appear in the very same place, so comparing their dimensions is pointless.) As you could see in the case (Brown, 1979): (800*(x + 4)/8, 600*(3 – y)/6) T(x,y) Examine the rectangle in the window along corners at (–1,2) and (3,–1). Whenever this rectangle is presented in the viewer, it appears as a rectangle with T(–1,2) and T(–1,2) corners (3,–1). T(–1,2) = (300,100) as well as T(3,–1) = (300,100) in this case (700,400) (Meijster et al., 2002). We utilize position modifications inside this manner since it is simpler to pick a world reference frame that is appropriate for defining the image we wish to portray than dealing closely with window dimensions. Consider

54

Exploration of Computer Graphics

the following scenario: we wish to create a complicated object, there will be many replicas of that item in our scenario. Perhaps we are constructing an animation and want the item to be in various places in multiple glasses (Claypoole et al., 2003). We would like to pick a handy reference frame and utilize it to permanently describe the item. The coordinates we utilize to describe an item are referred to as object coordinates. Whenever we wish to put an item in a scenario, we must convert the object coordinates we were using to describe it into the reference frame we are using for the incident. The change we need is known as a modeling transformation (Figure 2.12) (Daubechies and Sweldens, 2000):

Figure 2.12. Image depicts an item that is created in its object reference frame and then transferred into the reference frame using three separate modeling transforms. Source: https://math.hws.edu/graphicsbook/c2/s3.html.

Recall that there would be another transition that translates the item from a screen in coordinates for the viewer to observe the picture (Amira and Farrell, 2005). Take note that the viewpoint frame you choose determines whether a portion of the area is visible in the photograph. The background may be changed by rotating, scaling, or even turning the window. Assume we create many photos of the same vehicle (Figure 2.13) (Muraki, 1992).

Two-Dimensional Computer Graphics

55

Figure 2.13. A picture is manipulated by moving, cropping, and spinning it. Source: https://pubs.acs.org/doi/10.1021/acs.inorgchem.1c02471.

What occurred here between the creation of the top picture in this graphic and the bottom left picture? There are two options: The automobile was relocated to the right, or the show’s viewing window was changed to the left. This is crucial, so make sure you comprehend it. (Experiment with the phone’s camera.) Point it at a few things, then take a step to the left to see what occurs to the items in the field of view: they shift to the right in the image!) Likewise, what occurs here between the top image and the lower image’s middle image (Hanrahan, 1990)? Either the automobile moved clockwise or the windows turned anticlockwise. (Try this with a phone again—you may need to capture two genuine photographs to contrast.) Lastly, the shift from the top image to the bottom image on the right might be due to the automobile being shorter or the window becoming bigger (A wider window on your lens suggests you could see a greater field of view, which you do by using zoom or pulling up away from the items you are looking at) (Sramek and Kaufman, 2000). There seems to be an essential overarching concept here. Whenever we alter the view screen, we are also changing the viewport’s reference frame. In reality, this is similar to letting the reference system set up rather than shifting the scene’s objects. Although to achieve the same impact in the final picture, the objects must be transformed in the other direction (for instance, turning the window to the left is equal to moving the objects to

56

Exploration of Computer Graphics

the right) (DeLotto and Dotti, 1975). As a result, there is no significant difference between altering a window and changing an object. You describe a geometric primitive statistically by providing values in a natural reference frame, and the computer performs a set number of times on such values to generate, inside the final, the values that are utilized to display the primitive in the picture. A few of those changes will be referred to as modeling transformations, while others will be referred to as coordinate image is transformed, and to the computers, they are all the equivalent (Blinn, 1999). We will come back to these subject multiple times throughout the book, but geometric transformations are a key notion in computer graphics. Let us take a closer look at some of the most common transformations and 2D graphics, the transformations we will utilize may be stated in the form (Heckbert, 1995): a*x + b*y + e = x1 y1 = c*x + d*y + f y1 = c*x + d*y + f y1 = c* where; (x,y) denotes the values of a point prior to conversion; and (x1,y1) denotes the changed coordinates. The six integers a, b, c, d, e, and f determine the transformation. It is worth noting that this may be represented as a function T (Hou and Qin, 2012). (a*x + b*y + e, c*x + d*y + f) T(x,y) = (a*x + b*y + e, c*x + d*y + f) An affine transform is a conversion of such a type. Whenever two parallel lines are converted using an affine transform, the altered lines would also be similar. In addition, if one affine transform is followed by some other affine transform, the outcome is the other affine transform (Maurer et al., 2003).

2.4.2. Translation A translation transform just shifts each vector vertically and horizontally by a specific quantity. If the initial position is (x,y) as well as the converted point is (x1,y1), therefore the translation formula is x1 = x + e y1 = y + f. Their e reflects the number of horizontal steps the point is shifted as well as f determines the number it is shifted upward. (Therefore, a = d = 1 as well as b = c = 0 in the generic equation for a linear transformation for a translation.) Usually, a 2D graphics system contains a translate(e, f) function to perform a translate transformation. The interpretation will extend to anything drawn after the instruction. In other words, “e” will be placed on the x-coordinate as well as f will be put on the y-coordinate for all future painting actions. Consider an example (Kimmel et al., 1996).

Two-Dimensional Computer Graphics

57

Assume that you create an “F” utilizing values that centered the “F” at (0,0). If translate(4,2) is being used prior to drawing the letter “F,” each component of the letter would be shifted laterally by 4 units and upwards by 2 units even before real values are used, such that the letter would be fixed at (4,2) (Figure 2.14) (Cuntz and Kolb, 2007).

Figure 2.14. F is drawn by using coordinates. Source: https://www.chegg.com/homework-help/questions-and-answers/figure1-shows-flag-made-four-vertices-coordinates-given-local-coordinate-frame12-0-0-fig-q37354440.

In this image, the light gray “F” represents what would have been printed even without translating, whereas the dark red “F” represents the identical “F” drawn after performing a translation by 90° (4,2). The upper arrow indicates that now the upper left side of the letter “F” has indeed been shifted four units to the left as well as 2 units upwards. Each point on the letter “F” experiences a similar displacement. Notice that in my instances, the y-coordinate is assumed to rise from bottom to top. Therefore, the y-axis points upward (Ozparlak and Avcibas, 2011). Note that when you issue the translate(e,f) instruction, the translation pertains to everyone’s subsequent drawings, not the next form you create.

58

Exploration of Computer Graphics

If a secondary transformation is applied just after translation, it would not alter the transcription. This will be merged with the translation; thus, future artwork will be influenced by the integrated conversion. For instance, combining translate(4,2) and translate(–1,5) yields the very same effect as a simple translation, translate (3,7). This is an essential subject that will be discussed at length in the future (Yoo et al., 2019; Brandao et al., 2006). Note that you are not responsible for computing coordinate transformations. You just need to supply the object’s initial dimensions (that is, the object positions) and the transformation or transforms to be performed. It is the computer’s responsibility to perform the conversion to the parameters. You do not need to grasp the transformation’s mathematics; you only need to comprehend just what accomplishes graphically (Papazov and Burschka, 2011).

2.5. HIERARCHICAL MODELING This study explores how very basic forms may be used to develop multiple sceneries. The hierarchical structure is crucial. In other words, a complicated item may be composed of smaller things, which could be composed even of simple things, etc., until it reaches basic geometric blocks that could be drawn straight. This method is known as hierarchical planning. The transformations covered in the preceding section will be shown to have a critical part in hierarchical modeling (Anandan et al., 1993). The hierarchical structure is fundamental to coping with change in several fields of computer science (and then in life), therefore it should go without saying that it contributes to computer graphics (Cagan et al., 1998).

2.5.1. Building Complex Objects A significant motive for adding a new reference frame was that it would be feasible to utilize the reference frame which is most appropriate to the environment that you wish to depict. We may apply this approach to specific items in a picture: When sketching an object, utilize the reference frame that would be most appropriate for the thing (Musse and Thalmann, 2001). Typically, we would like an object in its original values to be oriented at the source, (0,0), or at minimum to utilize the beginning as a quick reference position. Next, to put it in the image, we may apply a scaling transform, then a spin, translate to establish its scale, direction, and location in the picture. Remember that changes performed in this manner are termed modeling

Two-Dimensional Computer Graphics

59

transformations. The transformations are frequently done in the order size, then spin, then translation, since scale and rotations keep the reference point, (0,0), fixed (Hitchner and Sowizral, 2000; Wang et al., 2010). Once the item has been resized and turned, is straightforward to utilize a translation to shift the point of reference to any desired position in the scene. (Of fact, in a specific scenario, you may not require all three processes.) Note that in the script, the transforms are stated in a reverse manner from the sequence in which they are performed to the item and that the transforms are supplied prior displaying the object. So, in the script, the translation would occur first, followed by the spin and finally the scaling. Modeling transformations are not necessarily combined in this manner, although it is the most usual use (Kilgour, 1981). The modeling modifications that are being used to position an item in the scene must not influence other objects in an image. To restrict their use to just the single object, we could save the current transformation while work commences on the item as well as recover it later. How this is done changes from one visual API to another, but let us imagine here that there exist subroutines saveTransform() and restoreTransform() for doing those duties. In other words, save transform will create a duplicate of the currently active modeling transformation and save it. It just stores a duplicate of the current transformation without altering it. Later, when restoreTransform is called, this copy is recovered and the current modeling transform is replaced with the retrieved transform. The typical type of code for rendering an object is then (Weiss and De Floriani, 2011): saveTransform() translate(dx,dy)//move object into position rotate(r)//set the orientation of the object scale(sx,sy)//set the size of the object . .//draw the object, using its natural coordinates restoreTransform() We do not even understand what the saved transformation performs, and we do not have to understand. Maybe it is only such identity transformation, that does not change the positions of the objects with which it is performed. Other transforms, including a coordinate transform that impacts the entire image, may well be in place (Fekete, 2004). The object’s modeling transformation is performed in combination with other transforms that were

60

Exploration of Computer Graphics

previously defined. The modeling transform repositions the item in the picture from its original position. However, on top of that, the item would be carried along by a coordinate transform performed to the entire screen (Dayan, 1998). Let us take this concept a step further. Assume that the item we wish to depict is a complicated entity comprised of many smaller elements. Consider a potted flower, which consists of a container, stem, petals, and bloom. We would want to be capable to depict the smaller constituent objects in their very own appropriate reference frames, similarly to how we display the primary objective (Al-Mouslli, 1995). For instance, we would want to describe the bloom in a reference frame where the bloom’s center is at (0,0). But it is simple: Each minor element object, including the bloom, is drawn in its coordinate system, and the sub-object is moved into place inside the main object using a modeling transformation. As if it were a whole scene, we are building the complicated item in its natural coordinate system (Cunningham and Bailey, 2001). On top of that, we may perform further modeling transform to the complicated system at all to transport it into the captured image; the complicated object’s sub-objects are also brought along. That is, for a sub-object, the entire transformation contains a modeling transformation that inserts the sub-object into the complicated system, coupled with a transformation that inserts the complex object into the scene. In reality, we may construct items that are built up of smaller objects, and so on, to any depth. We could, for instance, create the petals of the bloom in their coordinate systems, then use modeling transformations to move the petals into the flower’s natural coordinate system. Another change will put the bloom on the stem, followed by still another transformation that will place the complete potted flower into the scene. Hierarchical modeling is what it is called (Matos et al., 2015). Let’s have a look at another example where we would like to create a basic 2D graphic of a two-wheeled cart (Dixit & Verkhivker, 2009). In the image beneath, this cart is one component of a larger scenario. A couple of rectangles may be used to represent the cart’s body. Let’s assume we’ve built a draw function for the wheels. drawWheel() (Concepcion & Zeigler, 1988. This generates a wheel. This function creates a natural reference frame for the wheel. The wheel is located at (0,0) and seems to have a radius of 1 in this reference frame. I discovered it easiest to utilize the middle of the

Two-Dimensional Computer Graphics

61

huge rectangle’s base as a point of reference in the basic reference frame. I am assuming that the y-axis is positive and points upward, as is standard in mathematics (Hanisch and Straβer, 2003). Because the rectangular body of the cart has a width of 6 and a height of 2, the bottom left corner’s coordinates are (–3,0), and we may draw it using a command like fill rectangle (–3,0,6,2). The cart’s top is a tiny red rectangle that may be created in the same manner. We have to put two wheels on the cart to make it perfect. The wheels must be sized for them to fit the cart. One wheel must always be moved to the left, while the other wheel should be moved to the right, to arrange them in the proper locations concerning the cart’s body. While I was coding this instance, I had to fiddle with the numbers to achieve the correct sizes as well as placements for the wheels, and I discovered that moving the back wheels a little improved their appearance (De Floriani and Falcidieno, 1988). We preserve the current transformation before painting every wheel as well as recover it afterward, using the standard hierarchical modeling approaches. This limits the impact of the modeling transforms for the wheel to that wheel only, ensuring that no other parts of the cart are affected. Here is some pseudocode for a subroutine that creates its coordinate system for the cart (Miller and Fishwick, 1993): drawCart() is a subroutine that is used to draw a cart. saveTransform()/this function saves the current transformation. (–1.65,–0.1)/the first wheel’s center will be at (–1.65,–0.1) scale(0.8,0.8)/lower radius from 1 to 0.8 by scaling /draw the first wheel using drawWheel() restoreTransform() returns the previously stored transform. saveTransform();/ (1.5,–0.1)/the second wheel’s center will be at (1.5,–0.1) scale(0.8,0.8)/lower radius from 1 to 0.8 by scaling /draw the second wheel drawWheel(g2) restoreTransform() is a function that restores the transform. setDrawingColor(RED)/To draw the rectangles, use the red color. fillRectangle(–3, 0, 6, 2)/create the cart’s body /draw the top of the cart using fillRectangle(–2.3, 1, 2.6, 1) It is worth noting that both wheels are drawn using a similar subroutine. Separate modeling transformations are in operation for the two function

62

Exploration of Computer Graphics

calls, which is why two wheels show in the image in different places. We could use this cart-drawing function to insert a cart into a scenario once we have it. We perform another modeling transform to the entire cart when we do something like this. If we chose to, we could call the drawcard function many times with various modeling modifications to add multiple carts to the image (Ip et al., 2001). You should observe the analogy: Creating a complicated scene from objects is comparable to creating a complex program from subroutines. In both instances, it is possible to work on parts of the issue independently, construct a solution to a large problem from solutions to smaller problems, and reuse a solution in other situations (Pegden and Davis, 1992). The demo c2/cart-and-windmills.html features an animated scenario with a cart. You may assume that hierarchical modeling was utilized to depict these three windmills. There is parity. A windmill drawing approach that uses its coordinate system. Each windmill in the scene is created by applying a unique modeling transformation to the basic windmill. In addition, the windmill is itself a complicated object comprised of several sub-objects created via numerous modeling changes (Lubbers et al., 2018). It may not be obvious how various elements of the scene may be animated. In reality, the animation is a subset of modeling. Animation on a computer consists of a series of frames. Each frame is a distinct picture with minor differences between frames (Schroder, 1996). From our perspective, each frame is a distinct scenario that must be drawn independently. Similar objects might occur in several frames. Just put on a new modeling modification to the item in each frame to animate it. The transformation parameters may be calculated using either the current time or the frame number. To create a cart trip from left to right, for instance, a modeling transformation may be used (Hodges, 1998). translate(frameNumber * 0.1, 0) where; frameNumber is the frame number. The cart will move 0.1 units to the right in each successive frame. (In the real software, the translation applied to the shopping cart is: translate(–3 + 13*(frameNumber percent 300)/300.0, 0) Every 300 frames, the reference point of the cart is moved from–3 to 13 along the horizontal axis. In the scene’s coordinate system, the x-coordinate runs from 0 to 7, placing the cart outside the scene for most of the loop) (Kanaujia et al., 2007).

Two-Dimensional Computer Graphics

63

Hierarchical modeling is supported by this form of animation, which is quite cool. For instance, the drawWindmill technique does not just depict a windmill; it depicts an active windmill with rotating vanes. This simply indicates that the rotation given to the vanes is dependent on the number of frames. When a modeling transformation is done to a windmill, the whirling vanes are scaled and moved as a unit. This is an instance of hierarchical modeling. The blades are parts of the windmill. The spinning of the blades is a component of the modeling transformation that incorporates the blades into the windmill object. Then, an additional modeling transformation is given to the windmill object to position it inside the scene (Yang et al., 1997).

2.6. JAVA GRAPHICS2D The remainder of this chapter examines certain two-dimensional graphics solutions. There are a couple of new concepts here, but most of what you will see is how the broad principles we have discussed are applied to a variety of real-world graphics systems. The Java language is the topic of this part. Java continues to be among the most widely used programming languages. Its basic windows version features a powerful 2D graphics API, which is the subject of this article. You ought to be familiar with the fundamentals of Java language prior to evaluating the information. Although if you cannot understand, you ought to be up to speed with the majority of the explanation of the graphics API (Bederson et al., 2000). The graphics API presented here is a component of Swing, a graphical user interface programming API that is included in the java Application release. Several Java projects now use the JavaFX alternative API, which is not included in the regular release. That book does not cover JavaFX. Its visuals API is quite close to the HTML canvas graphics API (Deng et al., 2014). The graphics API in the first edition of Java was substantially smaller. It was very pixel-focused, and it exclusively utilized numeric coordinates. Modules for brushing as well as completing a range of basic forms, such as lines, rectangles, ovals, and polygons, were included in the API (although Java utilizes the name draw rather than stroke). On a pixel level, it specified the significance of drawing actions quite precisely. The lines across pixels are referred to as integer coordinates. A 12-by-8-pixel grid, for instance, has x-coordinates ranging between 0 to 12 as well as y-coordinates ranging from 0 to 8, as illustrated here (Figure 2.15) (Dévai and Rahman, 2002).

64

Exploration of Computer Graphics

Figure 2.15. The x-coordinates range from 0 to 12 and the y-coordinates range from 0 to 8. A 12-by-8-pixel grid includes x-coordinates ranging from 0 to 12 as well as y-coordinates ranging from 0 to 8. Source: https://web.stanford.edu/class/cs101/image-1-introduction.html.

The lines across pixels, not the pixels themselves, are labeled. The fillRect(3,2,5,3) command covers the rectangle with the top left edge at (3,2), a width of 5, and a height of 3, as seen on the left. The command drawRect(3,2,5,3) simulates dragging a “pen” across the rectangle’s outline. The pen, on the other hand, is a 1-pixel square with the top left edge moving all along the line. The images to the right of the rectangle’s right edge are colored as the pen advances all along the margin; the pixels underneath the edge are colored as the pen travels all along the bottom corner (Bellotti et al., 2001; Pich et al., 2008). The result is seen to the right. My purpose here is not to go into too much information, but to emphasize that providing a comprehensive definition of what graphical processes represent allows you to have extremely fine command about what occurs at the pixel level. Realnumber coordinates, transformations, antialiasing, and gradients were not supported in the initial Java graphics. A new graphics API was implemented several years since Java was initially launched, and it supports all of them. This article will focus on the more complex API (Hooi and Yoong, 2011).

2.6.1. Graphics2D Java is a programming language that focuses on objects. The initial graphics API’s API was described as a large number of classes, with the real drawing activities mainly stored in the character named Graphical fidelity. Drawing activities are now techniques in a class called Graphics2D, which is a

Two-Dimensional Computer Graphics

65

subcategory of Graphics, in the better new Swing API, because all the initial drawing processes will still be accessible. (In Java, a class is enclosed within a “package,” which is a bunch of classifications.) Graphics and Graphics2D, for instance, are found in java. awt package. The package java. awt.geom contains categories that describe patterns as well as converts) (Denault and Kienzle, 2007). A graphics system requires a drawing surface. The schematic surface in Java is typically a JPanel object, that also symbolizes a rectangle on the display. To create its material, the JPanel category has a technique called paintComponent(). You can make a schematic surface by subclassing JPanel and giving its paintComponent() technique a definition. All drawing must be performed within paintComponent(); if the elements of the painting need to be changed, use the panel’s repaint() function to call paintComponent() () (ANTAL, 2021). Although the paintComponent() function has a Graphics argument, the value that is supplied to it is an entity of class Graphics2D, which may be type-cast toGraphics2D to have accessibility towards the more complex graphics features. As a result, the paintComponent() function is often defined as follows (Fill, 2009): void paint that has been shielded Graphics g) Component(Graphics Component(Graphics

g)

Component(Graphics

g)

g2 Graphics2D; /Type-cast the argument to Graphics2D using g2 = (Graphics2D)g. ./Create a drawing using g2. . } I will suppose that g2 is a Graphics2D variable for the following part, and I will go through a few of the tasks you could do with it. For starters, I would want to point out that Graphics2D supports antialiasing, although it is not automatically updated. It may be activated with the fairly frightening command g2 in a graphics environment. setRenderingHint(RenderingHints.KEY ANTIALIASING, g2.setRenderin gHint(RenderingHints.KEY ANTIALIASING, g2.setRenderingHint ANTIALIAS ON RenderingHints.VALUE);

66

Exploration of Computer Graphics

2.6.2. SHAPES Drawings created using the basic Graphics module use numeric locations with pixel measurements. This is fine while using the conventional reference frame, and not when using actual values, as the measuring unit in a coordinate would not be equivalent to pixels. We must be capable of describing forms with actual numbers. The Java module java.awt.geom gives help for actual coordinate-defined forms. In this module, for instance, the class Line2D provides lines whose ends are specified as sets of true values (Yew et al., 2011). Currently, Java supports two kinds of real numbers: double and float. The double kind may express a wider variety of integers than the float type, with a higher series of important numbers, and double is a much more popular type. In Java, doubles are more convenient to utilize. Nevertheless, float values are often accurate enough for graphical uses, and they need less memory. Fundamentally, computer graphics equipment often employs float values (Juneau et al., 2012).

Two-Dimensional Computer Graphics

67

REFERENCES Akeley, K., (1993). Reality engine graphics. In: Proceedings of the 20th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 109–116). 2. Al-Mouslli, N., (1995). Design and Implementation of a ThreeDimensional Graphics System an Interactive Hierarchical Modeling Approach (Vol. 1, pp. 10, 11). Doctoral dissertation, King Fahd University of Petroleum and Minerals, Saudi Arabia. 3. Amira, A., & Farrell, P., (2005). An automatic face recognition system based on wavelet transforms. In: 2005 IEEE International Symposium on Circuits and Systems (Vol. 1, pp. 6252–6255). IEEE. 4. Anandan, P., Bergen, J. R., Hanna, K. J., & Hingorani, R., (1993). Hierarchical model-based motion estimation. In: Motion Analysis and Image Sequence Processing (Vol. 1, pp. 1–22). Springer, Boston, MA. 5. ANTAL, T. A., (2021). Using java affine transformation in a swing based 2D of planar robot simulation. Acta Technica Napocensis-Series: Applied Mathematics, Mechanics, and Engineering, 64(1), 2–8. 6. Bailey, M., & Glassner, A., (2004). Introduction to computer graphics. In: ACM SIGGRAPH 2004 Course Notes (Vol. 1, pp. 4-es). 7. Barnsley, M. F., Devaney, R. L., Mandelbrot, B. B., Peitgen, H. O., Saupe, D., Voss, R. F., & McGuire, M., (1988). The Science of Fractal Images (Vol. 1, p. 312). New York: Springer. 8. Bederson, B. B., Meyer, J., & Good, L., (2000). Jazz: An extensible zoomable user interface graphics toolkit in Java. In: Proceedings of the 13th Annual ACM Symposium on User Interface Software and Technology (Vol. 1, pp. 171–180). 9. Bellotti, F., Berta, R., De Gloria, A., & Poggi, A., (2001). DirectJ: Java APIs for optimized 2D graphics. Software: Practice and Experience, 31(3), 259–275. 10. Blinn, J. F., (1999). Inferring transforms [computer graphics]. IEEE Computer Graphics and Applications, 19(3), 93–98. 11. Brandao, B. C., Wainer, J., & Goldenstein, S. K., (2006). Subspace hierarchical particle filter. In: 2006 19th Brazilian Symposium on Computer Graphics and Image Processing (Vol. 1, pp. 194–204). IEEE. 1.

68

Exploration of Computer Graphics

12. Bresenham, J., (1996). Pixel-processing fundamentals. IEEE Computer Graphics and Applications, 16(1), 74–82. 13. Brown, K. Q., (1979). Geometric Transforms for Fast Geometric Algorithms (Vol. 1, pp. 1–8). Carnegie-Mellon Univ. Pittsburgh Pa Dept of computer science. 14. Burt, D. M., & Perrett, D. I., (1995). Perception of age in adult Caucasian male faces: Computer graphic manipulation of shape and color information. Proceedings of the Royal Society of London. Series B: Biological Sciences, 259(1355), 137–143. 15. Cagan, J., Degentesh, D., & Yin, S., (1998). A simulated annealing-based algorithm using hierarchical models for general three-dimensional component layout. Computer-Aided Design, 30(10), 781–790. 16. Carr, N. A., & Hart, J. C., (2002). Meshed atlases for real-time procedural solid texturing. ACM Transactions on Graphics (TOG), 21(2), 106–131. 17. Chazelle, B., (1985). Approximation and decomposition of shapes. Algorithmic and Geometric Aspects of Robotics, 1, 145–185. 18. Chen, S. E., & Williams, L., (1993). View interpolation for image synthesis. In: Proceedings of the 20th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 279–288). 19. Claypoole, R. L., Davis, G. M., Sweldens, W., & Baraniuk, R. G., (2003). Nonlinear wavelet transforms for image coding via lifting. IEEE Transactions on Image Processing, 12(12), 1449–1459. 20. Concepcion, A. I., & Zeigler, B. P., (1988). DEVS formalism: A framework for hierarchical model development. IEEE Transactions on Software Engineering, 14(2), 228–241. 21. Cunningham, S., & Bailey, M. J., (2001). Lessons from scene graphs: Using scene graphs to teach hierarchical modeling. Computers & Graphics, 25(4), 703–711. 22. Cuntz, N., & Kolb, A., (2007). Fast Hierarchical 3D Distance Transforms on the GPU (Vol. 1, pp. 93–96). In Eurographics (Short Papers). 23. Daubechies, I., & Sweldens, W., (2000). Factoring wavelet transforms into lifting steps. Wavelets in the Geosciences, 131–157. 24. Dayan, P., (1998). A hierarchical model of binocular rivalry. Neural Computation, 10(5), 1119–1135.

Two-Dimensional Computer Graphics

69

25. De Floriani, L., & Falcidieno, B., (1988). A hierarchical boundary model for solid object representation. ACM Transactions on Graphics (TOG), 7(1), 42–60. 26. DeLotto, I., & Dotti, D., (1975). Two-dimensional transforms by minicomputers without matrix transposing. Comput. Graphics Image Process (Vol. 4, pp. 11–16). The United States. 27. Denault, A., & Kienzle, J., (2007). Avoid Common Pitfalls When Programming 2D Graphics in Java: Lessons Learnt from Implementing the Minueto Toolkit (Vol. 13, No. 3, pp. 7.). XRDS: Crossroads, The ACM Magazine for Students. 28. Deng, C., Li, H., & Shao, Y., (2014). Research on the drawing method of energy Sankey diagram based on java. In: 16th International Conference on Advanced Communication Technology (Vol. 1, pp. 88– 91). IEEE. 29. Dévai, F., & Rahman, M., (2002). The suitability of the java language for computer graphics and visualization research. In: Proceedings Sixth International Conference on Information Visualization (Vol. 1, pp. 273–278). IEEE. 30. Dixit, A., & Verkhivker, G. M., (2009). Hierarchical modeling of activation mechanisms in the ABL and EGFR kinase domains: Thermodynamic and mechanistic catalysts of kinase activation by cancer mutations. PLoS Computational Biology, 5(8), e1000487. 31. Dony, R. D., & Wesolkowski, S., (1999). Edge detection on color images using RGB vector angles. In: Engineering Solutions for the Next Millennium. 1999 IEEE Canadian Conference on Electrical and Computer Engineering (Cat. No. 99TH8411) (Vol. 2, pp. 687–692). IEEE. 32. Engel, K., Kraus, M., & Ertl, T., (2001). High-quality pre-integrated volume rendering using hardware-accelerated pixel shading. In: Proceedings of the ACM SIGGRAPH/EUROGRAPHICS Workshop on Graphics Hardware (Vol. 1, pp. 9–16). 33. Ertl, T., (1996). Computer graphics—principles and practice. In: Data Acquisition and Analysis for Multimedia GIS (Vol. 1, pp. 411–421). Springer, Vienna. 34. Fekete, J. D., (2004). The infoVis toolkit. In: IEEE Symposium on Information Visualization (Vol. 1, pp. 167–174). IEEE.

70

Exploration of Computer Graphics

35. Fill, H. G., (2009). Prototypical implementation. In: Visualization for Semantic Information Systems (Vol. 1, pp. 291–298). Gabler. 36. Foley, J. D., Van, F. D., Van, D. A., Feiner, S. K., Hughes, J. F., & Hughes, J., (1996). Computer Graphics: Principles and Practice (Vol. 12110, pp. 1–7). Addison-Wesley Professional. 37. Franklin, W. M., & Barr, A. H., (1981). Faster calculation of super quadric shapes. IEEE Computer Graphics and Applications, 1(3), 41– 47. 38. Frisken, S. F., Perry, R. N., Rockwood, A. P., & Jones, T. R., (2000). Adaptively sampled distance fields: A general representation of shape for computer graphics. In: Proceedings of the 27th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 249– 254). 39. Garces, E., Munoz, A., Lopez‐Moreno, J., & Gutierrez, D., (2012). Intrinsic images by clustering. In: Computer Graphics Forum (Vol. 31, No. 4, pp. 1415–1424). Oxford, UK: Blackwell Publishing Ltd. 40. Goel, N. S., Rozehnal, I., & Thompson, R. L., (1991). A computer graphics-based model for scattering from objects of arbitrary shapes in the optical region. Remote Sensing of Environment, 36(2), 73–104. 41. Govindaraju, N. K., Lloyd, B., Dotsenko, Y., Smith, B., & Manferdelli, J., (2008). High performance discrete Fourier transforms on graphics processors. In: SC’08: Proceedings of the 2008 ACM/IEEE Conference on Supercomputing (Vol. 1, pp. 1–12). IEEE. 42. Hanisch, F., & Straβer, W., (2003). Adaptability and interoperability in the field of highly interactive web-based courseware. Computers & Graphics, 27(4), 647–655. 43. Hanrahan, P., & Haeberli, P., (1990). Direct WYSIWYG painting and texturing on 3D shapes: (An error occurred during the printing of this article that reversed the print order of pages 118 and 119. While we have corrected the sort order of the 2 pages in the DL, the PDF did not allow us to repaginate the 2 pages.). ACM SIGGRAPH Computer Graphics, 24(4), 215–223. 44. Hanrahan, P., (1990). Three-pass affine transforms for volume rendering. In: Proceedings of the 1990 workshop on Volume Visualization (Vol. 1, pp. 71–78). 45. Hart, J. C., (2001). Perlin noise pixel shaders. In: Proceedings of the ACM SIGGRAPH/EUROGRAPHICS Workshop on Graphics Hardware (Vol. 1, pp. 87–94).

Two-Dimensional Computer Graphics

71

46. Heckbert, P., (1982). Color image quantization for frame buffer display. ACM SIGGRAPH Computer Graphics, 16(3), 297–307. 47. Heckbert, P., (1995). Fourier transforms and the fast Fourier transform (FFT) algorithm. Computer Graphics, 2, 15–463. 48. Heidrich, W., Westermann, R., Seidel, H. P., & Ertl, T., (1999). Applications of pixel textures in visualization and realistic image synthesis. In: Proceedings of the 1999 Symposium on Interactive 3D Graphics (Vol. 1, pp. 127–134). 49. Hitchner, L. E., & Sowizral, H. A., (2000). Adapting computer graphics curricula to changes in graphics. Computers & Graphics, 24(2), 283– 288. 50. Hodges, J. S., (1998). Some algebra and geometry for hierarchical models, applied to diagnostics. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 60(3), 497–536. 51. Hooi, Y. K., & Yoong, L. S., (2011). Technique to correct displacement of vector drawings on scaled underlying raster image. In: 2011 IEEE Symposium on Computers & Informatics (Vol. 1, pp. 102–107). IEEE. 52. Hou, T., & Qin, H., (2012). Continuous and discrete Mexican hat wavelet transforms on manifolds. Graphical Models, 74(4), 221–232. 53. Ip, H. H., Lam, M. S., Law, K. C., & Chan, S. C., (2001). Animation of hand motion from target posture images using an anatomy-based hierarchical model. Computers & Graphics, 25(1), 121–133. 54. Johnson, M., (1996). A comparative study of terms used in art education and computer graphics to describe the visual properties of images. Studies in Art Education, 184–192. 55. Juneau, J., Dea, C., Guime, F., & O’Conner, J., (2012). Java 2D graphics. In: Java 7 Recipes (Vol. 1, pp. 321–395). Apress. 56. Kanaujia, A., Sminchisescu, C., & Metaxas, D., (2007). Semisupervised hierarchical models for 3d human pose reconstruction. In: 2007 IEEE Conference on Computer Vision and Pattern Recognition (Vol. 1, pp. 1–8). IEEE. 57. Kilgour, A. C., (1981). A hierarchical model of a graphics system. ACM SIGGRAPH Computer Graphics, 15(1), 35–47. 58. Kimmel, R., Kiryati, N., & Bruckstein, A. M., (1996). Sub-pixel distance maps and weighted distance transforms. Journal of Mathematical Imaging and Vision, 6(2), 223–233.

72

Exploration of Computer Graphics

59. Krikke, J., (2004). Streaming video transforms the media industry. IEEE Computer Graphics and Applications, 24(4), 6–12. 60. Kung, L. E., Soedel, W., Yang, T. Y., & Charek, L. T., (1985). Natural frequencies and mode shapes of an automotive tire with interpretation and classification using 3-D computer graphics. Journal of Sound and Vibration, 102(3), 329–346. 61. Ledley, R. S., Buas, M., & Golab, T. J., (1990). Fundamentals of truecolor image processing. In: Proceedings: 10th International Conference on Pattern Recognition (Vol. 1, pp. 791–795). IEEE. 62. Li, Y., Su, H., Qi, C. R., Fish, N., Cohen-Or, D., & Guibas, L. J., (2015). Joint embeddings of shapes and images via CNN image purification. ACM transactions on Graphics (TOG), 34(6), 1–12. 63. Liu, S., Sun, H., & Zhang, X., (2012). Selective color transferring via ellipsoid color mixture map. Journal of Visual Communication and Image Representation, 23(1), 173–181. 64. Liu, Y., Hel-Or, H., Kaplan, C. S., & Van, G. L., (2010). Computational symmetry in computer vision and computer graphics. Foundations and Trends® in Computer Graphics and Vision, 5(1, 2), 1–195. 65. Lubbers, N., Smith, J. S., & Barros, K., (2018). Hierarchical modeling of molecular energies using a deep neural network. The Journal of chemical physics, 148(24), 241715. 66. Magnenat, S., Ngo, D. T., Zünd, F., Ryffel, M., Noris, G., Rothlin, G., & Sumner, R. W., (2015). Live texturing of augmented reality characters from colored drawings. IEEE Transactions on Visualization and Computer Graphics, 21(11), 1201–1210. 67. Majumder, A., & Stevens, R., (2004). Color nonuniformity in projection-based displays: Analysis and solutions. IEEE Transactions on Visualization and Computer Graphics, 10(2), 177–188. 68. Matos, R., Araujo, J., Oliveira, D., Maciel, P., & Trivedi, K., (2015). Sensitivity analysis of a hierarchical model of mobile cloud computing. Simulation Modeling Practice and Theory, 50, 151–164. 69. Maurer, C. R., Qi, R., & Raghavan, V., (2003). A linear time algorithm for computing exact Euclidean distance transforms of binary images in arbitrary dimensions. IEEE Transactions on Pattern Analysis and Machine Intelligence, 25(2), 265–270.

Two-Dimensional Computer Graphics

73

70. McDonnell, K. T., & Mueller, K., (2008). Illustrative parallel coordinates. In: Computer Graphics Forum (Vol. 27, No. 3, pp. 1031– 1038). Oxford, UK: Blackwell Publishing Ltd. 71. Meijster, A., Roerdink, J. B., & Hesselink, W. H., (2002). A general algorithm for computing distance transforms in linear time. In: Mathematical Morphology and its Applications to Image and Signal Processing (Vol. 1, pp. 331–340). Springer, Boston, MA. 72. Miller, V. T., & Fishwick, P. A., (1993). Graphic modeling using heterogeneous hierarchical models. In: Proceedings of 1993 Winter Simulation Conference-(WSC’93) (Vol. 1, pp. 612–617). IEEE. 73. Mohring, M., Lessig, C., & Bimber, O., (2004). Video see-through AR on consumer cell phones. In: Third IEEE and ACM International Symposium on Mixed and Augmented Reality (Vol. 1, pp. 252–253). IEEE. 74. Muraki, S., (1992). Approximation and rendering of volume data using wavelet transforms. In: Proceedings Visualization’92 (Vol. 1, pp. 21– 22). IEEE Computer Society. 75. Muraki, S., (1993). Volume data and wavelet transforms. IEEE Computer Graphics and Applications, 13(04), 50–56. 76. Musse, S. R., & Thalmann, D., (2001). Hierarchical model for real time simulation of virtual human crowds. IEEE Transactions on Visualization and Computer Graphics, 7(2), 152–164. 77. Nguyen-Phuoc, T. H., Li, C., Balaban, S., & Yang, Y., (2018). RenderNet: A deep convolutional network for differentiable rendering from 3D shapes. Advances in Neural Information Processing Systems, 31(1), 12–16. 78. Omer, I., & Werman, M., (2004). Color lines: Image specific color representation. In: Proceedings of the 2004 IEEE Computer Society Conference on Computer Vision and Pattern Recognition, (Vol. 2, pp. II). IEEE. 79. Owada, S., Nielsen, F., Nakazawa, K., & Igarashi, T., (2003). A sketching interface for modeling the internal structures of 3D shapes. In: International Symposium on Smart Graphics (Vol. 1, pp. 49–57). Springer, Berlin, Heidelberg. 80. Ozparlak, L., & Avcibas, I., (2011). Differentiating between images using wavelet-based transforms: A comparative study. IEEE Transactions on Information Forensics and Security, 6(4), 1418–1431.

74

Exploration of Computer Graphics

81. Papazov, C., & Burschka, D., (2011). Deformable 3D shape registration based on local similarity transforms. In: Computer Graphics Forum (Vol. 30, No. 5, pp. 1493–1502). Oxford, UK: Blackwell Publishing Ltd. 82. Patil, S., & Ravi, B., (2005). Voxel-based representation, display and thickness analysis of intricate shapes. In: Ninth International Conference on Computer-Aided Design and Computer Graphics (CAD-CG’05) (Vol. 1, pp. 6-pp). IEEE. 83. Pegden, C. D., & Davis, D. A., (1992). Arena: A SIMAN/Cinema-based hierarchical modeling system. In: Proceedings of the 24th conference on Winter Simulation (Vol. 1, pp. 390–399). 84. Pich, C., Nachmanson, L., & Robertson, G. G., (2008). Visual analysis of importance and grouping in software dependency graphs. In: Proceedings of the 4th ACM Symposium on SOFTWARE Visualization (Vol. 1, pp. 29–32). 85. Poco, J., Mayhua, A., & Heer, J., (2017). Extracting and retargeting color mappings from bitmap images of visualizations. IEEE Transactions on Visualization and Computer Graphics, 24(1), 637–646. 86. Podolak, J., Shilane, P., Golovinskiy, A., Rusinkiewicz, S., & Funkhouser, T., (2006). A planar-reflective symmetry transform for 3D shapes. In: ACM SIGGRAPH 2006 Papers (Vol. 1, pp. 549–559). 87. Pulli, K., Abi-Rached, H., Duchamp, T., Shapiro, L. G., & Stuetzle, W., (1998). Acquisition and visualization of colored 3D objects. In: Proceedings. Fourteenth International Conference on Pattern Recognition (Cat. No. 98EX170) (Vol. 1, pp. 11–15). IEEE. 88. Reichenbach, S. E., Ni, M., Kottapalli, V., & Visvanathan, A., (2004). Information technologies for comprehensive two-dimensional gas chromatography. Chemometrics and Intelligent Laboratory Systems, 71(2), 107–120. 89. Rowland, D. A., & Perrett, D. I., (1995). Manipulating facial appearance through shape and color. IEEE Computer Graphics and Applications, 15(5), 70–76. 90. Saito, S., Huang, Z., Natsume, R., Morishima, S., Kanazawa, A., & Li, H., (2019). Pifu: Pixel-aligned implicit function for high-resolution clothed human digitization. In: Proceedings of the IEEE/CVF International Conference on Computer Vision (Vol. 1, pp. 2304–2314).

Two-Dimensional Computer Graphics

75

91. Saito, T., & Takahashi, T., (1990). Comprehensible rendering of 3-D shapes. In: Proceedings of the 17th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 197–206). 92. Sajadi, B., Lazarov, M., Gopi, M., & Majumder, A., (2009). Color seamlessness in multi-projector displays using constrained gamut morphing. IEEE Transactions on Visualization and Computer Graphics, 15(6), 1317–1326. 93. Schroder, P., (1996). Wavelets in computer graphics. Proceedings of the IEEE, 84(4), 615–625. 94. Schwarzkopf, O., (1991). Parallel computation of disease transforms. Algorithmica, 6(1), 685–697. 95. Segal, M., Korobkin, C., Van, W. R., Foran, J., & Haeberli, P., (1992). Fast shadows and lighting effects using texture mapping. In: Proceedings of the 19th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 249–252). 96. Sharf, A., Lewiner, T., Shamir, A., & Kobbelt, L., (2007). On‐the‐fly curve‐skeleton computation for 3D shapes. In: Computer Graphics Forum (Vol. 26, No. 3, pp. 323–328). Oxford, UK: Blackwell Publishing Ltd. 97. Sims, K., (1991). Artificial evolution for computer graphics. In: Proceedings of the 18th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 319–328). 98. Sramek, M., & Kaufman, A., (2000). Fast ray-tracing of rectilinear volume data using distance transforms. IEEE Transactions on Visualization and Computer Graphics, 6(3), 236–252. 99. Strzodka, R., & Telea, A., (2004). Generalized distance transforms and skeletons in graphics hardware. In: Proceedings of the Sixth Joint Eurographics-IEEE TCVG Conference on Visualization (pp. 221–230). 100. Sutton, M. A., McNeill, S. R., Helm, J. D., & Chao, Y. J., (2000). Advances in two-dimensional and three-dimensional computer vision. In: Photomechanics (Vol. 1, pp. 323–372). Springer, Berlin, Heidelberg. 101. Teichmann, M., & Capps, M., (1998). Surface reconstruction with anisotropic density-scaled alpha shapes. In: Proceedings Visualization’98 (Cat. No. 98CB36276) (Vol. 1, pp. 67–72). IEEE. 102. Van, D. D. K., & Pai, D. K., (1998). The sounds of physical shapes. Presence, 7(4), 382–395.

76

Exploration of Computer Graphics

103. Wallach, D. S., Kunapalli, S., & Cohen, M. F., (1994). Accelerated MPEG compression of dynamic polygonal scenes. In: Proceedings of the 21st Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 193–196). 104. Wang, J., Wang, W., Wang, Y., Qi, W., & Gao, X., (2010). A study on SCADA graphics elements library based on SVG and batik. In: 2010 Asia-Pacific Power and Energy Engineering Conference (Vol. 1, pp. 1–3). IEEE. 105. Weiss, K., & De Floriani, L., (2011). Simplex and diamond hierarchies: Models and applications. In: Computer Graphics Forum (Vol. 30, No. 8, pp. 2127–2155). Oxford, UK: Blackwell Publishing Ltd. 106. Xalilova, H. E., & Rixsiboev, U. T., (2021). The role of computer graphics in working with colors in Design. International Journal on Orange Technologies, 3(3), 83–87. 107. Yang, C. W., Chung, P. C., Chang, C. I., Lee, S. K., & Kung, L. Y., (1997). A hierarchical model for PACS. Computerized Medical Imaging and Graphics, 21(1), 29–37. 108. Yew, K. H., Wan, A. W. F., & Leong, S. Y., (2011). Technique to rectify displaced vector graphics drawn over scalable raster drawing. Journal of Computing, 3(3), 2–8. 109. Yoo, J., Uh, Y., Chun, S., Kang, B., & Ha, J. W., (2019). Photorealistic style transfer via wavelet transforms. In: Proceedings of the IEEE/CVF International Conference on Computer Vision (Vol. 1, pp. 9036–9045).

CHAPTER

3

TWO-DIMENSIONAL GRAPHICS TEST BED

CONTENTS 3.1. Introduction....................................................................................... 78 3.2. Details of the Test Bed........................................................................ 80 3.3. Animation.......................................................................................... 84 3.4. Interaction......................................................................................... 86 3.5. Application of the Test Bed................................................................ 86 References................................................................................................ 90

78

Exploration of Computer Graphics

3.1. INTRODUCTION Here we demonstrate the specifics of the test bed, a framework for testing out concepts in graphics without a huge amount of overhead. By now, you are familiar with some aspects of WPF and have seen our planned test bed in action in building the Dürer renderer. There are two of them: one for 2D and the other for 3D. The two - dimensional test bed is introduced in this chapter; more detailed documentation and the three-dimensional test are available on the book’s website (Gerson & Wood Jr, 1996). These are called test beds because they resemble the test apparatus used by an electrical engineer: a collection of instruments, power supplies, and prototype boards on which various circuits can be assembled and tested. Our design aims are modest. We want a basic framework that makes writing and debugging simple programs. Simplicity is preferred over generality, and ease of debugging is favored over speed (Gooch, 1996).

Figure 3.1. Top: A polyline in the plane. Middle: Each segment has been divided into thirds, and the division points have been marked with dots. Bottom: The middle thirds of the segments are connected together to form a new, smoother polyline. Source: https://slideplayer.com/slide/14407760/.

Two-Dimensional Graphics Test Bed

79

We present exercises throughout this book, that require you to write small programs to investigate some subject that you’ve studied. For example, when we discuss mathematical modeling of shapes, we begin with polygons and show how to make curves shaped by them. This is demonstrated in Figure 3.1: You can conduct a corner-cutting operation on a closed polyline a connect-the-dots series of segments in a plane by dividing each segment into thirds, removing the first and last thirds of each segment, then joining the remaining segments in succession (Stevenson & Rosenman, 1992). If you continue this process, the resulting polyline becomes to get increasingly smooth, approximating a smooth curve. While mathematical analysis of this process is possible (and valuable), we believe that a picture is worth 1,000 words, and interaction is worth many thousands more. As a result, we provide you with the tools to answer a variety of questions you might have, such as whether curves will always get smoother, whether there are beginning polylines that result in curves with sharp corners regardless of the number of repetitions, and what happens if you keep the middle half of each section instead of the middle third, so you can get such a visceral understanding of the process. Simultaneously, writing programs to implement such concepts might help you comprehend subtleties (Durfee and Montgomery, 1989). If we choose to discuss corner-cutting for polylines instead of closed polylines, you’d have to determine what to do with the beginning and ending segments when you write the code; these boundary cases are a common source of both complication and understanding. We could have opted to explain how to draw individual points, then lines, detect mouse clicks, make menus and buttons, and link them to action in your program, which are all interesting and valuable topics (Verbeck and Greenberg, 1984). However, we would like you to be able to start learning graphics visually right away. To do so, we’ll have to give you some tools whose inner workings you won’t understand just yet. The remainder of that chapter presents our two-dimensional test bed, which is designed to provide easyto-modify programs in which you can experiment with different graphics ideas (Neff, 1994). We describe how to utilize the 2D software to accomplish corner-cutting in 2D and provide some exercises in which you can do some experiments that will prepare you for the ideas presented in the later chapters. The testbed program is designed to keep you from learning many of the details of a graphics program at that time. Setting the color values for individual pixels

80

Exploration of Computer Graphics

on the screen is a necessary part of all on-screen graphics (Delingette et al., 1994). For now, we are letting that hardware and software handle the heavy lifting so that we would work at a higher abstract level: we’ll assume that we’ll be able to create higher-level images and shapes and that Direct 3D and WPF will handle creating the pixels look the way we implied they should (Johnson et al., 2000).

3.2. DETAILS OF THE TEST BED As we said, our program is based on WPF, a subject that has devoted thousands of web pages and entire books. It’s always easier to modify an existing program than to start from scratch, in our experience. As a result, we created the two-dimensional test bed and included a sample program that performs a series of things. The testbed is often created by copying this sample, deleting the majority of it, and then changing the remainder. A photographic image, a software-created image, a polygon, a mesh, and a quiver of arrows are all displayed in the sample (i.e., a collection of arrows specified by their base points and directions). It also features a slider and a few buttons (one of which adjusts which program image is displayed) (that can be used to move one vertex of a polygon). You should be able to generalize and add your interaction features to the program based on these examples (O’Brien et al., 1993). Note that this program is continually evolving, and we anticipate augmenting it as students suggest new features. Because we’ll note any changes to the program on the book’s website since these augmentations may produce small changes to the program. This chapter is an introduction to the test bed and its use, not complete documentation of the organizations included in the test bed (Ackerman, 1998).

3.2.1. Using the 2D Test Bed At this point in this chapter, you should pause and visits the book’s website to download the two-dimensional test bed as instructed. In addition, you need to set up a development environment in which you want to work. We used Visual Studio (2010) in a publicly distributed “basic version” in the examples in this book, as well as the Microsoft Windows SDK for browsing documentation and other tasks (Ayache and Faugeras, 1986). To get the twodimensional testbed up and running, follow the instructions on the page, and

Two-Dimensional Graphics Test Bed

81

then try out the sample program: See that’s what happens when you click a button or move a slider. Browse through the code to see if you could put together how it works. Then continue reading. We’ll assume you’re familiar with an integrated development environment (IDE) such as Visual Studio and a programming language such as C#, C++, or Java. (i.e.; The test bed is developed in C#, although C# is simple to use for anyone who knows C++ or Java) (Figure 3.2) (Beffa and Connell, 2001).

Figure 3.2. The Testbed2D application running. All the things in the large graph-paper window are drawn by the Window1.xaml.cs code and are not described in the XAML file. Source: https://slideplayer.com/slide/14407760/.

3.2.2. Corner Cutting Step-by-step, we construct the corner-cutting application. Download and run the Subdivide program from the book’s website to prepare for that exercise. When the application starts, click several times in the main window to create a polygon; then, to observe the corner-cutting procedure, click the Subdivide button, or the clean button to start over (Harris et al., 1989).

82

Exploration of Computer Graphics

Examine the code in Window1.xaml. The XAML code around these words creates the buttons you’re clicking, and Click=“b1Click” tells WPF that when one of those buttons is pressed, a function called b1Click should be invoked. We’ll see more detail about this later; here, we just want you to gain a broad picture of where the functional parts of this example lie (Williams et al., 2013). Start by looking at the code in Window1.xaml.cs. The initializations for the Window1 class produce a set of Polygon objects, which are initialized in Window1’s function Object() {[native code]} and then added to a variable named GP (for “graph paper”), which represents everything that will be drawn on the display. The polygon initialization code sets up specific properties for the polygons; many more properties may be set as well, but they are all left at their default values. Finally, the b1Click and b2click routines specify what must ensue when the user clicks the two buttons (Minhas and Ariyapperuma, 2005; Boyle et al., 1911). Take a quick look at these. The Clear button should appear reasonably; the Subdivided button is more complex, but you can see that it includes multiplying several coordinates by 2/3 and 1/3, as you’d anticipate (Hoomans et al., 1996). Those are the most important parts of the corner-cutting application. Almost everything is boilerplate code or code that makes writing apps like this easier. In actuality, we started with the test bed, which generates points, a mesh, arrows, lines, and numerous moving objects, then deleted the majority of them before altering the XAML to eliminate some unnecessary user-interface components and renaming a few others. We can now check out the rest of the test bed with this example in mind (Vetsch et al., 2020).

3.2.3. The Structure of a Test-Bed-Based Program The WPF applications are usually specified in two sections: one in C# and the other in XAML. The two pieces work together to form the whole. Indeed, one can have object classes that have this same two-part separation, as are object classes have written entirely in C#; our code contains both types (Bates et al., 2010). Testbed2DApp is the application’s highest-level component, which is implemented in the files Testbed2DApp.XAML.cs (the C# file) and Testbed2DApp.XAML (the XAML file) (Johnson et al., 2000). Exception of the Startup event handler, which we’ll see in the C# file, the XAML file declares that Testbed2D is an object of class Application, which

Two-Dimensional Graphics Test Bed

83

means it has certain properties, events, and methods predefined. We use almost none of these, except for the Startup event handler, which we’ll see in the C# file (Singh et al., 1983).

The xmlns lines in the code above simply declare applications and some information about where to find particular name resolutions for this XML namespace. From our perspective, the most important line is Startup=“AppStartingUp,” which says that the Startup event will be handled by code found in the Testbed2D.xaml.cs file’s AppStartingUp method. In a C++ or Java program, this is the equivalent of main (Masubuchi et al., 2020). The C# file that corresponds. Part of the class description is here, but part of it is elsewhere, as indicated by the keyword partial (in the XAML file). The AppStartingUp function is responsible for creating and displaying Window1. The AppStartingUp parameters aren’t used. The Testbed2DApp’s methods, remaining event handlers, and so on are all inherited from the Application class’s defaults (Jardin et al., 1987).

So, if we run the Testbed2DApp, a Window1 will be created and shown. This Window1 class has a little more functionality than the Testbed2DApp class: It is similar to the main window of a traditional application and includes features such as buttons, menu bar, and sliders, as well as huge

84

Exploration of Computer Graphics

drawing things. The Window1.xaml file determines how these items are arranged (Held, 1997): You’ll modify that file if you would like to add a button to the test bed; if you want to set up a link between a certain action and a slider drag in your software, you’ll edit that file, and so on. The content of the one enormous area in which we might draw items is nearly exclusively handled by Window1.xaml.cs file (Ten Cate et al., 1984). Now we’ll look at both of the Window1 files. We’ll omit huge segments of each, as well as sections that are boilerplate or repetitive, to focus on the details you’ll need when writing your programs (Kaul et al., 1994). A complicated XAML file, such as Window1.xaml (see Listing 4.3), can specify several things at once: layout (i.e., where objects go in the window), event handling (i.e., what happened when you hit a keyboard key or click a button), styles (i.e., the font in which text appears, the color of a button), and so on. We’ll focus on the layout for the time being. Start examining the code to see what’s going on, and we’ll go over some specifics afterward (Chou, 1989; Friedberg, 1986).

3.3. ANIMATION The WPF has animation-creating capabilities. You can animate almost any Point, value—a double, or anything else—and then utilize that changing value to update the display. Animations can be defined in either XAML or C# code. There are many predefined animations in XAML that may be combined to create quite complex motions. These predefined animations can be used in C# code, or you can develop your own using arbitrarily sophisticated programs. For example, you could develop software that calculates the position of a ball bouncing over time and then uses that variable position to control the location of a form (such as a disc) displayed on the screen. Because writing a simulation program in XAML is impractical, it’s more natural to develop one in C# (Brown and Najork, 1993). We just have one animation in our sample, but it highlights the main points. We created a segment in the code with one endpoint at a Dot named p1. We animate a point in this code by defining the starting and finishing positions, the duration of the animation (it begins at time 0, i.e., when the program is started and lasts five seconds), and whether it should auto-reverse and repeat forever. (By the way, this rather simple animation is an instance of something that can be represented easily in XAML) (Figure 3.3) (Xu et al., 2022).

Two-Dimensional Graphics Test Bed

85

Figure 3.3. When we thicken the vertex join at the top, we must miter it, as shown in the middle. At the bottom, the miter is limited. Source: https://slideplayer.com/slide/14407760/.

As a result, over time, a point moves back and forth between the two designated locations. This point isn’t displayed on the GraphPaper; it’s just a Point with a constantly changing value. However, the line p1. BeginAnimation(Dot.PositionProperty, animaPoint1) says that the position property of the Dot named p1 should be animated by animaPoint1, causing the Dot to move back and forth on the screen. WPF’s dependence mechanism is performing the heavy lifting once more: It detects every change in animaPoint1 and ensures that the position property of p1 is also modified; this property defines the location of the Dots on the canvas, allowing us to witness motion (Catmull, 1978). We’ve been able to easily assign values to the x- and y-coordinates of Points. These coordinates should be treated as hidden instance variables that can only be retrieved using accessor/mutator (or set/get) methods, according to object-oriented programming concepts. Instead of a Java object or standard C++, a Point looks like a C struct or a C struct. C# facilitates such applications by blurring the distinction between records (groups of linked values) and objects, which can improve efficiency while reducing debuggability (Mukhamedov, 2021).

86

Exploration of Computer Graphics

3.4. INTERACTION We’ve already discussed how the test bed (and WPF in general) handles button clicks and slider value changes: The method Click or ValueChanged is called. The way you interact with the keyboard is a small difference. When you press a key anywhere in the main window, it goes through two stages: Some of them are recognized as commands (for example, “Alt-X” for “Exit the program”); others are handled by a procedure called KeyDownHandler, which responds to all key presses either by ignoring them (for modifier keys like Shift or Control) displaying a small dialog box specifying which key was pressed (Yu et al., 2011). As your programs become more complicated, you may want to modify this section of the code to do particular things when these keys are pressed. Finally, the InitializeCommands method defines the actions executed when menu items are selected. There is already a specified way to handle many commands (such as Application. Close, which indicates that the apps should close a window) and a specified key press connected with the command (Cao and Cao, 2021). For these, simple things like CommandBindings can be written. CloseApp is a small procedure that opens up a popup to check that the user does want to close the program. Add(new CommandBinding(ApplicationCommands. Close, CloseApp)); Others will need to use significantly more complicated processes. We don’t anticipate you adding any new instructions, so it’s up to you whether you want to look into the mechanism (Gamito et al., 1995).

3.5. APPLICATION OF THE TEST BED Returning to the corner-cutting example at the start of the chapter, let’s look at it again. To create an application that demonstrates this, we’ll need to remove the majority of the code in Window1.cs and begin with a simple polygon drawn by the user. The interaction sequence will be described first, and then the code will be written (Vellaithurai et al., 2015). The GraphPaper is initially empty, with two buttons labeled “Clear” and “Subdivide.” A polygon P1 forms when the user clicks on the graph paper, with vertices at the clicked positions (i.e., after two clicks, the polygon consists of two identical line segments; after three, a triangle, etc.). When the user hits the Subdivide button, a subdivided version of the first polygon, P2, appears; additional Subdivide clicks replace P2 with a subdivided version of P2 and P1 with P2, and so on, ensuring that a polygon and its

Two-Dimensional Graphics Test Bed

87

subdivisions are always visible. The graph paper is cleared when you press the Clear button. We prohibit further clicks on the graph paper once the user has split the polygon; you would want such clicking to add new elements to the subdivided polygon, but it’s not apparent where the new points should be added in the subdivided polygon, so we simply avoid the issue (Cao et al., 2019). With that description in mind, let’s write the code. We’ll need an isSubdivided flag (initially false) to tell us whether the user has subdivided the polygon or not. This, as well as the graph paper, should be reset with the Clear button. Subdivide should also have no effect if there are no points in the polygon yet. We start with a copy of the test bed code and update the XAML to delete the slider and change the button text (Belli et al., 2015):

We’re now modifying the C# code in Window1.xaml.cs. To begin, both polygons are set to be empty:

The polygon initialization procedure also ensures that when two edges meet at a sharp angle, they are truncated, as shown at the bottom of Figure 3.3, rather than having the junction prolonged in a long miter, as shown in the middle (Voisin et al., 2010).

88

Exploration of Computer Graphics

It’s simple to handle by clicking on the Clear button: Delete all points from each polygon and set the is Subdivided flag back to false (Takahashi et al., 2001):

The Subdivide option is more complicated. To begin, we want to replace the points of myPolygon with that of the subdivided polygon if the polygon has already been subdivided. After that, we may split myPolygon and save the result in mySubdivPolygon. Subdivision amounts calculating the previous and next vertices for each vertex and then combining coordinates in a two-thirds-to-one-third ratio to locate the corner-cutting points. (You may recall from rudimentary geometry that averaged the coordinates of two locations to determine the coordinates of the middle point of the section between them) (Cintuglu et al., 2016).

Finally, we have to handle it with mouse clicks. We would like to add a new vertex to the polygon whenever the user presses the mouse button unless it’s already subdivided.

Two-Dimensional Graphics Test Bed

89

As a result, we check the subdivided flag and add the points to our Polygon if it is false (Donnelly, 1987).

That’s it! You can check the program’s functionality by running it. Your polygon looks like a line segment when you only click two points. Subdividing the line segment makes it appear shorter. Explain why subdividing it again does not make it any shorter (Zhang et al., 2013). A similar procedure can be employed to “cut corners” in a 3D polyhedron in an attempt to smooth it out. Is it always get smoother? Meanwhile, now that you’ve seen how quickly subdivision smooths down curves, you could wonder, “How could I analyze whether the curves approach a limit and whether such a limit is smooth at a specific point?” This is addressed (Chiba et al., 1994).

90

Exploration of Computer Graphics

REFERENCES Ackerman, M. J., (1998). The visible human project. Proceedings of the IEEE, 86(3), 504–511. 2. Ayache, N., & Faugeras, O. D., (1986). HYPER: A new approach for the recognition and positioning of two-dimensional objects. IEEE Transactions on Pattern Analysis and Machine Intelligence, (1), 44– 54. 3. Bates, P. D., Horritt, M. S., & Fewtrell, T. J., (2010). A simple inertial formulation of the shallow water equations for efficient twodimensional flood inundation modeling. Journal of Hydrology, 387(1, 2), 33–45. 4. Beffa, C., & Connell, R. J., (2001). Two-dimensional flood plain flow. I: Model description. Journal of Hydrologic Engineering, 6(5), 397– 405. 5. Belli, L., Cirani, S., Davoli, L., Gorrieri, A., Mancin, M., Picone, M., & Ferrari, G., (2015). Design and deployment of an IoT applicationoriented testbed. Computer, 48(9), 32–40. 6. Boyle, W. J., Van, D. G. P., & Hunter, T., (1991). Phosphopeptide mapping and phosphoamino acid analysis by two-dimensional separation on thin-layer cellulose plates. In: Methods in Enzymology (Vol. 201, pp. 110–149). Academic Press. 7. Brown, M. H., & Najork, M. A., (1993). Algorithm animation using 3d interactive graphics. In: Proceedings of the 6th Annual ACM Symposium on User Interface Software and Technology (Vol. 1, pp. 93–100). 8. Cao, R., & Cao, R., (2021). Computer simulation of water flow animation based on two-dimensional Navier-stokes equations. Advances in Mathematical Physics, 1, 2–8. 9. Cao, S. C., Jung, J., & Radonjic, M., (2019). Application of microfluidic pore models for flow, transport, and reaction in geological porous media: From a single test bed to multifunction real-time analysis tool. Microsystem Technologies, 25(11), 4035–4052. 10. Catmull, E., (1978). The problems of computer-assisted animation. ACM SIGGRAPH Computer Graphics, 12(3), 348–353. 11. Chiba, N., Muraoka, K., Takahashi, H., & Miura, M., (1994). Two‐ dimensional visual simulation of flames, smoke and the spread of fire. The Journal of Visualization and Computer Animation, 5(1), 37–53. 1.

Two-Dimensional Graphics Test Bed

91

12. Chou, P. A., (1989). Recognition of equations using a two-dimensional stochastic context-free grammar. In: Visual Communications and Image Processing IV (Vol. 1199, pp. 852–865). SPIE. 13. Cintuglu, M. H., Youssef, T., & Mohammed, O. A., (2016). Development and application of a real-time testbed for multiagent system interoperability: A case study on hierarchical microgrid control. IEEE Transactions on Smart Grid, 9(3), 1759–1768. 14. Delingette, H., Subsol, G., Cotin, S., & Pignon, J., (1994). Craniofacial surgery simulation testbed. In: Visualization in Biomedical Computing (Vol. 2359, pp. 607–618). SPIE. 15. Donnelly, R. A., (1987). Development of a Graphical Display on the DMS Test Bed (Vol. 1, pp. 2–9). NASA. Johnson Space Center, NASA (ASEE Summer Faculty Fellowship Program. 16. Durfee, E. H., & Montgomery, T. A., (1989). MICE: A flexible testbed for intelligent coordination experiments. In: Proceedings of the 1989 Distributed Artificial Intelligence Workshop (Vol. 1, pp. 25–40). 17. Friedberg, S. A., (1986). Finding axes of skewed symmetry. Computer Vision, Graphics, and Image Processing, 34(2), 138–155. 18. Gamito, M. N., Lopes, P. F., & Gomes, M. R., (1995). Two-dimensional simulation of gaseous phenomena using vortex particles. In: Computer Animation and Simulation’95 (Vol. 1, pp. 3–15). Springer, Vienna. 19. Gerson, D. J., & Wood, Jr. S. E., (1996). RADIUS phase II: The RADIUS test-bed system. In: 24th AIPR Workshop on Tools and Techniques for Modeling and Simulation (Vol. 2645, pp. 62–69). SPIE. 20. Gooch, R., (1996). Karma: A visualization test-bed. In: Astronomical Data Analysis Software and Systems V (Vol. 101, p. 80). 21. Harris, L. S., Symonds, B. A., Golish, L. M., & Johnson, R. L., (1989). Corps of Engineers National Automation Team (CENAT) Technology Transfer Test Bed (T(3)B) Demonstration of the Design 4D Program (Vol. 1, pp. 2–8). Construction Engineering Research Lab (ARMY) Champaign IL. 22. Held, M., (1997). Erit—a collection of efficient and reliable intersection tests. Journal of Graphics Tools, 2(4), 25–44. 23. Hoomans, B. P. B., Kuipers, J. A. M., Briels, W. J., & Van, S. W. P. M., (1996). Discrete particle simulation of bubble and slug formation in a two-dimensional gas-fluidized bed: A hard-sphere approach. Chemical Engineering Science, 51(1), 99–118.

92

Exploration of Computer Graphics

24. Jardin, F., Dubourg, O., Guéret, P., Delorme, G., & Bourdarias, J. P., (1987). Quantitative two-dimensional echocardiography in massive pulmonary embolism: Emphasis on ventricular interdependence and leftward septal displacement. Journal of the American College of Cardiology, 10(6), 1201–1206. 25. Johnson, B. E., Julien, P. Y., Molnar, D. K., & Watson, C. C., (2000). The two‐dimensional upland erosion model casc2d‐sed 1. JAWRA Journal of the American Water Resources Association, 36(1), 31–42. 26. Kaul, S., Stratienko, A. A., Pollock, S. G., Marieb, M. A., Keller, M. W., & Sabia, P. J., (1994). Value of two-dimensional echocardiography for determining the basis of hemodynamic compromise in critically ill patients: A prospective study. Journal of the American Society of Echocardiography, 7(6), 598–606. 27. Masubuchi, S., Watanabe, E., Seo, Y., Okazaki, S., Sasagawa, T., Watanabe, K., & Machida, T., (2020). Deep-learning-based image segmentation integrated with optical microscopy for automatically searching for two-dimensional materials. NPJ 2D Materials and Applications, 4(1), 1–9. 28. Minhas, A., & Ariyapperuma, S., (2005). Role of three dimensional (3D) modeling as a pedagogic tool for heritage and tourism studies. In: 2005 6th International Conference on Information Technology Based Higher Education and Training (Vol. 1, pp. S2C-7). IEEE. 29. Mukhamedov, U. S., (2021). Animation graphics in the presentation. International Journal of Human Computing Studies, 3(1), 127–130. 30. Neff, J. A., (1994). Optical interconnects based on two-dimensional VCSEL arrays. In: First International Workshop on Massively Parallel Processing Using Optical Interconnections (Vol. 1, pp. 202–212). IEEE. 31. O’Brien, J. S., Julien, P. Y., & Fullerton, W. T., (1993). Two-dimensional water flood and mudflow simulation. Journal of Hydraulic Engineering, 119(2), 244–261. 32. Singh, B., Beatty, J. C., & Ryman, R., (1983). A graphics editor for Benesh movement notation. In: Proceedings of the 10th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 51–62).

Two-Dimensional Graphics Test Bed

93

33. Stevenson, D. S., & Rosenman, J. G., (1992). VISTAnet gigabit testbed. IEEE Journal on Selected Areas in Communications, 10(9), 1413–1420. 34. Takahashi, T., Tadokoro, S., Ohta, M., & Ito, N., (2001). Agent based approach in disaster rescue simulation-from test-bed of multiagent system to practical application. In: Robot Soccer World Cup (Vol. 1, pp. 102–111). Springer, Berlin, Heidelberg. 35. Ten, C. F. J., Drury, J. K., Meerbaum, S., Noordsy, J., Feinstein, S., Shah, P. M., & Corday, E., (1984). Myocardial contrast twodimensional echocardiography: Experimental examination at different coronary flow levels. Journal of the American College of Cardiology, 3(5), 1219–1226. 36. Vellaithurai, C. B., Biswas, S. S., & Srivastava, A. K., (2015). Development and application of a real-time test bed for cyber-physical system. IEEE Systems Journal, 11(4), 2192–2203. 37. Verbeck, C. P., & Greenberg, D. P., (1984). A comprehensive lightsource description for computer graphics. IEEE Computer Graphics and Applications, 4(7), 66–75. 38. Vetsch, D. F., Vanzo, D., Bürgler, M., Bacigaluppi, P., Conde, D., Boes, R. M., & Siviglia, A., (2020). High performance computing in river modeling: A novel two-dimensional software for river hydro-and morphodynamic simulations. In: River Flow 2020 (Vol. 1, pp. 1401– 1408). CRC Press. 39. Voisin, A., Levrat, E., Cocheteux, P., & Iung, B., (2010). Generic prognosis model for proactive maintenance decision support: Application to pre-industrial e-maintenance test bed. Journal of Intelligent Manufacturing, 21(2), 177–193. 40. Williams, R. D., Brasington, J., Hicks, M., Measures, R., Rennie, C. D., & Vericat, D., (2013). Hydraulic validation of two‐dimensional simulations of braided river flow with spatially continuous aDcp data. Water Resources Research, 49(9), 5183–5205. 41. Xu, P., Zhu, Y., & Cai, S., (2022). Innovative research on the visual performance of image two-dimensional animation film based on deep neural network. Neural Computing and Applications, 34(4), 2719– 2728.

94

Exploration of Computer Graphics

42. Yu, J., Liu, D., Tao, D., & Seah, H. S., (2011). Complex object correspondence construction in two-dimensional animation. IEEE Transactions on Image Processing, 20(11), 3257–3269. 43. Zhang, Y. M., Chamseddine, A., Rabbath, C. A., Gordon, B. W., Su, C. Y., Rakheja, S., & Gosselin, P., (2013). Development of advanced FDD and FTC techniques with application to an unmanned quadrotor helicopter testbed. Journal of the Franklin Institute, 350(9), 2396– 2422.

CHAPTER

4

LIGHTS AND MATERIALS FOR COMPUTER GRAPHICS

CONTENTS 4.1. Introduction....................................................................................... 96 4.2. Introduction to Lighting..................................................................... 96 4.3. Light and Material in Opengl 1.1..................................................... 105 4.4. Image Textures................................................................................. 113 4.5. Lights, Camera, Action..................................................................... 116 References.............................................................................................. 124

96

Exploration of Computer Graphics

4.1. INTRODUCTION Physical reality, or creating visuals that seem to be photos of truth, is among the aims of graphic design. This isn’t the sole objective. The purpose of visualizing data, for instance, is to portray data clearly and properly using computer visuals. Computer graphics may be used by designers to generate modern paintings instead of realistic art. Furthermore, in a few of the most apparent applications of computer visuals, like video games, films, and marketing, realism is a primary aim (Gooch, 1996). Illumination is a crucial part of physical realism: the role of light as well as shadow, the method light scatters off material properties, and the method light bends or diffracts when it travels across transparent objects. All of such aspects, as well as others, may be taken into consideration in the methods to make the most accurate visuals. Therefore, speed seems to be another purpose of computer animation (Verbeck and Greenberg, 1984). OpenGL was created with real-time visuals in mind, in which the amount of time accessible for generating a picture is a matter of seconds. It’s all right if every frame in an animated movie requires hours to produce. A video game, on the other hand, is supposed to produce 60 frames per second. Also, with contemporary computer graphics machines’ tremendous speed, tradeoffs are required to achieve that performance. The tradeoffs were much larger 30 years ago, while OpenGL was in its infancy (Durfee and Montgomery, 1989). We’ll examine light as well as substance in OpenGL 1.1 throughout this chapter. We will focus on giving material attributes to items and setup light resources. The way things engage with light is determined by their material qualities. We will also study how to use a picture as a pattern on a material. By historical standards, OpenGL 1.1’s capability for sunlight, substance, as well as pattern is basic and inadequate. However, the techniques it employs are still used to underpin current real-time visuals and, to a large degree, all but the most accurate graphic design (Stevenson & Rosenman, 1992).

4.2. INTRODUCTION TO LIGHTING Lighting is among the most crucial aspects of creating realistic 3D visuals. The objective is to recreate lighting effects and how the light they transmit comes into contact with visual objects. OpenGL’s illumination analyzes are deactivated by default. This indicates that whenever OpenGL pertains color to an edge, it utilizes the existing color information as decided by a few of the glColor* functions. In sequence for OpenGL to calculate light sources,

Lights and Materials for Computer Graphics

97

you must facilitate lighting by trying to call glEnable (GL LIGHTING) (Jennings et al., 2000). If you do nothing else, you will discover which of your items are purely black. To be able to see them, you must transform on the lights. The characteristics of a surface that evaluate how it comes into contact with light are known as the surface’s substance. A surface can exhibit a variety of properties of materials. Before we examine the OpenGL API for brightness as well as material, you must have a basic understanding of light as well as material properties. The above section introduces these concepts. The conversation about how lighting is implemented in OpenGL 1.1 is deferred until the following section. We postpone discussion of how lighting is done in OpenGL 1.1 till the following section (Hall and Greenberg, 1983).

4.2.1. Light and Material A few of the light that hits a surface would be mirrored. The precise manner in which it mirrors is intricately dependent on the type of the surface, or what I refer to as the surface’s features of materials. OpenGL 1.1 approximates the difficulty with two main forms of reflection: specular reflection and diffuse reflection. Such two forms of reflections are also essential to other 3D graphics systems (Figure 4.1) (Clark et al., 2012).

Figure 4.1. Two forms of reflection are crucial in various 3D graphics techniques. Source: https://www.javatpoint.com/computer-graphics-reflection.

98

Exploration of Computer Graphics

In complete specular (“mirror-like”) reflection, an incident beam ray is perfectly reflected off a material. The incident ray and the reflected waves create a similar angle with the ground. A spectator can only observe the reflecting beam if he or she is precisely positioned all along the direction of the light reflected. Even though the source of light illuminates the whole area, the spectator only observes the light source’s mirror at such locations on the surface in which the shape is correct. These reflections are called specular highlights. In actuality, we consider a beam of light to be mirrored not even as a single proper beam, but as a somewhat thin light source (Figure 4.2) (Greenberg et al., 2013).

Figure 4.2. Diagrammatic illustration of specular reflection. Source: https://www.researchgate.net/figure/Illustration-of-diffuse-reflectionand-specular-reflection_fig1_324769047.

Specular reflection from a highly reflective surface generates very thin beams of light reflected; specular sparkles on the material are tiny and pointed. A surface with a lower reflectivity will generate broader cones of mirrored light and larger, fuzzier specular lights. Glossiness is the OpenGL material attribute that influences the magnitude as well as clarity of specular highlights. Shininess is an integer between 0 and 128 in OpenGL. As the value rises, the size of specular reflections decreases. This graphic depicts eight rounds that vary only by their shininess material attribute value (Figure 4.3) (Feiner and McKeown, 1991).

Lights and Materials for Computer Graphics

99

Figure 4.3. Image depicts eight rounds that vary just in their shininess substance attribute value. Source: https://www.siyavula.com/read/science/grade-8/particle-model-ofmatter/06-particle-model-of-matter?id=toc-id-4.

The shininess of the sphere on the left is set to zero, resulting in an unsightly reflective “highlight” that nearly spans a whole hemisphere. From left to right, the luster of each successive sphere rises by 16 units. A clean reflective surface scatters an oncoming light beam evenly in all planes. A spectator would be seeing sunlight reflecting from every part of the surface. If such entering light comes in parallel beams that uniformly brighten the surface will look evenly lighted to the observer. The quantity of light at a place relies on the degree to which the ray strikes the material at a certain location, and not just on the direction of the line from such a site to the viewer (Steil and Roßmann, 2014). Whenever light hits a surface, this may be consumed, a few can be unevenly mirrored, and can also be secularly mirrored. The quantity of reflection might vary depending on wavelength. The extent to which a substance takes into account light of different wavelengths is just what determines its color. Presently it seems that a substance could have two distinct colors: a diffuse color that indicates how it sparsely needs to reflect light, and a highly reflective color that indicates how it specularly needs to reflect light. The diffuse color is the object’s primary color. The color scheme of specular highlights is determined by the specular color. The diffuse and specular hues might be identical; for metal particles, that’s often the case. Or they may be distinct; for instance, plastic material will typically have white specular highlights regardless of the diffuse hue (Lesser and Corkill, 1983). OpenGL is even more advanced. There are in reality two more hues connected with a substance. The third color is the object’s atmospheric color, which indicates how the surface reflects the light source. Ambient light is the actual scale of lighting which does not originate from a single

100

Exploration of Computer Graphics

light source. It is composed of radiation that has been mirrored and refracted so often that it no more emanates from a certain location. Because of the light source, the shades are not completely black. In actuality, ambient light is simply a rough representation of the actuality of many projections, but it is preferable than rejecting them. A material’s atmospheric color influences how it reflects different wavelengths of ambient light. The atmospheric color is often selected to match the diffuse color (Li et al., 2015). The fourth color attached to the material is the emitted color, which isn’t a true color in a similar way to the preceding three. Such that, it has nothing to do with how light is reflected by the surface. The emitting color is a color that does not originate from an independent factor, so it appears to be released by the substance directly. This would not imply that the item is emitting light that would brighten other things, but does indicate that now the object is visible in the absence of a beam of light (not beam light). In the visible light, the entity would then have seemed to light up since it will be clearer than could be explained by the brightness that enlightens it. Typically, the emitting color is black, indicating that the item emits no light (Lewis et al., 2019). Every one of the four-color attributes of material is specified by three values representing the red, green, and blue (RGB) parts of the color. Real light is composed of an unlimited variety of wavelengths. An RGB color consists of only three factors, yet considering the nature of natural color perception, even an approach is sufficient for most uses. Substance colors may have alpha parts, but only the diffused substance color’s alpha element is ever utilized in OpenGL (Chen et al., 2012). When referring to the red, blue, and green parts of the atmospheric, diffuse, or specular color, “color” really refers to reflection. Thus, the red element of a color indicates the percentage of red light striking a material that is mirrored, as well as likewise for the green and blue components. Since there are three forms of light in OpenGL, there are three sorts of reflecting color, and a substance may have a distinct reflection for every light source (Poupyrev et al., 1997).

4.2.2. Light Properties Apart from illuminance, an atmosphere’s light is provided by a source of light including light or the sunlight. A lamp as well as the sun, in reality, are two distinct types of light sources: point light as well as directed light. A point source of light is a 3D source of light that generates light rays from

Lights and Materials for Computer Graphics

101

a single point. Many of the light in a directed light originates from a similar direction, therefore the beams of light are straight. Because the sun is far off, its light beams are almost straight once they reach the Earth, it is termed a directed light supply (Figure 4.4) (Schmeckpeper et al., 1989).

Figure 4.4. The sun is considered to be a directional light source since it is so far away that light rays from the sun are essentially parallel when they get to the Earth. Source: https://www.lpi.usra.edu/education/skytellers/seasons/.

Color may exist in light. In reality, every source of light in OpenGL has three primary colors: a diffused color, an atmospheric color, as well as a specular color. The color of a photon is more correctly referred to as brightness or power, even as the color of a substance is more appropriately known as reflectance. Color relates to how the energy of light is dispersed across various wavelengths. Real light may have an endless number of wavelengths; whenever the light waves are divided, spectra or rainbows are formed, including a range of colors. Just the three fundamental hues, red, green, and blue, are used to depict light on a laptop. As with substance color, light color is given by three integers that indicate the light’s red, green, and blue strengths (Stel and Roßmann, 2015). The diffuse strength of light connects with diffused substance color, while the specular level works to specular substance color. The diffused and reflected light intensity are often similar. A light’s ambient strength operates a bit differently. Remember that light source is illumination that cannot be traced back to a specific source. However, it has to originate from someplace, and we may assume that switching on a light would raise the atmospheric brightness levels in the surroundings. In OpenGL, a light’s ambient strength

102

Exploration of Computer Graphics

is contributed to the existing amount of light source. (There may also be worldwide usable light that is unrelated to all the scene’s visible light.) The interplay between ambient light as well as the ambient hue of a substance is independent of the location of the visible light or the spectator. As a result, a source of light does not need to reflect on an item to change the object’s atmospheric color; the source of light only has to be switched on (Calandrino et al., 2006). One should note that this is simply an estimation. Some computer animation techniques simulate light sources just using single color since strong light resources do not even have discrete atmospheric, diffuse, as well as specular colors (Taylor et al., 2007).

4.2.3. Normal Vectors The special impact of bright light on a ground varies based on the surfaces and light’s characteristics. However, it also varies based substantially on the angular position at which light hits the surface. The slope is vital for specular reflection and influences diffuse reflection as well. Because of this, a contoured, bright surface appears varied from various vantage points, as it has a uniformly colored surface. To determine this angular position, OpenGL requires knowledge of the surface’s orientation (Cohen et al., 1986). A vector that is orthogonal to the surface specifies this orientation. Normal is an alternative term for right angles, and a non-zero matrix that is orthogonal to the ground at a specified place is known as a vector field to that ground. A normal vector used during lighting estimations should have a duration of one. A one-length normal vector is known as a unit normal. For adequate lighting estimations in OpenGL, so every vertex must have a unit normally defined. Nevertheless, a unit normal can be calculated from every vector field by separating the vector by its size (Jato et al., 2016). Because a surface could be rounded, at various points this could encounter in various positions. Consequently, a normal vector is linked to a specific surface point. In OpenGL, normal vectors are only designated to the primitive’s nodes. The normal vectors at the primitive’s nodes are being used to calculate light sources for a whole primitive (Wetter, 2011). Observe especially that distinct standard vectors may be assigned to every node of a polygon. You may be wondering, “Don’t all basic vectors to a polygon spot in a similar direction?” A polygon is a level; the orientation

Lights and Materials for Computer Graphics

103

orthogonal to the polygon does not vary from spot to spot. If your goal is to show a polyhedral object where edges are plain polygons, then every one of these polygons’ normals must point in a similar direction. In contrast, polyhedra are frequently employed to estimate curved surfaces like spherical. If your true goal is to create that which resembles a curved surface, you should utilize standard vectors that are orthogonal to the real ground, not the polyhedron that represents it. Examine the following instance (Figure 4.5) (Helmer et al., 2013).

Figure 4.5. Example of a normal vector. Source: https://www.storyofmathematics.com/normal-vector/.

The two items in this image are composed of rectangular bands. Even though the two items have identical geometry, they seem substantially different. In each instance, various normal vectors are used. The ring of rectangles on the top item is intended to resemble a flat finish. The corners of the rectangles are locations on this exterior, and I didn’t would like to view the rectangles at all; I wanted to see the curving texture or a good estimate of it (Immel et al., 1986). Whenever specifying the normal vector at any of the nodes for the top object, I chose a vector that is orthogonal to the surface instead of the rectangle. For the item on the bottom, though, I envisioned an object that is such a ring of rectangles, as well as I utilized standard vectors that have been orthogonal to the rectangles. Here is a 2D representation of the normal vectors used to create the two images (Figure 4.6) (Bolt, 1981).

104

Exploration of Computer Graphics

Figure 4.6. Representation of normal vectors in two dimensions. Source: html.

https://study.com/academy/lesson/vectors-in-two-three-dimensions.

The bright blue lines indicate the rectangles when viewed from overhead edge-on. The lines symbolize normal vectors. Normals exist at every terminal of every rectangle. Every vertex is a component of two rectangles; hence, every vertex has two common vectors. In the lower part of the figure, two intersecting rectangles have distinct standard vectors at their point of intersection. In reality, the usual vectors of a rectangle are orthogonal to the rectangle. There is a sudden shift in direction as you walk from one rectangle to another; thus, the standard vectors of the two rectangles disagree at their intersection. Between the two rectangles, the produced picture displays a sudden shift in a shade that is viewed as an edge or border (Carter & Drewfs, 1983). In contrast, the vectors in the upper half are orthogonal to a surface that crosses across the extremities of the rectangles. Whenever two rectangles overlap a vertex, their standard at that vertex is similar. This reduces the sudden shift in shading, giving in a surface that seems to be more gently curved. Flat coloring and smooth coloring are the two methods used to allocate standard vectors. A surface with flat shading seems to have flat sides or angles. Smooth coloring creates the illusion of a smooth surface (Liu et al., 2012).

Lights and Materials for Computer Graphics

105

In light of this, you are free to create whichever normal vectors fit your needs. Normal vectors at vertices are arbitrary and do not need to be orthogonal to the polygon. The standard vector you select should be dependent on the item you are attempting to simulate. Another consideration when selecting normal vectors is there are two alternative unit standard vectors traveling in opposing directions at each point on a surface. A three-dimensional polygon has two sides that face in opposite ways. OpenGL identifies one as the front face and the other as the rear face. OpenGL distinguishes them based on the sequence in which the given vertices are supplied. The arrangement of the vertices is anticlockwise when seen from the frontal face as well as clockwise when viewed from the rear face (Wang et al., 2010). That rule enables OpenGL to determine if the front-face or backface is being displayed whenever the polygon is rendered on the display. While supplying a shape for the polygon, the vector must point away from the polygon’s frontal face. It is an additional instance of the right-hand principle. If you bend your right hand’s fingers in the direction indicated for the polygon’s vertices, the usual vector must indicate the position of your finger. Note that while seeing the frontal side of a polygon, the normal vector must point in your direction. When seeing the back of an object, the standard vector must step away from you. It might be challenging to determine the right standard vectors for an item. Frequently, complex geometric systems contain the essential normal vectors. This holds, for instance, for the GLUT library’s solid forms (Murphy-Chutorian and Trivedi, 2010).

4.3. LIGHT AND MATERIAL IN OPENGL 1.1 That section will demonstrate how to utilize lighting and materials in OpenGL. The methods covered in this part are particular to previous iterations of OpenGL and will not be immediately applicable to newer graphics APIs. However, the underlying notions which they apply, as discussed in the preceding section, are more generalizable. Light, as well as material usage in OpenGL 1.1, must be enabled by executing glEnable (GL LIGHTING). Whenever lighting is turned off, the hue of a pixel is just the color specified by glColor*. Whenever lighting is set, the hue of a vertex is determined using a complex equation that considers the illumination of the area as well as the material attributes given to the edge, as explained in the preceding

106

Exploration of Computer Graphics

part. It’s necessary to study the OpenGL instructions for configuring lighting and assigning substances to objects (Shao et al., 2001). Lighting is often switched on for rendering certain sections of a picture and switched off for others. Many items will be “highlighted,” whereas others will not be. Wireframe objects, for instance, are often rendered with lighting turned off, particularly if they are the segment of a scene containing lighted solid objects. However, since it is forbidden to use glEnable or glDisable within glBegin and glEnd, it is not feasible for one section of a primitive to be lighted since another portion of the similar primitive remains unlit. (It should be noted that whenever lighting is allowed, it is given to line as well as line primitives and also polygons, although this seldom works in a way) (Petre, 1997). Lighting may be activated and disabled by using glEnable and glDisable with the GL LIGHTING argument. Additional lighting, as well as substance settings, do not need to be changed when lighting is switched off because they are completely disregarded. To illuminate a scene, you must set at least one light beam in parallel to activate GL LIGHTING. For extremely simple illumination, enable(GL LIGHT0); is often sufficient (Chunlon et al., 2003). The instruction activates a directed light that beams into the image from the position of the user. (It’s worth noting that the final letter in GL LIGHT0 is a zero.) Because it radiates in the path of the observer, it illuminates whatever the user can see. The light is white and has no specular element, so you would see the ambient color of things rather than any specular highlights. We’ll explore how to adjust the attributes of such a beam of light and set up more options further below. But first, let’s look at substances and basic vectors (Naumov et al., 2014).

4.3.1. Working with Material Similar to how color is a vertex property, material characteristics are vertex characteristics. In other words, the OpenGL state represents the main amount of every material property. Whenever a vertex is formed by calling among glVertex* functions, a replica of the existing material characteristics and the vertex dimensions are kept. Whenever a primitive containing the vertex is drawn, the substance attributes and lighting data linked with the vertex are utilized to determine a coloring for the edge (Andújar and Vázquez, 2006). This is predicated on the assumption that polygons are bi-sided and their front and rear faces might be made of material properties. That implies that every vertex store 2 pairs of material property values: the whole front

Lights and Materials for Computer Graphics

107

substance and the rear material. (The rear material is not used until twosided illumination is enabled, which would be detailed later) (Forney et al., 2003). In light of these considerations, we now examine methods for configuring the existing values of properties of materials. The function is used to set the atmospheric, diffused, specular, as well as emission substance colors (Chen et al., 2009). GL FRONT AND BACK, GL FRONT, or GL BACK might be used for the first variable. It indicates if a substantial value of the property is being set for a front side, the rear face, or perhaps both. The second option specifies the material property being modified. GL AMBIENT, GL DIFFUSE, GL SPECULAR, GL EMISSION, or GL AMBIENT AND DIFFUSE are all possible values. Utilizing GL AMBIENT AND DIFFUSE as the parameter value, it is feasible to adjust the atmospheric as well as diffuse shades to a similar value with such a single call to glMaterialfv; it is the most typical scenario. The last argument of glMaterialfv is an array of four floating-point values (Kim and Dey, 2010). The numbers represent the RGBA color features as ranges between 0.0 and 1.0; values beyond this band are permitted and would be considered in lighting calculations, although they are uncommon. Notice that while an alpha element is necessary, it is only utilized for diffuse colors: The alpha part of the vertex coloring is assigned to the alpha part of the diffused material coloring whenever the vertex color is calculated (Ruikar et al., 2019). The shininess substance attribute is a single integer instead of an array, therefore changing its value (with no “v” at the end of the name) requires a distinct function: void glMaterialf (int side, int property, float value). Once more, the possible sides are GL FRONT AND BACK, GL FRONT, and GL BACK. The property must meet the GL SHININESS criteria. And the response is a floating-point number between 0.0 and 128.0. Relative to the many variants of glColor* and glVertex*, substance setting choices are restricted. Specifically, it is impossible to place the color of material without specifying an array containing the color model parameters. Consider the scenario in which bluish-green ambient and diffuse hues are desired. In C, this is possible using (Sun et al., 2009): float bgcolor[4] = {0.0, 0.7, 0.5, 1.0}; bgcolor; glMaterialfv(GL FRONT AND BACK, GL AMBIENT AND DIFFUSE, GL FRONT AND BACK);

108

Exploration of Computer Graphics

With my JavaScript OpenGL emulator, this is how it would seem. let bgcolor = [0.0, 0.7, 0.5, 1.0]; bgcolor; glMaterialfv(GL FRONT AND BACK, GL AMBIENT AND DIFFUSE, GL FRONT AND BACK) (Zhang et al., 2017); And in the JOGL API for Java, wherein procedures with matrix arguments include an extra parameter to provide the initial number of the array’s contents, this becomes possible to specify the initial index. float[] bgcolor = {0.0F, 0.7F, 0.5F, 1.0F}; bgcolor = 0; In C, the third argument is a pointer to float, that enables the flexible storage of many materials property values in a single array. Consider the case when we have a C array (Pendergast, 2003). float gold[13] = {0.24725, 0.1995, 0.0745, 1.0,/* ambient */ 0.75164, 0.60648, 0.22648, 1.0,/* diffuse */ 0.628281, 0.555802, 0.366065, 1.0,/* specular */ 50.0% reflectiveness }; In which the first four integers in the matrix provide an atmospheric color, the following four integers supply a diffuse color, the next four values indicate a specular color, and the final number specifies a shininess coefficient. That array is being used to configure all properties of materials (Zhao et al., 2013): gold; glMaterialfv(GL FRONT AND BACK, GL AMBIENT); &gold[4]; glMaterialfv(GL FRONT AND BACK, GL DIFFUSE, GL FRONT AND BACK); &gold[8]; glMaterialfv(GL FRONT AND BACK, GL SPECULAR); glMaterialf(GL FRONT AND BACK, GL SHININESS, gold[12]) translates to: Notice that the final function is glMaterialf as opposed to glMaterialfv, and its third argument is a number as opposed to a reference. Same functionality is available in Java using: float[] gold = {0.24725F, 0.1995F, 0.0745F, 1.0F,/* ambient */ 0.75164F, 0.60648F, 0.22648F, 1.0F,/* diffuse */ 0.628281F, 0.555802F, 0.366065F, 1.0F,/* specular */

Lights and Materials for Computer Graphics

109

50 F/* glossiness */ }; gl.glMaterialfv(GL2.GL FRONT AND BACK, GL2.GL AMBIENT, gold, 0); gl.glMaterialfv(GL2.GL FRONT AND BACK, GL2.GL DIFFUSE, gold, 4); gold; gl.glMaterialf(GL2.GL FRONT AND BACK, GL2.GL SHININESS, gold); The glMaterialfv and glMaterialf functions may be invoked at any moment, even among glBegin and glEnd calls. This signifies that several vertices of a primitive may have distinct substance qualities (Liu et al., 2014). So perhaps you prefer glColor* over glMaterialfv. If so, you are using it to manipulate material in addition to color. If you call glEnable(GL COLOR MATERIAL), some color characteristics of the substance would follow the color. By definition, adjusting the color also sets the existing frontal, rear, atmospheric, and diffuse attributes of the material. This includes, for instance, calling the expression glColor3f(1, 0, 0); would have a similar effect, if the lighting is allowed, as using glMaterialfv(GL FRONT AND BACK, GL AMBIENT AND DIFFUSE, array), wherein array has the numbers 1, 0, 0, 1. Void glColorMaterial(side, property); wherein side may be GL FRONT AND BACK, GL FRONT, or GL BACK while property could be GL AMBIENT, GL DIFFUSE, GL SPECULAR, GL EMISSION, or GL AMBIENT AND DIFFUSE. During calls to glBegin and glEnd, neither glEnable nor glColorMaterial may be used, therefore all edges of a primitive must have a similar value (Sun and Han, 2010). Remember that whenever glDrawArrays or glDrawElements are used to create a primitive, the color features for the primitive’s vertices may be retrieved from a color array via glColorPointer. There are no comparable collections of material attributes. Nevertheless, if a color array is utilized when illumination is allowed and GL COLOR MATERIAL is also active, the coloring array is used as the origin for the color-tracking material property values (Kapralos et al., 2014).

4.3.2. Defining Normal Vectors Lighting estimations rely heavily on two vectors. Normal vectors, such as color and material, are characteristics of edges. The OpenGL state represents

110

Exploration of Computer Graphics

the main normal vector, which itself is fixed utilizing functions from the glNormal* family. Whenever a vertex is stated with glVertex*, a duplicate of the existing normal vector is stored as a characteristic of the vertex, and is used as that of the vector field for that fixed point whenever the lighting equation computes the color scheme of the vertex. Mention that a vertex’s normal vector should be defined before calling glVertex* for that vertex (Rossi et al., 2004). glNormal* includes the functions glNormal3f, glNormal3d, glNormal3fv, and glNormal3dv. A “v” indicates that the qualities are arrays, an “f” indicates that the attributes are floats, and a “d” indicates that the values are twins. (Every normal vector contains three parts.) A few cases (Magri et al., 2016): /glNormal3f(0, 0, 1) (It is the defined value.) glNormal3d(0.707, 0.707, 0.0); floating-point normalArray[3] = 0.57, 0.57, 0.57; glNormal3fv(normalArray) is equivalent to normalArray. For a polygon that is intended to appear flat, the similar normal vector is applied to all of its nodes. For instance, to create one part of a cube, let’s tell the “top” edge, having to face the positive y-axis (Morgan et al., 2017): glNormal3f(0, 1, 0);/Points positioned along the positive y-axis glBegin(GL QUADS); glVertex3fv(1,1,1); glVertex3fv(1,1,–1); glVertex3fv(–1,1,–1); glVertex3fv(–1,1,1); glEnd(); Note that the normal vector must point away from the frontal part of the polygon, which would be defined by the sequence wherein the edges are created. (You may believe that the position wherein the normal vector lines would decide the front side, but this is not the case. If a vertex’s normal vector tried to point in the incorrect position, lighting calculations would not produce the right color scheme for such a vertex (Peter et al., 2017). When simulating a level surface, normal vectors ought to be selected orthogonal to the surface, as opposed to the surface’s approximating polygons. Suppose we want to draw the side of a cylinder with a radius of 1

Lights and Materials for Computer Graphics

111

and a height of 2, where the cylinder’s center is located at (0,0,0) and its axis runs along the z-axis. A single triangular strip can be used to represent the surface (Van Dam et al., 2000). A cylinder’s side has circular top and bottom boundaries. The coordinates (cos(a), sin(a),1) will be used for vertices along the top edge, whereas (cos(a), sin(a),1) will be used for vertices along the bottom edge, where an is an angle. Although the normal vector points in the same direction as the radius, its z-coordinate is zero since it points away from the cylinder’s side. The normal vector to the side of the cylinder at each of these points will be (cos(a), sin(a), 0). It looks as follows when seen along the z-axis at the top of the cylinder (Liu et al., 2011): While drawing the edge of the cylinder as a triangular strip, edges must be generated on alternate edges. The normal vector is identical for both edges inside a couple, but somehow it varies across pairs. Voici the code: glBegin(GL TRIANGLE STRIP); for I = 0; I 0;

Data Structures for Graphics

189

And f1(p) = 0 for all locations p just on the plane’s opposite side. We could determine whichever side of the plane T2 is on by using this attribute. Remember, every three triangles of T2 must be on the same side of the aircraft for this to work. Suppose T2 is on the plane’s f1(p) 0 edge for the sake of this discourse. Therefore, for every eyepoint e: we may draw T1 or T2 in the proper sequence (Overmars, 1988). if (f1(e) < 0) then draw T1 draw T2 else draw T2 draw T1 Because T2 cannot be entirely or partly covered by T1 as viewed from e if T2 and e should be on the same side of the aircraft including T1, it is acceptable to draw T1 first. T2 cannot totally or partly block T1 if e and T2 are on different sides of the longitudinal plane T1, or the different drawing ordering is safe (Cotton and Greatorex, 1968; Samet, 1988). This discovery may be applied to a wide range of items as long as none of them crosses the T1 plane. The positive stem of a branching tree structure with T1 the root includes all triangles where vertices possess fi(p) 0, whereas the affirmative branch includes all the triangles whose vertex have fi(p) > 0. We may draw in the following order: function draw(BSP tree, point e) if (tree.empty) then return if (free.root(e) < 0) then draw(tree.plus, e) rasterize tree. triangle draw(tree. minus, e) else draw(tree. minus, e) rasterize tree. triangle draw(tree. plus, e)

190

Exploration of Computer Graphics

The benefit of the code would be that it works for any perspective ‘e,’ allowing the tree to be calculated ahead of time. The program will operate as is if every subtree is a tree, with the root’s triangle dividing some other triangle into two different groups according to the longitudinal plane it. It may be somewhat more efficient if the recursion calls were terminated one step higher, however, the code would still be straightforward (Williams, 1971; Cederman et al., 2012).

Data Structures for Graphics

191

REFERENCES 1.

Aksoy, E. E., Abramov, A., Wörgötter, F., & Dellen, B., (2010). Categorizing object-action relations from semantic scene graphs. In: 2010 IEEE International Conference on Robotics and Automation (pp. 398–405). IEEE. 2. Botsch, M., Pauly, M., Rossl, C., Bischoff, S., & Kobbelt, L., (2006). Geometric modeling based on triangle meshes. In: ACM SIGGRAPH 2006 Courses (pp. 1-es). 3. Cederman, D., Chatterjee, B., & Tsigas, P., (2012). Understanding the performance of concurrent data structures on graphics processors. In: European Conference on Parallel Processing (pp. 883–894). Springer, Berlin, Heidelberg. 4. Chang, X., Ren, P., Xu, P., Li, Z., Chen, X., & Hauptmann, A., (2021). Scene Graphs: A Survey of Generations and Applications. arXiv preprint arXiv:2104.01111. 5. Corsini, M., Larabi, M. C., Lavoué, G., Petřík, O., Váša, L., & Wang, K., (2013). Perceptual metrics for static and dynamic triangle meshes. In: Computer Graphics Forum (Vol. 32, No. 1, pp. 101–125). Oxford, UK: Blackwell Publishing Ltd. 6. Cotton, I. W., & Greatorex, Jr. F. S., (1968). Data structures and techniques for remote computer graphics. In: Proceedings of the, Fall Joint Computer Conference, Part I (pp. 533–544). 7. Gillespie, R., & Davis, W. A., (1981). Tree data structures for graphics and image processing. In: Proceedings 7th Canadian Man-Computer Communications Conference (Vol. 7, pp. 155–162). 8. Ji, J., Krishna, R., Fei-Fei, L., & Niebles, J. C., (2020). Action genome: Actions as compositions of Spatio-temporal scene graphs. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (pp. 10236–10247). 9. Johnson, J., Gupta, A., & Fei-Fei, L., (2018). Image generation from scene graphs. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (pp. 1219–1228). 10. Johnson, J., Krishna, R., Stark, M., Li, L. J., Shamma, D., Bernstein, M., & Fei-Fei, L., (2015). Image retrieval using scene graphs. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (pp. 3668–3678).

192

Exploration of Computer Graphics

11. Jones, C. B., (1989). Data structures for three-dimensional spatial information systems in geology. International Journal of Geographical Information System, 3(1), 15–31. 12. Lefohn, A. E., Sengupta, S., Kniss, J., Strzodka, R., & Owens, J. D., (2006). Glift: Generic, efficient, random-access GPU data structures. ACM Transactions on Graphics (TOG), 25(1), 60–99. 13. Matzko, S., & Davis, T. A., (2008). A graphics-based approach to data structures. ACM SIGCSE Bulletin, 40(3), 109–113. 14. Nievergelt, J., & Widmayer, P., (2000). Spatial data structures: Concepts and design choices. In: Handbook of Computational Geometry (pp. 725–764). North-Holland. 15. Overmars, M. H., (1988). Geometric data structures for computer graphics: An overview. Theoretical Foundations of Computer Graphics and CAD, 21–49. 16. Pagel, B. U., Six, H. W., Toben, H., & Widmayer, P., (1993). Towards an analysis of range query performance in spatial data structures. In: Proceedings of the Twelfth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems (pp. 214–221). 17. Papadias, D., & Theodoridis, Y., (1997). Spatial relations, minimum bounding rectangles, and spatial data structures. International Journal of Geographical Information Science, 11(2), 111–138. 18. Pebesma, E., & Bivand, R. S., (2005). S Classes and Methods for Spatial Data: The SP Package (Vol. 5, No. 2), pp. 9–13). R News. 19. Petitjean, S., (2002). A survey of methods for recovering quadrics in triangle meshes. ACM Computing Surveys (CSUR), 34(2), 211–262. 20. Puech, C., & Yahia, H., (1985). Quadtrees, octrees, hyperoctrees: A unified analytical approach to tree data structures used in graphics, geometric modeling, and image processing. In: Proceedings of the First Annual Symposium on Computational Geometry (pp. 272–280). 21. Rossignac, J., (1999). Edgebreaker: Connectivity compression for triangle meshes. IEEE Transactions on Visualization and Computer Graphics, 5(1), 47–61. 22. Ruiz, S., Piera, M. A., & Del, P. I., (2013). A medium term conflict detection and resolution system for terminal maneuvering area based on spatial data structures and 4D trajectories. Transportation Research Part C: Emerging Technologies, 26, 396–417.

Data Structures for Graphics

193

23. Rusinkiewicz, S., (2004). Estimating curvatures and their derivatives on triangle meshes. In: Proceedings. 2nd International Symposium on 3D Data Processing, Visualization and Transmission, 2004: 3DPVT 2004. (pp. 486–493). IEEE. 24. Samet, H., (1988). An overview of quadtrees, octrees, and related hierarchical data structures. Theoretical Foundations of Computer Graphics and CAD, 51–68. 25. Samet, H., (1989). Hierarchical spatial data structures. In: Symposium on Large Spatial Databases (pp. 191–212). Springer, Berlin, Heidelberg. 26. Samet, H., (1990). The Design and Analysis of Spatial Data Structures (Vol. 85, p. 87). Reading, MA: Addison-Wesley. 27. Schroeder, W. J., Zarge, J. A., & Lorensen, W. E., (1992). Decimation of triangle meshes. In: Proceedings of the 19th Annual Conference on Computer Graphics and Interactive Techniques (pp. 65–70). 28. Sharp, N., & Crane, K., (2020). A Laplacian for nonmanifold triangle meshes. In: Computer Graphics Forum (Vol. 39, No. 5, pp. 69–80). 29. Sowizral, H., (2000). Scene graphs in the new millennium. IEEE Computer Graphics and Applications, 20(1), 56, 57. 30. Springborn, B., Schröder, P., & Pinkall, U., (2008). Conformal equivalence of triangle meshes. In: ACM SIGGRAPH 2008 Papers (pp. 1–11). 31. Stein, O., Grinspun, E., & Crane, K., (2018). Developability of triangle meshes. ACM Transactions on Graphics (TOG), 37(4), 1–14. 32. Sumner, R. W., & Popović, J., (2004). Deformation transfer for triangle meshes. ACM Transactions on Graphics (TOG), 23(3), 399–405. 33. Timpf, S., & Frank, A. U., (1997). Using hierarchical spatial data structures for hierarchical spatial reasoning. In: International Conference on Spatial Information Theory (pp. 69–83). Springer, Berlin, Heidelberg. 34. Weibel, R., (1996). Generalization of spatial data: Principles and selected algorithms. Advanced School on the Algorithmic Foundations of Geographic Information Systems, 99–152. 35. Williams, R., (1971). A survey of data structures for computer graphics systems. ACM Computing Surveys (CSUR), 3(1), 1–21.

194

Exploration of Computer Graphics

36. Williams, R., (1977). On the application of relational data structures in computer graphics. In: Data Structures, Computer Graphics, and Pattern Recognition (pp. 153–165). Academic Press. 37. Williams, R., Giddings, G. M., Little, W. D., Moorhead, W. G., & Weller, D. L., (1977). Data structures in computer graphics. In: Data Structures, Computer Graphics, and Pattern Recognition (pp. 167– 177). Academic Press. 38. Yamaguchi, K., Kunii, T., Fujimura, K., & Toriya, H., (1984). Octreerelated data structures and algorithms. IEEE Computer Graphics and Applications, 4(01), 53–59. 39. Yang, X., Tang, K., Zhang, H., & Cai, J., (2019). Auto-encoding scene graphs for image captioning. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (pp. 10685– 10694). 40. Yu, F., Tang, J., Yin, W., Sun, Y., Tian, H., Wu, H., & Wang, H., (2021). Ernie-ViL: Knowledge enhanced vision-language representations through scene graphs. In: Proceedings of the AAAI Conference on Artificial Intelligence (Vol. 35, No. 4, pp. 3208–3216). 41. Zareian, A., Karaman, S., & Chang, S. F., (2020). Bridging knowledge graphs to generate scene graphs. In: European Conference on Computer Vision (pp. 606–623). Springer, Cham.

CHAPTER

8

COMPUTER ANIMATION

CONTENTS 8.1. Introduction..................................................................................... 196 8.2. Principles of Animation................................................................... 198 8.3. Keyframing...................................................................................... 202 8.4. Deformations................................................................................... 209 8.5. Character Animation........................................................................ 210 References.............................................................................................. 217

196

Exploration of Computer Graphics

8.1. INTRODUCTION The word “animation” comes from the Latin word “anima” and refers to the process, the consequence, or the act of giving life, desire, vitality, mobility, or movement. Motion is one of the defining characteristics of living things, and a significant portion of the genuine art of animation consists of figuring out how to use motion to tell a narrative, portray emotion, or even communicate minor nuances of human behavior. A computer is a supplementary tool that may be used to accomplish these objectives (Hodgins et al., 1999). This is a tool that an experienced animator could use to assist in producing the results he desires in a timelier manner and without focusing on the technical aspects, although he is not concerned. Animation created without the use of computers, which is now commonly referred to as “traditional” animation, has its own lengthy and illustrious history, which is being added to by the hundreds of artists who are still actively engaged in this art form (Reynolds, 1982). As is the case in every industry that has been around for a while, some time-honored norms have been consolidated, and these rules provide broad, high-level direction about how certain things should work and what can be ignored. We would go through some of these fundamentals of conventional animation that may just as easily be applied to digital animation, as well as we will do so in the next chapter (Lasseter, 1987). The computer, on the other hand, is much more than only a tool. Computers not only make the animator’s primary duty less tiresome, but they also bring some very unique talents that either did not previously exist or were either impossible to achieve or incredibly hard to obtain. Strong numerical modeling methods can help to generate the required physicsbased movement for particularly difficult to animate components. Motion control frameworks allow the opportunity to document and then use real-life motion (Large, 1996; Ram and Ling, 2008). Advanced analytical models enable the construction of detailed three-dimensional designs to be created relatively easily. Because of these advancements, the usage of modern computer methods has exploded in a variety of fields, including movies and advertisements, the design of automobiles and buildings, medical, and scientific study, and a great many others. There has also been the emergence of whole new fields and applications, such as entirely computer-animated motion pictures, virtually, and immersive virtual reality technology, and of obviously, computer games (Figure 8.1) (Bétrancort and Tversky, 2000).

Computer Animation

197

Figure 8.1. The action diagram. Source: https://www.researchgate.net/figure/UML-activity-diagram-example_ fig2_302921854.

In the other sections of this chapter, topics such as geometric correction and rendering, as well as several of the other recent advancements described above, are discussed in more depth. Only the methods and algorithms that are directly utilized to produce and modify motion will be covered in this overview that we are providing. Specifically, we will make a general distinction between, and then quickly discuss, the following four primary methods of digital animation (Multon et al., 1999): •

The animator has the most complete control with keyframing since he or she delivers the essential data at certain points in time as well as the computers fill in the remainder;

Exploration of Computer Graphics

198



Algorithmic animation entails mathematical operations and techniques that are carefully devised, typically empirically, but whose outputs match a certain motion; • Dynamical equations of motion are solved using physics-based approaches; and • Motion analysis is a technology that records true motion but then translates it to computer simulations using particular equipment or processes. The creative aspect of the topic is completely ignored throughout this discussion. Generally, we will only be able to skim the surface of the exciting topic of making motion using a computer, since we can’t accomplish much more than that here. We have high hopes that readers who are interested in the topic will continue their exploration of the topic much beyond the scope of the information presented in this chapter (Moore and Wilhelms, 1988).

8.2. PRINCIPLES OF ANIMATION John Lasseter introduced important ideas established by conventional animators at Walt Disney animation studios as early as the 1930s to the awareness of the then-computer animation industry in his groundbreaking 1987 SIGGRAPH paper (Lasseter, 1987). Squash and stretched, anticipating, following through it and overlapped action, gradual, and sluggish, setting, arcs, auxiliary action, plain, and pose-to-pose activity, exaggerated, strong drawing technique, and attractiveness were among the 12 concepts listed (Garcia, 2012). Those moment guidelines, which may distinguish between a spontaneous and enjoyable animation and a deterministic and dull one, remain as relevant as ever over decades later. In animation techniques, it’s also critical to strike a balance between the animator’s flexibility and efficiency, as well as making full use of the machine’s capabilities. Even though these concepts are well-known, a variety of circumstances influence how so much attention is given to them in reality. Whereas a character animator who works on a feature film could spend a lot of time attempting to implement a few of these ideas (for example, fine-tuning his timing), several game developers think that their time would be better used somewhere (Van Breemen, 2004).

Computer Animation

199

8.2.1. Timing Every animation relies on timing or the rate at which things happen. The significance of an action, one’s personal emotional experience, and even the apparent mass of the items involved are all affected by how quickly things are happening. A movement of a player’s head from left to right, based on its pace, might signify a response to being struck by a heavy item slowly searching a book on a bookcase or extending neck muscles (Carter, 2016). Setting timing that is suitable for the activity at hand is critical. Actions should last long enough to be observed while avoiding movements that are overly sluggish and possibly dull. The sound offers a natural time foundation to be maintained in computer animation projects that use recorded sound. In reality, for most films, the actor’s speech is captured first, and then the whole animation is synchronized to it. Timing may be used to offer substantial information about an object’s mass since big and heavy things typically move slowly (with less velocity, to become more accurate) (Ghani and Ishak, 2012).

8.2.2. Action Layout The spectator should be able to tell what notion (actions, attitude, emotion) is being portrayed at any point throughout the animation. Without saying anything, good staged, or greater strategic planning, should bring a viewer’s attention to where the main action is now focused, essentially telling him “Look at this, but now, look at this.” A basic understanding of human perception may assist us in completing this challenging endeavor. Because human vision systems respond to variability in stimulus rather than actual values, a sudden movement in a motionless setting or a lack of motion in a crowded scene naturally attracts attention. When opposed to a frontal arrangement, the identical motion presented such that the organism’s outline changes may frequently be considerably more obvious (see Figure 8.1 (bottom left)) (Chan et al., 2013). Every action may be divided into three elements on a more basic level: expectation (planning for the action), the activity itself, and adoption (termination of the action). In several situations, the action is the quickest and, in some ways, the least engaging section of the story. Kicking a ball, for example, can include substantial preparations on the kicker’s part as well as considerable “eye tracking” of the leaving ball, with plenty of opportunities to illustrate the kicker’s tension, emotional condition, and even response to the predicted consequence of the activity. The action (kicking the ball

200

Exploration of Computer Graphics

with the leg) is simple and requires just a matter of seconds in this scenario (Sultana et al., 2013). The purpose of anticipating is to get the audience ready for what’s going to occur. This is particularly critical if the activity is quick, significant, or tough. Creating a larger expectation for such actions emphasizes these characteristics and ensures that the action also isn’t ignored (see Figure 8.1 (bottom center) (Sloan et al., 2012; Riwinoto, 2020). In real life, the primary action often triggers one or even more secondary acts. In the obey stage of the primary motion, different appendages or loose sections of the item often drag behind the biggest and most important section and stay moving for a time, as seen in Figure 8.1 (bottom right). Furthermore, the following action often begins before the preceding one is completed (Kazi et al., 2016). While still following the football he just kicked, a player may begin sprinting. Ignoring natural flow makes it seem as though there are gaps between activities, which may lead to robotic mechanical motion. While overlapping is required to maintain the motion authentic, the animator often adds supplementary initiatives to create the motion more fascinating and create realistic animation intricacy. It’s critical not to let secondary activity take precedence over primary action (Pambudi et al., 2021).

8.2.3. Animation Techniques When making motion appear more organic, there are a few different strategies that may be applied. The most significant is arguably compression and stretching, which implies that a moving organism’s form changes in a certain manner as it travels. When pressure is applied to an item, it is usually stretched in the direction of movement and squashed, as seen in Figure 8.2 for a famous animation of such a ball bouncing. It is critical to maintain the whole volume to prevent the illusion of the thing increasing or shrinking. Additional stretch (or squashing) is done as the speed of motion (or force) increases. Deflections like this are utilized for a variety of purposes (Bishko, 2007).

Computer Animation

201

Figure 8.2. A classic illustration of the squash and stretch concept in action. Source: one.html.

http://sevencamels.blogspot.com/2011/10/squash-and-stretch-part-

An object may move through two successive frames so rapidly for extremely fast motion there is no overlapping between both the objects at the period of the consecutive frames as well as the preceding frame, causing strobing (a variant of aliasing). Having the item stretched in the direction of motion might assist the eye in avoiding this problem occur by ensuring greater overlap (Thesen, 2020). Squeezing may also be used to demonstrate item elasticity, with greater deformation being given to more malleable materials. As an item is meant to look stiff, its form is kept the same even when it moves. Because natural motion seldom occurs along straight lines, it’s best to avoid them in animation and instead employ arcs (Weir and Heeps, 2003). Likewise, no true motion can alter its speed instantly—doing so would require applying an infinite degree of force to an item. In animation, it is also preferable to avoid similar scenarios. The movement should, in general, begin, and stop slowly (slow in and out). Whereas plain action, in which an animator starts at the first frame and draws one frame yet again in succession until the conclusion, is often used in hand-drawn animation, rotation-invariant action, also referred to as keyframing, is far more ideal for computer-generated imagery (Kazi et al., 2016). The remainder of the animation (through frames) is filled in only when the keys are established in this approach, where animation is meticulously planned using a succession of very widely separated keyframes (Figure 8.3). This provides for more exact timing and enables the computer to handle the most time-consuming portion of the process: creating the in-between frames, which is covered in the following section (Salomão et al., 2021). Most of the approaches listed above may be exaggerated to generate a stronger esthetic impact or to emphasize a certain characteristic of an action

202

Exploration of Computer Graphics

or a personality. The overall aim is to create something that the audience will want to watch, something that will appeal to them. Extreme symmetry or extreme intricacy in a personality or activity is less attractive. A conventional animator must have strong drawing abilities to produce effective results. A computer animator, on the other hand, should be well-versed in computer animation and the technologies it employs (Fisher, 2010; Prasasti et al., 2018).

8.3. KEYFRAMING When it comes to 3D computer animation, the phrase keyframing might be deceptive since no finished frames (i.e., pictures) are usually involved. A 3D scene is defined by a set of digits at any given time: the location of all item centers, their RGB color combinations, and the quantity of scalability applied to every object on each axis, to model transitions between various parts of a complicated system, camera location and orientation, source of light concentration, and so on. Every subset of these variables must change over time to animate a visual. One could set these variables directly at each frame, but it would be inefficient (Igarashi et al., 2006).

Figure 8.3. While keyframing (on the top) fosters elaborate action preparation, straight-ahead action (on the bottom) produces a more spontaneous outcome. Source: https://learn.toonboom.com/modules/animation-principles/topic/ straight-ahead-and-pose-to-pose-principle.

Computer Animation

203

Shorter that, with each of the variables, a list of key points in time (usually forms TK) may be selected all along the animation sequence, and the quantities of this component (key values FK) are only set for such specified frames (Terra et al., 2004). A key will be defined as a combination of a key point and a primary key (Tk, FK). Although keyframes for distinct parameters are also not the very same, it is generally reasonable to set keys with at least a few variables at the same time. For instance, keyframes for a certain item’s x-, y-, and z-coordinates could all be assigned to the same frames, resulting in a given position vector key (Tk, pk). These pivotal moments, these crucial frames, on the other hand, could not be the same as the ones picked for the item’s alignment or color (Huang et al., 2005; Faloutsos et al., 1997). The animator has greater control over the output if the keyframes were closer together; nevertheless, the expense of completing more effort to configure the keys must be considered. As a result, it’s common to have a lot of space among keys in portions of the animation that are relatively basic, and a lot of space among keys in periods when sophisticated motion happens, as seen in Figure 8.4 (Treuille et al., 2003).

Figure 8.4. For the same scenario, you may utilize several patterns of setting keys (black circles). There are likely to be more frames before and after this section. Source: https://www.nature.com/articles/s41598-021-81115-9.

The system must calculate f values for every additional frame once the animator selects the key (TK, FK). Even though we’re only concerned with a categorical collection of values, it’s easier to think of this as a traditional interpolation issue that involves fitting a continuous animation curve f(t)

204

Exploration of Computer Graphics

over a series of points (Figure 8.5). Techniques that calculate the essential information straight from keys are preferred for animation because the animator just gives the keys but not the derivatives (tangent) (Kondo et al., 2005; Hodgins et al., 1999). The derivatives of the curves with the function of time df/determine the rate of variable change all along the curve. As a result, C1 continuity is usually required to prevent abrupt changes in velocity. Because the derivative, which relates to velocity or load applied, can encounter very rapid dynamic changes in circumstances (ball to hit a solid wall), and greater credit default swaps do not straight correspond to any variables of physical motion, a higher level of continuity is generally not necessary from animation curves. Catmull-Rom splines are one of the greatest options for creating initial animation curves because of these factors (Zhang et al., 2018).

Figure 8.5. Although only data at frame locations are of importance, the animator’s keys are used to fit a continuous curve f(t). The pace of parameter change is defined by the derivative of this function, which is initially obtained automatically by the fitting technique. Source: https://gamemath.com/book/curves.html.

All animation system enables the animator to fine-tune this initial curve interactively, such as adding new keys, tweaking current keys, or changing automatically generated tangents. The TCB control method is another valuable tool for adjusting the curve’s form (TCB stands for tension, continuity, and bias). The concept is to provide three new variables that may be used to change the form of the curve at a key by adjusting the inbound and outbound digressions at this location in a coordinated manner. The usual Catmull-Rom equation for entering Tiin and departing Ti out tangents at an

Computer Animation

205

interior key (TK, FK) may be recast as for keys equal spacing in time having distance t separating them (Browning et al., 2014). 1 1 (f k +1 − f k ) + (f k − f k −1 ) 2∆t 2∆t Modified tan gents of a TCB spline are (1 − t)(1 − c)(1 + b) (1 − t)(1 + c)(1 − b) Tkin (f k +1 − f k ) + (f k − f k −1 ), = 2∆t 2∆t (1 − t)(1 + c)(1 + b) (1 − t)(1 − c)(1 − b) Tkout (f k +1 − f k ) + (f k − f k −1 ) = 2∆t 2∆t Tkin = Tkout =

By scaling combined inbound and outbound network tangents, the stress parameter t regulates the stiffness of the curvature near the key. A smoother curve form towards the key is caused by larger digressions (lower tension) (Haarbach et al., 2018). Bias b enables the animator to raise the gravity of a key’s neighbors locally, bringing the curve nearer to a single direction linking the key to its left (b near 1, “going past”) or right (b near 1, “underestimating”) neighbors. Input and output tangents are different when continuity c is nonzero, enabling the animator to generate bends in the curves at the key value. The range of feasible TCB model parameters is often limited to [1; 1], with defaults t = c = b = 0 matching the initial Catmull-Rom spline. Figure 8.6 shows several examples of potential curve form modifications (Joshi et al., 2006).

Figure 8.6. Utilizing TCB controls to edit the default interpolating spline (middle column). Source: https://www.mathworks.com/help/matlab/ref/spline.html.

206

Exploration of Computer Graphics

8.3.1. Motion Controls So far, we’ve covered key location and fine-tuning tangential variables at the keys to influencing the form of the animation curves. But, when one wants to have command over all of where the item is traveling, i.e., its route, and how quickly it goes along that path, this is usually insufficient. Automated curve-fitting systems may fit a curve across a collection of key locations in space, but the resultant motion is only controlled by requiring the objects to appear at a defined key position pk just at the matching key framework, with no direct mention of the velocity of movement between both the keys (Reeves, 1981). This may cause issues. If an object advances down the x-axis at 11 m/ sec for 1 second and then at 1 m per second for 9 seconds, it will reach x = 20 after 10 seconds, fulfilling the animator’s keys (0,0). (10, 20). It’s doubtful that this erratic motion was intended, and a smooth motion at a rate of 0.2 meters per second is more probably whatever the animator had in mind when selecting these keys. Quadratic curves produced from traditional fitting approaches do exhibit non-uniform distribution velocity of movement across keys, as seen in Figure 8.7, but do not always exhibit such dramatic behavior (Izani and Eshaq, 2003).

Figure 8.7. All three movements follow the same two-dimensional route and fulfill the set of keys at the black triangles’ tips. Source: https://www.sciencedirect.com/topics/social-sciences/routing-protocol.

Computer Animation

207

Although this is acceptable (within boundaries) for some variables in which the visual system wasn’t very good at detecting a greater impact in the speed of change (such as coloring or even speed of rotation), we must do it effectively for placement p of the item in which acceleration specifically relate to daily reality (Terra and Metoyer, 2007). First, we’ll differentiate between the curve parametric used through the fitting method and the curve parametric utilized for animation. When we fit a curve using position keys, the outcome is written as a functional p(u) of some variable u. This will explain the curve’s shape in space. The mechanical length of the curvature is the arc length s. Specifying an additional function s(t) that relates to how far along the curves the object should have been at any given time is a logical approach for the animator to manage the movement along a now curves. One further supplementary function, u(s), is required to get a real location in space. It computes a parameter value u for a provided arc length s. Combining these functions yields the whole process of determining an object’s location for a given point in time t (Wheatland et al., 2015): p(t) = p(u(s(t))) As even the function f s, a variety of common functions may be employed (t). The linear equation relating to constant speed is one of the simplistic: s(t) = vt with v = constant. The movement with continuous accelerating a (and starting speed v0) is given by the parabola s(t) = v0t + at2/2. This equation may be used to mimic ideal ease-in and easiness behavior since velocity changes slowly here (Lasseter, 1987). The gradient of s(t) indicates the speed of movement with such a negative slope, which corresponds to travel rearward along the curve. The option to dynamically change s(t) is often supplied to the animator either by animation platform to obtain maximum flexibility. The distance measure isn’t the only approach to keeping motion under control. In certain circumstances, a speed function v(t) or even a speed function a may be more comfortable for the user (t). To utilize these controls, the software first retrieves the distance-time relationship by incorporating the input from the user (twice in the instance of a(t)) (Pullen and Bregler, 2002). The technology establishes an automated link between both the curve variable u and the arc length s. In reality, the system determines the arc length dependence on parameter u (i.e., the inverted function s(u)) first. It is feasible to calculate the equation s(u) S = 0 with variable u that uses this

208

Exploration of Computer Graphics

function for every given S, yielding u. (S). The variable s(u) cannot be stated in complete analytical form with most curves, hence numeric integration. The equation s(u) S = 0 for u may thus be solved directly using the means of standard seedlings approaches (like Newton’s method) (Barbič et al., 2009). Another option is to represent the curve as a series of linear sections connecting points pi calculated at a set of appropriately densely separated model parameters UI. The next step is to build a database of estimated arc lengths (Ciccone et al., 2019). i

s(u i ) ≈ ∑ || Pj − Pj−1 ||= s(u i −1 )+ || Pi − Pi −1 || . j=1

Because s(u) is a non-decreasing product of u, the interval holding the value S may be found by simply scanning the table. Finally, the device of the interval’s u end values is used to determine u. (S). If more accuracy is required, a few rounds of the Newton-Raphson method may be used using this number as that of the starting place (Steketee and Badler, 1985).

8.3.2. Interpolating Rotation The approaches described above may be used to extrapolate the keys specified for the majority of the scene’s variables. One major movement for which more specific interpolation techniques and descriptions are prevalent is three-dimensional rotations. This is because employing normal procedures for 3D rotations often results in major practical issues (Jin et al., 2012). Apart from translation, the only motion that preserves an object’s form is rotation (a change in its orientation). As a result, it plays a unique function in the animation of hard objects. An entity’s orientation may be specified in a variety of ways. Regrettably, naive (component) rotation matrix approximation does not provide accurate results. The null matrix, for example, is the matrices “half the way” across 2D clockwise and counterclockwise 90° rotation (Hong and Kim, 2004):

1  0 1  1 0 + 2  −1 0  2 1

−1  0 0  = 0   0 0 

The units matrix correlating to no rotations is, obviously, the right result. Secondly, random orientation may be specified as a series of precisely three revolutions around cartesian coordinates selected in a certain order. Such axes might be static in space (repaired description) or integrated into the

Computer Animation

209

object (rotational depiction). All three rotational angles may be animated immediately using normal keyframing, however, an issue known as gimbal lock occurs (Thompson et al., 2020). Gimbal lock occurs when one of the three movable joints accidentally aligns with the other while rotating, decreasing the number of variables accessible to a physical device by one. A simple 90° rotation towards the right (or left) might put an item into a gyroscope lock, which is more often than one would assume. Lastly, any direction may be given by selecting a suitable axis in spacetime and an angulation around that axis (Bechmann and Dubreuil, 1993). Although animating in this form is simple, combining these two rotations, that is, determining the axis and angle that correspond to a series of two rotations each denoted by axes and angle, is not. Equations are a unique mathematical instrument that has been constructed to make this formulation ideal for integrating several revolutions into a unified one as well as for animation (Togawa and Okuda, 2005).

8.4. DEFORMATIONS Object modification techniques are typically described with animation techniques, even though they are more appropriately handled as modeling tools. Non-uniform scalability is perhaps the most basic example of such an operation that affects the geometry of an item. px = f(p,), wherein p is a column of parameters utilized by the distortion function, may be performed to coordinate the frame of all points describing the object (i.e., nodes of a triangular mesh or controlling polygons of a smoothing surface), moving these points and generating a new shape: Using several f (and mixing them by using them rapid succession) might assist to generate some pretty intriguing deformations (Faloutsos et al., 1997). In this scenario, keyframing the variables of the distortion function makes animating transformation fairly simple. The difficulties in selecting the functional form for certain nonstandard elastic deformation, as well as the reality that the resultant distortion is worldwide in the meaning that the whole object, rather than just a portion of it, is altered, are both drawbacks of this approach (Faloutsos et al., 1997). Just choose a single vertex, transfer it to a new place, and then alter vertices within some vicinity to follow the seeding vertex to modify an object regionally while allowing greater full control over the output. An attenuated function that diminishes with distances (usually calculated across the surface of an object) from the seed vertex controls the region impacted by the distortion and the particular amount of

210

Exploration of Computer Graphics

movement in various portions of the item. To create animated form change, seed vertices motion may be keyframed (Thalmann et al., 1996). The term “free-form distortion” (FFD) refers to a more generic kind of deformation (Sederberg and Parry, 1986). The values (s, t, u) of all pertinent points are calculated concerning a localized (for most cases straight line) reference grid that encapsulates the portion of the item to be distorted. The viewer then has complete control over reshaping the grids of net points Pijk into such a new deformed mesh P’ijk (Figure 8.7). Inside the var model analog of B’ezier interpolants, the figure is rebuilt using dimensions calculated in the initial undoctored grid, with deformed lattice points P’ijk acting as command posts in this affirmation (Magnenat-Thalmann et al., 1988): L M N  i   j  k L −i i M− j j ' P(s, u, t) = s ∑ t ∑  (1 − u) N − k u k Pijk ∑  (1 − s) (1 − t) M i 0= i 0 = k 0 N = L

where; L, M, and N are the maximum indices of lattice points in each dimension. In effect, the lattice serves as a low-resolution version of the object for deformation, allowing for a smooth shape change of an arbitrarily complex object through a relatively small number of intuitive adjustments. FFD lattices can themselves be treated as regular objects by the system and can be transformed, animated, and even further deformed if necessary, leading to corresponding changes in the object to which the lattice is attached. For example, moving a deformation tool consisting of the original lattice and distorted lattice representing a bulge across an object results in a bulge moving across the object (Kaul and Rossignac, 1992).

8.5. CHARACTER ANIMATION The most common method for animating articulating models is to use a mix of puts in place and specific deformation methods. At least two major layers are usually included in a figure model designed for animation. The spectator will finally observe the movement of an extremely detailed layer reflecting the character’s exterior shell or coat in the finished output (Capell et al., 2002). The skeletons beneath that are a hierarchical system (a tree) of connections that serves as a kinematic representation of the body and is only utilized for animation. Between both the skeletal and the epidermis are often introduced extra intermediate layer(s) that approximately relate to muscles. Each skeletal joint serves as a parent to the hierarchy underneath it

Computer Animation

211

(Lamousin and Waggenspack, 1994). The roots, which symbolize the entire character, are located in the coordinate frame If a localized transfer function relating joints to their parents in the hierarchy exists, a transition relating the local area of every joint to the global system (i.e., the root system) may be obtained by simply appending transforms along the route from of the roots to the joint. An intensity traverse of the entire tree of the joint is conducted to assess the entire skeleton (i.e., identify the location and orientation among all joints). To assist with this effort, a conversion stack is a logical data model. The present composite matrix is placed onto the stack as the tree descends, and a new one is formed by combining the present matrix with one held at the junction (Debunne et al., 2001). When returning to the parents, the extra conversion should be performed before proceeding to the next branch; this is readily accomplished by emptying the stacks. Even though this basic and easy approach for analyzing hierarchy is used across computer animation, it is referred to as including forward kinematics in animations (and robots) (FK) (Nedel and Thalmann, 1998). While broad expressions for all operations may be utilized, skeletons are often specified using particular model parameters including such path length or range of motion. To animate by forwarding kinematics, all limbs’ rotational properties are dynamically adjusted. The animator may also adjust the spacing between joints (link length) with this approach, but be mindful that this correlates to limb elongation and might seem awkward (Chenney et al., 2002). The user must provide settings including all partner firms in the movements during forwarding kinematics. The majority of such joints, on the other hand, are inner nodes of the hierarchy, and their motion is usually not anything the animator is concerned with. In most cases, the animator just desires them to travel organically “under their own,” and just one is far more interested in knowing the behaviors of the joints chain’s terminus, which generally corresponds to anything executing a particular movement, including an ankle or perhaps the tip of the fingers. The animator would like that the software automatically calculates the settings of all inner joints based on the movement of the output shaft. We can achieve this because of inverse kinematics (IK) (Noble and Tang, 2006). Letting x be the location of the output shaft, and become the vectors of variables required to define all inner joints along with the network from the beginning to the end. The animator may optionally explicitly specify the direction of the last joint, with which event the associated variables are

212

Exploration of Computer Graphics

assumed to include it in the vector x. But, for the sake of simplicity, we’ll write all of the vector’s phrases as follows (Moccozet and Thalmann, 1997): x = (x1, x2, x3)T But each of the factors in x is a function of, the equations x = F(may be represented as vectors equations. If we modify the inner joint settings by a little amount, we may estimate the change x in the location of the output shaft as (Bailey et al., 2020): δ= x

δF δα δa

where; is the Jacobian is a matrix of partial differential equations:  δf1   δα1 δF  δf 2 = δa  δα1  δf  2  δα1

δf1 δα 2



δf 2 δα 2



δf 2 δα 2



δf1   δα n  δf 2   δα n  δf 2   δα n 

We know how it ends the effector’s intended location (specified either by the animator) and, obviously, the effector’s present position at any given time. We can obtain the required adjustment x by combining the two (Hahn et al., 2012). When one inner variable is altered while others stay constant, members of the Jacobian matrix are connected to variations in the coordinates of the output shaft. Geometrical connections may be used to calculate these components for just any given skeletal arrangement. The modifications in input parameters are the only residual unknown factors inside the system of linear equations. We modify = + once we’ve solved both, which provides us with all the knowledge we need for the FK operation to move the skeleton (Kojekine et al., 2002). Furthermore, in most circumstances, the situation could be obtained analytically, and it is also under constrained, meaning that the number of missing internal analytical models exceeds the value of components in vectors x. This implies that multiple skeletal movements might result in much the same end output motion (Noble and Tang, 2007). There are a variety of approaches to getting a particular resolution for these kinds of systems, including those that take into consideration the inherent restrictions that certain real-life joints need (bending knees only in one direction, for example). It’s also worth noting that the calculated Jacobian matrix is only valid for one arrangement and must be updated when the skeletal moves. The IK framework is described in its entirety. The roots joint for IK is not

Computer Animation

213

always the root of the entire hierarchy, and various IK solvers may be used on separate skeleton portions. For example, distinct solutions may be used for the right and left foot (Müller et al., 2002). Yet another, within each base, to aid animate grabbing with both the right side The skeletal is usually animated using a mix of FK and IK techniques. Many popular movements (walking or jogging cyclic, gripping, reaching, and so on) include well sequences of cooperative joint motion, allowing you to rapidly build natural-looking movements or even employ a collection of such “clips.” The animator then tweaks this general outcome to fit the character’s physical specifications and to provide it with more personality (Nieto and Susín, 2013). Whenever a subject’s skeleton moves, it serves as a specific sort of deformer on the subject’s skin. All skin vertices are assigned one (rigid peeling) or even more (smoothness skinning) joint as actuators to transmit motion towards this surface. In the first example, a skin vertex is essentially frozen into the particular region of the relevant joint, which may be the closest in reality or one selected manually (Casti et al., 2018; McLaughlin et al., 2011). The vertices then duplicate the motion that this joint has gone through, and its location in coordinates is computed using the conventional FK technique Hard skinning, despite its simplicity, depends on achieving suitably soft and smooth distortion in places around joints, as well as for more small effects such as respiration or muscle activity. Flexors, which are specialized deformers, may also be employed by the researchers. Smooth skinned allows many joints to impact a skin vertex based on a weight supplied by the animator, giving the animator greater precise control and over output. The ultimate movement of the vertices is calculated by averaging the displaced vectors, di, proposed by multiple joints impacting a specific skin vertex (each calculated using conventional FK) (Escher et al., 1998). d =Σ widi. The most popular are standardized weights (wi = 1), although they aren’t required. Generating smooth-skinned values to produce the desired appearance is a difficult task that requires much talent on the animator’s part (Bickel et al., 2008).

8.5.1. Facial Animation Skeletons are great for animating a subject’s body, but they’re not so great for producing realistic face movement. The explanation for this is that the epidermis of the face image is controlled by muscles that are directly related

214

Exploration of Computer Graphics

to it, as opposed to certain other portions of the body in which the muscular’ main goal is to manipulate the skeleton’s bones and any skin distortion is a side effect (Magnenat-Thalmann and Thalmann, 1990). As a consequence of this physical structure, humans have an extremely diverse spectrum of variable facial gestures that they employ as one of their main means of communication. We’ve all been educated to detect such face changes and can immediately spot anything out of the ordinary. This mostly places unique demands on the animator, but then also takes a high model structure of the face, as well as precise skin reflecting characteristics and texturing if a tool to achieve is needed (Kalra et al., 1992). While it is feasible to specify key positions of both the facial vertices by vertices and linear interpolation among them utilizing physics-based methods, best high ways are also available. A very limited collection of so-called conformation factors (overall size, distance from the eyeball to the forehead, size of the nose, the thickness of the jawline, etc.), are being used to transform general face images into almost particular characteristics, defining the fixed shape of a particular face. To characterize the dynamic form of both the face for animation, an extra set of emotive characteristics may be employed (Anguelov et al., 2005). The stiff spin of the head, the width of the eyes open, the displacement of a region of interest out of its static location, and so on are all examples. These were selected such that the majority of the fascinating emotions can be created by a mixture of parameter modifications, enabling conventional keyframing to be used to animate a facial. To get more control, utilize emotive variables to construct a series of attitudes that correlate to typical emotions (neutral, sorrow, excitement, anger, surprise, etc.), and then combine these essential poses to get a “particularly sad” or “angrily shocked” face (Milliron et al., 2002).

8.5.2. Motion Capture Strategic formulation of figure animation from the beginning, even using the approaches mentioned above, is a difficult undertaking. As a result, systems that capture an actor’s movements in the actual world and afterwards transfer it to software creatures are receiving a lot of attention. Electrostatic and visual motion control methods are the two most used types (You et al., 2009). An electromagnetic detector immediately monitors its location (and perhaps rotation) in 3D during electromagnetic motion tracking, and the acquired data are generally provided in live time. Substantial equipment

Computer Animation

215

costs, probable contamination from surrounding metallic objects, and the size of detectors and battery packs, which might impede executing elevated movements, are all drawbacks of this technology. Rather than sensing devices, tiny colored indicators are utilized in optically MC, making it a far less invasive operation. Because more complex existing algorithms for reliable tracking of numerous indicators using video are generally computationally intensive, such processing is performed offline in most circumstances (Coquillart and Jancene, 1991). Optic monitoring is less reliable than electromagnetic detection. Obstruction of a specific marker in certain frames, probable marker mistaken identity, and picture noise is just a few of the usual issues that must be handled. Adding additional cameras to observe motion from various angles enhances accuracy and resilience, but this strategy is more costly and takes longer to handle such data. As computing power improves and proper computer visual techniques are created, optically MC becomes much more appealing. Optical approaches are suited for sensitive face motion tracking and may also be utilized with items other than people, such as wildlife and even tree limbs in the breeze, due to the minimal effect character of markings (Kazi et al., 2016). A set of time-dependent 3D locations of certain series of points may be captured using many sensors or indicators affixed to a producer’s body. These monitoring sites are often selected near joints; however, they remain on the surface of the skin rather than where real bones connect. As a result, extra caution and processing are required to transform recording locations into those of real skeletal joints. By averaging the positions of two markers on opposing sides of elbows or ankles, for instance, the system may derive a proper joint location. According to misaligned joint placements, natural noise, and poor measurement precision, highly apparent artifacts might occur if special care is not taken. Physiological inaccuracies in mobility, for example, might lead characters’ limbs to cut off contact with items they are meant to touch when walking or gripping, resulting in the skeletal ankle (skate). The majority of these issues may be solved by employing joint angles approaches that explicitly push the limb’s end to behave as it should (Noh et al., 2000). Joint configurations that have been retrieved can now be placed straight to the skeletons of a software figure. This approach presupposes that the subject’s measurements are the same as the performers. Creating targeted recording motion to a new character, and, more broadly, modifying MC information, requires great care to meet certain limitations (such as keeping feet planted or not permitting an arm to bend down) while retaining the

216

Exploration of Computer Graphics

adjusted motion’s entire ecological aspect. Generally, the larger the intended deviation from the source, the more difficult it will be to retain the result’s excellence. Recording a large number of movements and stitching together small clips from such a library to get desirable output is an innovative solution to the challenge. While this is now a highly active field of research, another of the key downsides of the motion control approach is the restricted capacity to modify the captured motions to the artist’s demands (Sumner and Popović, 2004).

Computer Animation

217

REFERENCES 1.

Anguelov, D., Srinivasan, P., Koller, D., Thrun, S., Rodgers, J., & Davis, J., (2005). Scape: shape completion and animation of people. In: ACM SIGGRAPH 2005 Papers (Vol. 1, pp. 408–416). 2. Bailey, S. W., Omens, D., Dilorenzo, P., & O’Brien, J. F., (2020). Fast and deep facial deformations. ACM Transactions on Graphics (TOG), 39(4), 94–1. 3. Barbič, J., Da Silva, M., & Popović, J., (2009). Deformable object animation using reduced optimal control. In: ACM SIGGRAPH 2009 papers (Vol. 1, pp. 1–9). 4. Bechmann, D., & Dubreuil, N., (1993). Animation through space and time based on a space deformation model. The Journal of Visualization and Computer Animation, 4(3), 165–184. 5. Bétrancourt, M., & Tversky, B., (2000). Effect of computer animation on users’ performance: A review/(Effet de l’animation sur les performances des utilisateurs: Une sythèse). Human Labor, 63(4), 311. 6. Bickel, B., Lang, M., Botsch, M., Otaduy, M. A., & Gross, M. H., (2008). Pose-space animation and transfer of facial details. In: Symposium on Computer Animation (Vol. 1, pp. 57–66). 7. Bishko, L., (2007). The uses and abuses of cartoon style in animation. Animation, 2, 24–35. 8. Browning, M., Barnes, C., Ritter, S., & Finkelstein, A., (2014). Stylized keyframe animation of fluid simulations. In: Proceedings of the Workshop on Non-Photorealistic Animation and Rendering (Vol. 1, pp. 63–70). 9. Capell, S., Green, S., Curless, B., Duchamp, T., & Popović, Z., (2002). Interactive skeleton-driven dynamic deformations. ACM Transactions on Graphics (TOG), 21(3), 586–593. 10. Carter, C. P., (2016). In: Bechmann, D., & Dubreuil, N., (eds.), Animated Mise-En-Scene and Aesthetic Harmony: An Expansion of the Traditional Principles of Animation to 3D Computer Animation (Vol. 1, pp. 1–6). Doctoral dissertation, Queensland University of Technology. 11. Casti, S., Corda, F., Livesu, M., & Scateni, R., (2018). CageLab: An interactive tool for cage-based DEFORMATIONS. In: STAG (Vol. 1, pp. 65–74).

218

Exploration of Computer Graphics

12. Chan, Y. M., Choo, K. A., & Woods, P. C., (2013). Youtube videos for learning principles of animation. In: 2013 International Conference on Informatics and Creative Multimedia (Vol. 1, pp. 43–46). IEEE. 13. Chenney, S., Pingel, M., Iverson, R., & Szymanski, M., (2002). Simulating cartoon style animation. In: Proceedings of the 2nd International Symposium on Non-photorealistic Animation and Rendering (Vol. 1, pp. 133–138). 14. Ciccone, L., Öztireli, C., & Sumner, R. W., (2019). Tangent-space optimization for interactive animation control. ACM Transactions on Graphics (TOG), 38(4), 1–10. 15. Coquillart, S., & Jancene, P., (1991). Animated free-form deformation: An interactive animation technique. ACM SIGGRAPH Computer Graphics, 25(4), 23–26. 16. Debunne, G., Desbrun, M., Cani, M. P., & Barr, A. H., (2001). Dynamic real-time deformations using space & time adaptive sampling. In: Proceedings of the 28th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 31–36). 17. Escher, M., Pandzic, I., & Thalmann, N. M., (1998). Facial deformations for MPEG-4. In: Proceedings Computer Animation’98 (Cat. No. 98EX169) (Vol. 1, pp. 56–62). IEEE. 18. Faloutsos, P., Van De, P. M., & Terzopoulos, D., (1997). Dynamic free-form deformations for animation synthesis. IEEE Transactions on Visualization and Computer Graphics, 3(3), 201–214. 19. Fisher, D., (2010). Animation for visualization: Opportunities and drawbacks. Beautiful visualization, 19, 329–352. 20. Garcia, A. L., (2012). Principles of animation physics. In: ACM SIGGRAPH 2012 Courses (Vol. 1, pp. 1–20). 21. Ghani, D. A., & Ishak, S. B. A., (2012). Relationship between the art of Wayang kulit and Disney’s 12 principles of animation. Journal of Research and Social Intervention, 37(1), pp. 144. 22. Haarbach, A., Birdal, T., & Ilic, S., (2018). Survey of higher order rigid body motion interpolation methods for keyframe animation and continuous-time trajectory estimation. In: 2018 International Conference on 3D Vision (3DV) (Vol. 1, pp. 381–389). IEEE. 23. Hahn, F., Martin, S., Thomaszewski, B., Sumner, R., Coros, S., & Gross, M., (2012). Rig-space physics. ACM Transactions on Graphics (TOG), 31(4), 1–8.

Computer Animation

219

24. Hodgins, J. K., O’Brien, J. F., & Bodenheimer, R. E., (1999). Computer animation. Wiley Encyclopedia of Electrical and Electronics Engineering, 3, 686–690. 25. Hong, J. M., & Kim, C. H., (2004). Controlling fluid animation with geometric potential. Computer Animation and Virtual Worlds, 15(3, 4), 147–157. 26. Huang, K. S., Chang, C. F., Hsu, Y. Y., & Yang, S. N., (2005). Key probe: A technique for animation keyframe extraction. The Visual Computer, 21(8), 532–541. 27. Igarashi, T., Moscovich, T., & Hughes, J. F., (2006). Spatial keyframing for performance-driven animation. In: ACM SIGGRAPH 2006 Courses (Vol. 1, pp. 17-es). 28. Izani, M., & Eshaq, A. R., (2003). Keyframe animation and motion capture for creating animation: A survey and perception from industry people. In: Proceedings. Student Conference on Research and Development, 2003: SCORED 2003 (Vol. 1, pp. 154–159). IEEE. 29. Jin, C., Fevens, T., & Mudur, S., (2012). Optimized keyframe extraction for 3D character animations. Computer Animation and Virtual Worlds, 23(6), 559–568. 30. Joshi, P., Tien, W. C., Desbrun, M., & Pighin, F., (2006). Learning controls for blend shape based realistic facial animation. In: ACM SIGGRAPH 2006 Courses (Vol. 1, pp. 17-es). 31. Kalra, P., Mangili, A., Thalmann, N. M., & Thalmann, D., (1992). Simulation of facial muscle actions based on rational free form deformations. In: Computer Graphics Forum (Vol. 11, No. 3, pp. 59– 69). Edinburgh, UK: Blackwell Science Ltd. 32. Kaul, A., & Rossignac, J., (1992). Solid-interpolating deformations: Construction and animation of PIPs. Computers & Graphics, 16(1), 107–115. 33. Kazi, R. H., Grossman, T., Umetani, N., & Fitzmaurice, G., (2016). SKUID: Sketching dynamic drawings using the principles of 2D animation. In: ACM SIGGRAPH 2016 Talks (Vol. 1, pp. 1–1). 34. Kazi, R. H., Grossman, T., Umetani, N., & Fitzmaurice, G., (2016). Motion Amplifiers: Sketching dynamic illustrations using the principles of 2D animation. In: Proceedings of the 2016 CHI Conference on Human Factors in Computing Systems (Vol. 1, pp. 4599–4609).

220

Exploration of Computer Graphics

35. Kojekine, N., Savchenko, V., Senin, M., & Hagiwara, I., (2002). A prototype system for character animation based on real-time deformations. The Journal of Three Dimensional Images, 16(4), 91–95. 36. Kondo, R., Kanai, T., & Anjyo, K. I., (2005). Directable Animation of elastic objects. In: Proceedings of the 2005 ACM SIGGRAPH/ Eurographics Symposium on Computer Animation (Vol. 1, pp. 127– 134). 37. Lamousin, H. J., & Waggenspack, N. N., (1994). NURBS-based freeform deformations. IEEE Computer Graphics and Applications, 14(6), 59–65. 38. Large, A., (1996). Computer animation in an instructional environment. Library & Information Science Research, 18(1), 3–23. 39. Lasseter, J., (1987). Principles of traditional animation applied to 3D computer animation. In: Proceedings of the 14th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 35–44). 40. Magnenat-Thalmann, N., & Thalmann, D., (1990). Human Body Deformations Using Joint-Dependent Local Operators and FiniteElement Theory, 1, 243–262. 41. Magnenat-Thalmann, N., Laperrire, R., & Thalmann, D., (1988). Jointdependent local deformations for hand animation and object grasping. In: Proceedings on Graphics interface’88 (Vol. 1, pp. 1–6). 42. McLaughlin, T., Cutler, L., & Coleman, D., (2011). Character rigging, deformations, and simulations in film and game production. In: ACM SIGGRAPH 2011 Courses (Vol. 1, pp. 1–18). 43. Milliron, T., Jensen, R. J., Barzel, R., & Finkelstein, A., (2002). A framework for geometric warps and deformations. ACM Transactions on Graphics (TOG), 21(1), 20–51. 44. Moccozet, L., & Thalmann, N. M., (1997). Dirichlet Free-form Deformations and Their Application to Hand Simulation (Vol. 1, pp. 93–102). IEEE. 45. Moore, M., & Wilhelms, J., (1988). Collision detection and response for computer animation. In: Proceedings of the 15th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 289– 298). 46. Müller, M., Dorsey, J., McMillan, L., Jagnow, R., & Cutler, B., (2002). Stable real-time deformations. In: Proceedings of the 2002 ACM

Computer Animation

47.

48.

49. 50.

51. 52.

53.

54.

55.

56.

57.

221

SIGGRAPH/Eurographics Symposium on Computer Animation (Vol. 1, pp. 49–54). Multon, F., France, L., Cani‐Gascuel, M. P., & Debunne, G., (1999). Computer animation of human walking: A survey. The Journal of Visualization and Computer Animation, 10(1), 39–54. Nedel, L. P., & Thalmann, D., (1998). Real time muscle deformations using mass-spring systems. In: Proceedings: Computer Graphics International (cat. no. 98ex149) (Vol. 1, pp. 156–165). IEEE. Nieto, J. R., & Susín, A., (2013). Cage based deformations: A survey. In: Deformation Models (Vol. 1, pp. 75–99). Springer, Dordrecht. Noble, P., & Tang, W., (2006). Automatic expressive deformations for stylizing motion. In: Proceedings of the 4th International Conference on Computer Graphics and Interactive Techniques in Australasia and Southeast Asia (Vol. 1, pp. 57–63). Noble, P., & Tang, W., (2007). Automatic expressive deformations for implying and stylizing motion. The Visual Computer, 23(7), 523–533. Noh, J. Y., Fidaleo, D., & Neumann, U., (2000). Animated deformations with radial basis functions. In: Proceedings of the ACM Symposium on Virtual Reality Software and Technology (Vol. 1, pp. 166–174). Pambudi, S., Hidayatulloh, I., Surjono, H. D., & Sukardiyono, T., (2021). Development of instructional videos for the principles of 3D computer animation. In: Journal of Physics: Conference Series (Vol. 1737, No. 1, p. 012022). IOP Publishing. Prasasti, F. D., Situmorang, R., & Kusumawardani, D., (2018). Development of integrated audiovisual module for learning animation principles at multimedia vocational school. International Journal of Education, Information Technology, and Others, 1(2), 55–69. Pullen, K., & Bregler, C., (2002). Motion capture assisted animation: Texturing and synthesis. In: Proceedings of the 29th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 501– 508). Ram, S. S., & Ling, H., (2008). Simulation of human microDopplers using computer animation data. In: 2008 IEEE Radar Conference (Vol. 1, pp. 1–6). IEEE. Reeves, W. T., (1981). Inbetweening for computer animation utilizing moving point constraints. ACM SIGGRAPH Computer Graphics, 15(3), 263–269.

222

Exploration of Computer Graphics

58. Reynolds, C. W., (1982). Computer animation with scripts and actors. ACM SIGGRAPH Computer Graphics, 16(3), 289–296. 59. Riwinoto, R., (2020). A study on the model of animation style using PCAF. Journal of Applied Multimedia and Networking, 4(1), 64–73. 60. Salomão, A., Vieira, M. L. H., Romeiro, N. C., & Nassar, V., (2021). Theorized work for adapting the principles of animation to virtual reality as a new form of narrative for 3D animation. In: VISIGRAPP (1: GRAPP) (Vol. 1, pp. 308–312). 61. Sloan, R., Martinez, S., & Scott-Brown, K., (2012). Using the principles of animation to predict allocation of attention. In: Predicting Perceptions: Proceedings of the 3rd International Conference on Appearance (Vol. 1, p. 133). Lulu. com. 62. Steketee, S. N., & Badler, N. I., (1985). Parametric keyframe interpolation incorporating kinetic adjustment and phrasing control. In: Proceedings of the 12th Annual Conference on Computer Graphics and Interactive Techniques (Vol. 1, pp. 255–262). 63. Sultana, N., Peng, L. Y., & Meissner, N., (2013). Exploring believable character animation based on principles of animation and acting. In: 2013 International Conference on Informatics and Creative Multimedia (Vol. 1, pp. 321–324). IEEE. 64. Sumner, R. W., & Popović, J., (2004). Deformation transfer for triangle meshes. ACM Transactions on Graphics (TOG), 23(3), 399–405. 65. Terra, S. C. L., & Metoyer, R. A., (2004). Performance timing for keyframe animation. In: Proceedings of the 2004 ACM SIGGRAPH/ Eurographics Symposium on Computer Animation (Vol. 1, pp. 253– 258). 66. Terra, S. C. L., & Metoyer, R. A., (2007). A performance-based technique for timing keyframe animations. Graphical Models, 69(2), 89–105. 67. Thalmann, D., Shen, J., & Chauvineau, E., (1996). Fast realistic human body deformations for animation and VR applications. In: Proceedings of CG International’96 (Vol. 1, pp. 166–174). IEEE. 68. Thesen, T. P., (2020). Reviewing and updating the 12 principles of animation. Animation, 15(3), 276–296. 69. Thompson, J., Liu, Z., Li, W., & Stasko, J., (2020). Understanding the design space and authoring paradigms for animated data graphics. In:

Computer Animation

70.

71.

72.

73.

74.

75.

76.

223

Computer Graphics Forum (Vol. 39, No. 3, pp. 207–218). Togawa, H., & Okuda, M., (2005). Position-based keyframe selection for human motion animation. In: 11th International Conference on Parallel and Distributed Systems (ICPADS’05) (Vol. 2, pp. 182–185). IEEE. Treuille, A., McNamara, A., Popović, Z., & Stam, J., (2003). Keyframe control of smoke simulations. In: ACM SIGGRAPH 2003 Papers (Vol. 1, pp. 716–723). Van, B. A. J. N., (2004). Bringing robots to life: Applying principles of animation to robots. In: Proceedings of Shaping Human-Robot Interaction Workshop Held at CHI (Vol. 2004, pp. 143–144). Weir, G. R., & Heeps, S., (2003). Getting the message across: Ten principles for web animation. In: 7th IASTED International Conference on Internet and Multimedia and Applications (IMSA 2003) (Vol. 1, pp. 121–126). Wheatland, N., Wang, Y., Song, H., Neff, M., Zordan, V., & Jörg, S., (2015). State of the art in hand and finger modeling and animation. In: Computer Graphics Forum (Vol. 34, No. 2, pp. 735–760). You, L. H., Chaudhry, E., You, X. Y., & Zhang, J. J., (2009). Physics and example-based skin deformations for character animation. In: 2009 11th IEEE International Conference on Computer-Aided Design and Computer Graphics (Vol. 1, pp. 62–67). IEEE. Zhang, X., & Van De, P. M., (2018). Data-driven autocompletion for keyframe animation. In: Proceedings of the 11th Annual International Conference on Motion, Interaction, and Games (Vol. 1, pp. 1–11).

INDEX

A Affine transform 56 Algorithmic animation 198 Aliasing 40 analogy 62 Animation 3 Antialiasing 40, 41 application program interface (API) 6 Automated curve-fitting systems 206 B binary hardcopy 155 C C# 81, 82, 83, 84, 85, 87 C++ 81, 83, 85 Computational Photography 4 computed tomography (CT) 5 computer 196, 198, 199, 201, 202, 211, 215, 217, 220, 221 Computer-aided design (CAD) 5 Computer-aided manufacturing (CAM) 5

computer-generated imagery 201 computer graphics 2, 3, 4, 5, 8, 17, 19, 27, 28, 29, 30, 31, 32, 33, 34, 35 computer graphics technology 4 computer hardware 2 Consumer Interaction 3 continuity 204, 205 coordinate conversion 53 curves 79, 89 D debugging 78 demosaicking 161 digital animation 196, 197 digital picture 38 dots per inch (DPI) 159 E electromagnetic detection 215 ellipses 48 Emissive display 155 F file formats 2, 20 films 96

226

Exploration of Computer Graphics

flatbed scanner 155, 161 free-form distortion\” (FFD) 210 G geometric transformations 56 Glossiness 98 graphic design 96, 116 graphics programming 12 graphics programs 52 graphics software 7, 13, 15 GraphPaper 85, 86 gripping 213, 215 H hierarchical planning 58 high dynamic range (HDR) 164 human behavior 196 I Illumination 96 Image Processing 3, 27, 29, 33 image processing software 161 image processing system 179 image sensor 154, 160, 162 index triangular mesh 183 inorganic semiconductors 156 integrated development environment (IDE) 81 interaction 79, 80, 86 J Java 38, 63, 64, 65, 66, 67, 69, 71 K KeyDownHandler 86 L learning coordinate systems 38 level of detail (LOD) 9

light-emitting diode (LED) 155 Lighting 96, 106, 109 lighting vertex shader 141 light-sensitive semiconductor 160 linear transformation 56 line segment 46, 51 living things 196 low dynamic range (LDR) 164 M marketing 96 mathematical analysis 79 Medical Imaging 5 mesh modification 179 mesh reduction 179 Motion 196, 198, 206, 214, 219, 221, 223 mouse rotation 143 N normal vectors 140, 141, 142 O Optic monitoring 215 overlapping 200, 201 P pairwise information 179 photograph 54 photon 101 Pixels 39, 42 pixels per inch (PPI) 161 pressure 200 printer resolution 159 programming language 64 projection transformation 137 pseudocode 38, 48, 49, 61

Index

227

R

T

raster devices 154, 155, 157, 172, 173, 175 realism 96 Real light 100, 101 Real-number coordinates 64 real skeletal joints 215 Rectangular meshes 178 red, green, and blue (RGB) 100 robotic mechanical motion 200 row spacing 157

texture 103, 113, 114, 115, 116, 126 Texture coordinates 114 three-dimensional scanning 4 three-dimensional transformations 136 topology 180 transmissive display 155 triangle irregularity networking (TINs) 179 Triangular meshes 179 two-dimensional transformations 136

S segmentation 179, 187 semiconductor devices 156 shader program 138, 139, 146, 147 shrinking 200 skeletal ankle 215 Skeletons 213 Squeezing 201 stunning computer animations 2 sunlight 96, 99, 100

V vector pictures 155 video games 96, 129 virtual reality 3 Visualization 3, 6, 16, 33 vocabulary 2 W web page 136, 137, 143