Lecture Notes in Computer Science Edited by G. Goos and J. Hartmanis
421 Tamiya Onodera Satoru Kawai
A Formal Model of...
26 downloads
925 Views
3MB Size
Report
This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!
Report copyright / DMCA form
Lecture Notes in Computer Science Edited by G. Goos and J. Hartmanis
421 Tamiya Onodera Satoru Kawai
A Formal Model of Visualization in Computer Graphics Systems
Springer-Verlag Berlin Heidelberg NewYorkLondon ParisTokyoHong Kong
Editorial Board D. Barstow W. Brauer P. Brinch Hansen D. Gries D. Luckham C. Moler A. Pnueli G. Seegmeller J. Stoer N. Wirth Authors Tamiya Onodera IBM Research, Tokyo Research Laboratory 5-19, Sanban-cho, Chiyoda-ku Tokyo 102, Japan Satoru Kawai Department of Graphics and Computer Science The College of Arts and Sciences, The University of Tokyo 3-8-1, Komaba, Meguro-ku Tokyo 153, Japan
CR Subject Classification (1987): 1.3.4 ISBN 3-540-52395-2 Springer-Verlag Berlin Heidelberg New York ISBN 0-387-52395-2 Springer-Verlag NewYork Berlin Heidelberg
Thiswork is subjectto copyright.All rightsare reserved,whetherthe wholeor part of the material is concerned,specificallythe rights of translation,reprinting,re-useof illustrations,recitation, broadcasting,reproductionon microfilmsor in otherways,and storagein databanks.Duplication of this publicationor partsthereofis onlypermittedunderthe provisionsof the GermanCopyright Law of September9, 1965,in its versionof June 24, 1985,and a copyrightfee must a}waysbe paid. Violationsfall underthe prosecutionact of the GermanCopyright Law. cOSpringer-VerlagBerlin Heidelberg 1990 Printed in Germany Printing and binding: DruckhausBeltz, Hemsbach/Bergstr. 2145/3140-543210- Printed on acid-freepaper
Preface
The field of computer graphics has expanded rapidly during the last decade. It provides a comprehensive way for computers and human beings to communicate, and is indispensable in modern computer systems. In order to facilitate the building of such systems, the kernel systems of computer graphics are designed and implemented to provide programmers with a set of fundamental graphics functions for producing pictures.
Visualizalion refers to the total process of transforming graphical objects from system-specified representations into their final representations. Unfortunately, visualization in conventional kernel systems is only poorly described: the specification documents are incredibly thick and most of the essential parts are written in natural language, relying on the incomplete framework of a viewing pipeline. The model of a viewing pipeline is insufficient, since it models only the viewing process, ignoring the important process of attribute rendering of graphical objects, and does not define the central concept of graphical output primitives. Moreover, the diversity of standards and proposed standards by the ISO for kernel systems embarrasses the computer graphics community, since we do not have a model on which two standards can be compared. All of these problems motivate the construction of a general, concise, and formal model of visualization. The main purpose of this book is to present a formal model of visualization called a visualizing
ne~. We give the model in a unified and axiomatic manner based on the mathematical concept of correspondence, which is a general form of mapping. Surprisingly, various attribute rendering processes, including pattern filling, are described there in a uniform way, and graphical output primitives are defined as mappings from finite generable objects. A visualizing net is a concise model that not only allows an unambiguous and comprehensive description of systems but can also be the center of the documentation. In addition, a visualizing net is far more general than a viewing pipeline. This implies that all visualizations in conventional kernel systems can be described by means of a visualizing net: we do so in Section 3.3. This book is primarily intended for students or researchers interested in the formal aspects of computer graphics, which have been paid little attention by most researchers. One reason is that the research done so far in this field is not closely linked to actual systems.
IV We try in this book to link the model to reality. That is, we present the design and implementation of a kernel system called a graphics nucleus, which provides the full functionality of a visualizing net. The system is based on one general and expressive drawing technique, called geometry-driven drawing, which is the consequence of our abstraction of attribute rendition. For instance, it can draw roads or railways as simply as dotted lines. Kernel system designers can also benefit from our work, since it contains a discussion of what a kernel system should be and expresses a view on how to avoid building complex, hopeless systems. Chapter 2 will be helpful for those who are interested in correspondence, since it contains indepth discussions on this subject, which has hitherto received far less attention than mapping or functions. Familiarity with computer graphics kernel systems and with first-order logic is assumed. Acknowledgements We are thankful to Messrs. T. Kamada, S. Matsuokz, H. Morishima, and C. Lee of the Kawai Laboratory of the University of Tokyo for their helpful discussions and valuable criticisms. We would also like to express my gratitude to Mr. H. Yokouchi of IBM Research, Tokyo Research Laboratory for his mathematical suggestions. Finally, We are grateful to Mr. McDonald of IBM Research ' Tokyo Research Laboratory for his careful proof-readlng.
Tokyo, Jauuary 1990
Tamiya Onodera Satoru Kawai
Co~e~s
Introduction 1.1
The Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1.2
O v e r v i e w s of C o m p u t e r G r a p h i c s S y s t e m s . . . . . . . . . . . . . . . . . . . . . . .
3
1.2.1
Output Primitives and Primitive Attributes ..................
3
1.2.2
Viewing Pipeline
6
1.2.3
Picture Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
1.3.1
Specifying GKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
1.3.2
Mallgren's Specification
1.3.3
Detailed Viewing Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
1.3.4
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
1.3
2
Mathematical
..............
. . . . . . . . . . . . . . . . . . .
10
..............................
Framework
2.1
Correspondences
2.2
O p e r a t i o n s on C o r r e s p o n d e n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16
2.3
Equalities
17
2.4
E x t e n s i o n s of C o r r e s p o n d e n c e s
Formal 3.1
Model
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
21
of Visualization
F o r m a l i z a t i o n of B a s i c C o n c e p t s in C o m p u t e r G r a p h i c s
...............
25
. . . . . . . . . . . . . . . . . . . . .
25
3.1.1
Pictures and Picture Transformations
3.1.2
Picture Sum
3.1.3
G e o m e t r i e s a n d G e o m e t r y 3_-'ransformations . . . . . . . . . . . . . . . . . .
26
3.1.4
Geometric Transformations
27
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
26
CONTENTS
VI
4
Restrictive T r a n s f o r m a t i o n s . . . . . . . . . . . . . . . . . . . . . . . . . . .
27
3.1.6
Replications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27
3.].7
Pictorializing T r a n s f o r m a t i o n s
. . . . . . . . . . . . . . . . . . . . . . . . .
28
3.1.8
Firite Ordered Geometries
. . . . . . . . . . . . . . . . . . . . . . . . . . .
28
3.1.9
Equalities
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
31
3.2
Visualizing Nets
3.3
Specifying V i s u a l i z a t i o n s in C o n v e n t i o n a l S y s t e m s 3.3.1
Polyline in G K S
3.3.2
P o l y m a r k e r in G K S
3.3.3
Line in P o s t s c r i p t
..............
; . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
33 34
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
35
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
36
3.3.4
Fill A r e a ]'n G K S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
36
3.3.5
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
39
Graphical 4.1
5
3.1.5
Nucleus
G e o m e t r i c a n d Pictorial P r i m i t i v e s . . . . . . . . . . . . . . . . . . . . . . . . . . .
41
4.1.1
F o r m a l i z a t i o n of G r a p h i c a l P r i m i t i v e s
. . . . . . . . . . . . . . . . . . . . .
41
4.1.2
S o u n d P r o p e r t y of P r i m i t i v e s . . . . . . . . . . . . . . . . . . . . . . . . . .
43
4.2
Graphical Nucleus
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
44
4.3
I m p l e m e n t a b i l i t y of a G r a p h i c a l N u c l e u s . . . . . . . . . . . . . . . . . . . . . . . .
44
4.4
Optimization Considerations
47
Implementation
of a Graphical
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Nucleus
5.1
G e o m e t r i c a n d Pictorial P r i m i t i v e s in p N u d e u s
. . . . . . . . . . . . . . . . . . . .
49
5.2
R e p r e s e n t a t i o n of Visualizing Nets
. . . . . . . . . . . . . . . . . . . . . . . . . . .
50
5.3
Geometries and Geometry T~ansformations
. . . . . . . . . . . . . . . . . . . . . .
51
5.3.1
Restrictive G e o m e t r i e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
51
5.3.2
Geometries
51
5.3.3
Geometry Transformations
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
52
CONTENTS 5.4
5.5
5.6
Pictures and Picture Transformations
. . . . . . . . . . . . . . . . . . . . . . . . .
53
5.4.1
Pictures and Picture Naming
. . . . . . . . . . . . . . . . . . . . . . . . . .
53
5.4.2
Picture Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
55
Pictorializing Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
56
5.5.1
Pictorializing a Point Geometry . . . . . . . . . . . . . . . . . . . . . . . . .
56
5.5.2
Pictorializing a Lattice Geometry . . . ~ . . . . . . . . . . . . . . . . . . . .
57
5.5.3
P i c t o r i a l i z i n g a Line G e o m e t r y
. . . . . . . . . . . . . . . . . . . . . . . . .
58
Backend Display Function -- peval . . . . . . . . . . . . . . . . . . . . . . . . . . .
60
Extending
7
VII
a Graphical
Nucleus
6.1
Simulating a Conventional Graphics Interface
. . . . . . . . . . . . . . . . . . . . .
6.2
Picture Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
65
6.3
Generalized Texts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
66
Conclusion
63
69
Appendices
75
Appendix
A
Proofs
of Propositions
Appendix
B
pNucleus
Reference
and
Theorems
77
Manual
B.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
85
B.2
Starting the pNucleus System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
85
B.3
Functions
85
B.4
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.3.1
Control Functions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
86
B.3.2
Graphical Functions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
87
B.3.3
Utility Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
89
F o r m a l S y n t a x of t h e p N u c l e u s S y s t e m . . . . . . . . . . . . . . . . . . . . . . . . .
90
B.4.1
Basic Data Types
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
90
B.4.2
Geometries
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
90
CONTENTS
VIII
B.5
B.4.3
Pictures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
91
B.4.4
Invoking Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . .
91
Examples
Appendix
C
.........................................
Implementation
92
I s s u e s ~n p N u ¢ l e u s
C.1
Sectioning a Line Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C.2
Transformations for Mapping a Rectangle onto a Quadrangle C.2.1
xy-Ttansformation . . . . . .
C.2.2
Two-Dimensional Projective Transformatioa
Bibliography
95 ............
.......................... .................
96 96 97
99
List of Figures
1.1
Typical o u t p u t primitives
1.2
GKS viewing pipeline
1.3
P H I G S viewing pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1
Divergent a n d convergent correspondences . . . . . . . . . . . . . . . . . . . . . . .
16
2.2
C o r r e s p o n d e n c e for illustrating Proposition 3 . . . . . . . . . . . . . . . . . . . . .
19
2.3
Correspondences for illustrating the equality in T h e o r e m 1 . . . . . . . . . . . . . .
20
2.4
C o r r e s p o n d e n c e s for illustrating the equality ix T h e o r e m 2 . . . . . . . . . . . . . .
21
2.5
Diagram representing b o t h sides in the equality of T h e o r e m 4 . . . . . . . . . . . .
23
3.1
Picture t r a n s f o r m a t i o n derived from a divergent correspondence
26
3.2
Replication defined by three survergent correspondences
3.3
................................
5
..................................
7 7
..........
28
..............
Intrusion of a geometric t r a n s f o r m a t i o n into a restrictive t r a n s f o r m a t i o n w h e n t h e application order is reversed
.............................
30
3.4
P a t t e r n generation when Dom rl 5& Dora p . . . . . . . . . . . . . . . . . . . . . . .
32
3.5
Visualizing net
33
3.6
Visualizing net of GKS polyline
3.7
Effects of two different restrictive t r a n s f o r m a t i o n s of polyline
3.8
Visualizing net of GKS polymarker
3.9
Effects of two different restrictive t r a n s f o r m a t i o n s of polymarker
..................................... ............................ ............
35
.....................
.....
36
.........
37
...........................
3,10 Visualizing net of Postscript line 3.11 Visualizing net of GKS fill area
34
.
.
.
.
.
.
.
.
.
4.1
E x a m p l e s of geometric primitives
4,2
Soundness of geometric ~nd pictorial primitives
5.1
Region specified by the expression in Example 5.1
.
.
.
.
37 .
.
.
.
.
.
........................... ...................
..................
.
.
.
.
.
.
.
.
.
38
42 43
52
LIST OF TABLES
X 5.2
Picture to which the name *h is assigned
5.3
Pictorialization of a Point Geometry . . . . . . . . . . . . . . . . . . . . . . . . . .
57
5.4
Pictorialization of a Lattice Geometry
58
5.5
Development of Secfiors
5.6
Pictorialization of a Line Geometry
6.1
Conventional picture storing by pNucleus
7.1
Pictorializaiton of a line geometry
7.1
Pictorializaiton of a line geometry (continued) . . . . . . . . . . . . . . . . . . . . .
72
7.2
Pictorialization of a polygon geometry
73
C.1
Determining section height vectois . . . . . . . . . . . . . . . . . . . . . . . . . .
96
C.2
Pictorialization of a line geometry by two-dimensional projective -transformation
98
.........................
................................
List
1.1
.......................
..........................
.......................
...........................
........................
54
59 60
66
71
of Tables
GKS primitives with p a r a m e t e r s supplied in the invocation and with basic attributes controlling their appearances
..............................
2.1
Results of applying correspondence operations
B.1
Data type notation
....................
...................................
4
18
86
Chapter
1
Introduction
Visualization in a kernel system for computer graphics refers to the total process of transforming of graphical objects from system-specified representations into their final visuM representations. The visualizations of graphical objects in conventional kernel systems have been described in the form of natural language documents which rely on the ambiguous and incomplete framework of a
viewing p@eline [8,9,11,10], but not on the basis of any formal model. The reason why the viewing pipehne is insufficient as a model of a visuahzation is that it literally models only the viewing process of the system: it does not contain the important process of
attribute rendering of graphical objects. Moreover, graphical objects are supposed to be subject to successive transformations in the viewing pipeline model, but these objects and transformations are left ambiguous and are defined merely in an intuitive manner. In general, a well-established model is indispensable for an unambiguous 'and' comprehensive description of a system. The main purpose of this book is to present a formal model of visualization, called a visualizing net. We also introduce a new graphics system called a graphical nucleus. The system is designed directly with the framework of a visualizing net. The treatment of graphical objects is much freer and the organization of transformations within it is variable.
1.1
The Outline
The rest of this chapter overviews conventional graphics kernel systems and related work on formal approaches to computer graphics systems. Chapter 2 presents the mathematical framework for our model of visualization. The basic concept
is correspondence, which is the most general form of mapping. We pay much attention to one-tomany correspondences: these play an important role in the book. We consider the usual operations, such as composition and inverse, and less common, such as restriction, domain-priority-sum and image-priority-sum. Three extensions of a correspondence are given: one for the power set of its domain, the second for the closure of its domain, and the third for a correspondence space. We also present theorems and many equalities, some of which are used in subsequent chapters.
2
CHAPTER 1. INTRODUCTION
Chapter 3 is the main chapter of this volume. It contains the definition of a visualizing net. We begin the chapter by formahzing basic concepts in computer graphics. First, we identify the two distinct objects of geometry and ?icf~tre. The former is defined to be a partial mapping whose domain and range are a subset of Euclidean space and a set of reasonable values, respectively. The latter is defined to be a subset of Euclidean space. Geometric ~ransforma~ions and restrictive
transformations (clippings) are defined for each of the two. Second, we clarify the concept of attribute rendering, which has been ignored in conventional viewing pipelines. It is treated as what we call a pic*orializing ~ransformalion, which turns a geometry into a picture by repeatedly transforming and pasting a given pattern picture 'along' a given geometry. We continue by defining a visualizin9 ne~ to be any direct acyclic graph that generates a picture and is composed of the abovementioned transformations. This implies that the organization of component transformations is not fixed. The chapter also analyzes visualizing processes of graphical primitives in conventional kernel systems in terms of the model of a visualizing net, detecting overlooked ambiguities and insufficiencies. All of these are presented in a unified and axiomatic manner upon the mathematical framework established in Chapter 2. For instance, geometric transformations and restrictive transformations, which appear inherently different, are formalized within the same framework. In addition, relations recognized in graphics system are concisely formulated and are vafidated with a few definitions and theorems. Chapter 4 shows a new graphics system called a gvaphica~ nucleus, which is designed within the framework of the visualizing net and therefore inherits much generality and flexibility from the model. Before showing the definition of the system, we define graphical output primitives as geometric primitives and pictorial primitives, which are mappings from finitely generable objects to geometries or pictures. A formal study of the implementability of a graphical nucleus is also made.
Chapter 5 describes the reahzation of a prototype of a graphical nucleus called pNucleus. The system is written in Franz Lisp. The representations of a visualizing net and of the objects within it are elucidated. Chapter 6 examines possible extensions of the pNucleus system. The topics include simulating functional interface as in GKS, reafizing more general picture storage, and what we call generalized text. A visualizing net is a transparent in the sense that its user can access the intermidate results in the net, modify them and give them to another visualizing net. Together with the organization
1.2. OVERVIEWS OF COMPUTER GRAPHICS SYSTEMS variability this intermidate result accessibility make the system very extensible. Chapter 7 presents our conclusions. Appendix A presents the proofs of propositions and theorems in Chapter 2. Appendix B and Appendix C contain a reference manual for pNucleus and the implementation details of the system, respectively. The manual contains a description of the functions provided by pNucleus and of its syntax. The implementation details given in Appendix C are all related to the pictorializing transformation tht handles a line. The model we present in this volume gives guidance in and suggests the possibility of a newgeneration computer graphics system. For instance, we describe a new method of drawing, which may be called a geometry-driven drawing. It is done by formalizing the sets of attributes simply as pictures and by abstracting pictorializing transformations from various attributes renditions; conventional systems just give each graphical primitive a speciahzed set of attributes and a separate description of attribute rendition. We also show the possibility of treating geometries and pictures as freer data by allowing any valid sequence of any transformations. We believe that these indicate the right direction for the development of graphics systems. 1.2
O v e r v i e w s of C o m p u t e r G r a p h i c s S y s t e m s
This section overviews the output features of conventional graphics systems. It wa not until the advent of the Core system [8] that concepts in computer graphics were organized as an integrated system. Most of these concepts were inherited by GKS [9], the internationM standard for twodimensional computer graphics systems, although some were reorganized, refined, or newly added. PHIGS [11] was designed on the principle that it should be as compatible with GKS as possible. In CGI [10] the device interface specification is based on the GKS workstalion interface. (Workstations are an abstraction of physical devices with input and/or output capabilities. GKS incorporates physical devices, such as refresh tube, storage tube, plotter, and even sequential file for long-term filing, as workstations, so that they are controlled by a uniform logical interface - - the workstation interface. The system can support multiple workstations at the same time.) Conventional systems therefore have much in common, and it is possible to describe the output features of any of these systems with few particulars of the specific system. Note that we follow the descriptions given in the documents specifying the above systems. 1.2.1
Output Primitives and Primitive Attributes
In conventional systems, pictures are considered to be drawn as a collection of graphical output
primitives. Their visuM representations are controlled by corresponding sets of output primitive
4
C H A P T E R 1. I N T R O D U C T I O N
GKS Primitive polyline
Parameters
Basic Attributes
number of points
linetype"
points
fine width scale factor* polyline color index*
polymarker
number of points
marker type*
points
marker size scale factor" polymarker color index"
text
text position
text font and precision*
character string
character expansion factor" character spacing* text color index* character height character up vector text path text alignment
fill area
number of points
fill area interior style*
points
fill area style index* fill area color index* pattern size pattern reference point
Table 1.1: GKS primitives with parameters supplied in the invocation and with basic attributes controlling their appearances
attributes that are defined for each primitive. Table 1.1 contains GKS output primitives together with parameters supplied in the invocation of a primitive and basic attributes applied to a primitive. These primitives are drawn in Figure 1.1 with three different settings of attributes.
Some attributes are not contained in the table. They are called aspect source flags, and are related to the methods of specifying the values of the attributes marked by asterisks in the table: these attributes can be either directly given independently of workstations or indirectly obtained via the bundle table for that primitive in each workstation. Each workstation has four bundle tables: a polyfine bundle table, a polymarker bundle table, a text bundle table, and a fill area bundle table.
1.2. OVERVIEWS OF COMPUTER GRAPHICS S Y S T E M S
~////
~
5
/ /\ \ / / /
(a) polyline *
+ *
*
"k +
+
,k' ,k
(b) polymarker
abc
abc (e) text
(d) fillarea Figure 1.1: Typical output primitives
abc
/
6
CHAPTER 1. INTRODUCTION
The elements in these tables, called bundles, consist of the attributes marked by asterisks. For example, the polyline primitive has three aspect source flags - - the liuetype ASF, the line-width scale factor ASF, and the polyline color index ASF - and one more attribute, called a polyline bundle table index. If the value of the linetype ASF is BUNDLED,the actual value of the linetype is obtained through the bundle table element indexed by the polyline bundle table index. Otherwise, the value of the linetype ASF is INDIVIDUAL, and the actual value of the Iinetype is simply the value of the attribute of linetype. GKS originally allowed only bundle specification for primitive attributes. Bundle tables are similar to color lookup tables, which most devices had when GKS was being designed. The lookup table allows concise specification of colors: a color is specified by an index, not by a set of three values of red, green, and blue. In addition, since such devices usually store color lookup table indices in a frame buffer and since these indices are interpreted by harware, any change to a table entry (not to a frame buffer) is immediately reflected in drawings on the display screen. The designers of GKS wanted to allow users to do this when specifying other attributes. However, most devices in those days were designed to be compatible with the predecessor of GKS, or Core, which allows only individual specification. A compromise was therefore made and the system became more complex. Similar output primitives are provided by other conventional systems with similar sets of attributes, although PHIGS covers three-dimensional graphics and CGI has additional complicated primitives and more detailed sets of attributes, since it deals with devices from low-end to high-end. 1.2.2
Viewing Pipeline
Conventional systems give users the following model or notion about their inner processing for the visualization of output primitives:
When the user invokes an output primitive, he or she is supposed to pass the primitive together with its attributes into a vie~oing pipeline, through which the primitive (or in complex cases, even some of its attributes) is subject to a sequence of transformations. The primitive is then successively refined by the values of its attributes into a visual representation. Figures 1.2 and 1.3 show the viewing pipeline in GKS and in PHIGS, respectively. There are two major components in a viewing pipeline: geometric transformation and clipping [15].
Geometric transformations, as the name implies, geometrically transforms a primitive. We can
1.2.
O V E R V I E W S OF C O M P U T E R GRAPHICS S Y S T E M S
7
I WC Normalization Transformation
I NDC
Clipping Rectangle Stored
non-s~;gment segment
INDC
Segment Transformation
I NDC Workstation Transformation I DC
Clipping
Figure 1.2: GKS viewing pipeline
~
t WC al and Global Modeling Transformation]
I NDC
Viewing Transformation I NDC Viewing Projection I NDC
Workstation Mapping I DC Figure 1.3: PHIGS viewing pipeline
q
8
CHAPTER 1. INTRODUCTION
identify three types of geometric transformation in a viewing pipeline, depending on how we specify them:
1. Window-io-viewpori mappings are specified by two rectangles called a window and a viewport. In general, both are parallel to the coordinate axes.
2. Imagings are specified directly by a matrix or by a combination of three primitive imagings of translation, scaling, and rotation.
3. Projections are specified by a set of viewing parameters such as the view reference point, the view plane normal~ and the view up vector. Alternatively, geometric transformations can be seen in terms of the concepts of the coordinate systems provided by a graphics system. The type, the domain coordinate system, and the range coordinate system of a geometric transformation are closely related to its graphical semantics in a system. For example, GKS has three coordinate systems, which are the world coordinate system (WC), ~he normalized device coordinate system (NDC), and the device coordinate system (DC). It provides three types of geometric transformation: normalization transformations are window-to-viewport mapping from WC to NDC, segment transformations are imaging from NDC to NDC, and workstation transformations are window-to-viewport mapping from NDC to DC. PHIGS has five coordinate systems, which are the modeling coordinate system (MC), the world coordinate system (WC), the viewing coordinate system (UVN), the normalized projection coordinate system (NPC), and the device coordinate system (DC). It provides five types of geometric transformations: local modeling transformations and global modeling transformations are imaging from MC to WC, viewing transformations are window-to-viewport mapping from WC to UVN, viewing projections are projection from UVN to NPC, and workstation mappings are window-toviewport mapping from NPC to DC. Clipping removes parts of primitives ~hat lie outside a given region. Generally speaking, clipping follows geometric transformation. The clipping boundary is often obtained from the preceding geometric transformation. The normalization transformation and the workst:Ltion transformation in GKS are both followed by clipping against their viewport. The workstation transformation in PHIGS is followed by clipping against its viewport, and the viewing projection by clipping against the view volume.
1.2.3
Picture Storage
Every conventional system includes a storage, which is considered to be placed between a certain
1.3. RELATED W O R K
9
two adjacent component transformations in the viewing pipeline. The very position of the storage splits the viewing pipeline into two parts. The system can process graphical objects in the viewing pipeline, building up the intermediate result in the storage from the first part of the viewing pipeline. The group of graphical objects in the storage is given a name, referred to by this name, and manipulated as a whole. Such a group is called a segmenl in GKS and Core, or a s~ruc~ure in PHIGS. Different systems provide different functions for picture-storing facilities. PHIGS allows the nesting and editing of a group, while the other systems do not. Screen update is realized by these picture-storing facilities. For instance, the storage in GKS is located between the "clipping rectangle stored" and "segment transformation" shown in Figure 1.2. This implies that screen updates occur when the setting of the workstation transformation changes. There are many other events that cause screen update: change of a segment transformation, change of a bundle representation, and so on. Screen update may be performed 'immediately' after some events when the required facifities are reafized by hardware. After other events, it may be performed by the software routine that retrieves the stored pictures one by one and processes them in the latter part of the viewing pipeline. This is called implicit regeneration. Since this is usually a time-consuming process, the system provides an option as to whether the implicit regeneration should be 'allowed' or 'suppressed.' Those famifiar with the v i editor and t h e / e t c / t e r r a c a p file may know similar situations in screen update. 1.3
Related Work
This section reviews previous major contributions to the formalization of graphics systems. 1.3.1
Specifying GKS
Dace et al. [3,4] applied to graphics software the two existing specification methods intended for general software systems. They first specified a simplified GKS system, applying the constructive technique known as the Vienna Development Method [23]. The simplifications, which they claim are made for illustrative purposes, include ignoring input facilities, restricting graphical output primitives to a polyline and fixing the workstation transformation. After specifying the system, they examined its external behavior and compared intuitive understanding with formal analysis. The behavior is intuitively described as follows: Consider the three workstation W1, W2 and W3. W1 supports dynamic modification for
10
C H A P T E R 1. I N T R O D U C T I O N changing the polyline bundle representations. W2 requires implicit regeneration, where the implicit regeneration mode currently takes the value of gLLOWED.W3 is the same as W~ except that the current implicit regeneration mode is StWPRESSED. Suppose that three workstations have the same polyline bundle representations and have no primitives outside segments. Then, if the same pictures are drawn and the same changes to the polyline bundle representations are made, the same pictures will appear on W1 and W2, and will be on W3 after the additional invocation of REDRAW ALL SEG~IEIqTS.
They 'formulated' the above description, and gave a formal proof of the formulated description by establishing the several invariants of the system behavior. They also applied the algebraic technique known as OBJ [24] to the specification of the same GKS system. Since OBJ specifications can be 'executed' by using data-type equations (axioms) as rewrite rules, they were able to check the above behavior in several actual cases with the OBJ interpreter, instead of proving it.
1.3.2
Mallgren's Specification
Mallgren [1] first succeeded in specifying interactive graphics programming languages. In principle, he used the axiomatic specification technique developed by Hoare [22]. He also employed algebraic data-type specification techniques in describing graphical data types such as picture, geometric transformation, region, and color. In addition, he devised a new technique based on algebraic specification to describe interactions in graphics systems. He then gave actual specifications to his prototype graphics language and two existing graphics systems, X P L / G and Core. He began his work by formalizing graphical concepts themselves before applying general specification techniques. This is necessary in order to describe the semantic features of a graphics system. Here, we introduce his formalization. He first gave the definitions for the following graphical concepts: 1. A picgure is a partial mapping from U to C. The set U is some chosen universe, which is typically E 2 or E 3. The set C is any set of reasonable values, which are referred to as colors. 2. A region is a set of points in U. 3. The sum of two pictures PI and P2, denoted by P1 + P2, is defined as follows:
1.3. RELATED W O R K
11
(P1 + P2)(q) =-
I P~(q)
q E D~ - 92
P2(q)
q ~ D2 - Dt
Pl(q)+P~(q) q E D2 A D, 4. A graphical transformation is a function that maps pictures to pictures.
5. A geometric transformation is a graphical transformation characterized by a mapping on U. The effect of a geometric transformation T g < G >, characterized by the mapping G : U ~ U, on a picture P is T g < G > (P) = {(G(x), P(z))]z e domain(P)}. (Note that a partial mapping is represented in terms of the set of pairs of each element in the domain and its mapped value.)
6. A restrictive transformation is a graphical transformation characterized by a region R. The effect of a restrictive transformation T" < R >, characterized by the region R, on a picture P is
T" < R > (P) = {(p, P(p))[p e R n domain(P)}. He then formulated the basic relations involved in a graphical transformation as below, and gave them a formal proof." Composition rules:
Tg < G1 > oT 9 < G2 >= Tg < Gl o G~ > T" < R1 > oT ~ < R2 > = T " < Rl n R2 > Commutation rules:
TgoT"
=T"
oTg
T" < R > o T g < G > = T g < G >oT" < G-I(R) > Distributive rules: Tg (P~)+T
T" < R > ( P 1 ) + T "
g(P2)=7
(P2)=T"
'9(P~+P2)
(PI+P2)
Following the presentation of these formalized concepts and relations~ he initiated discussions on the speci~cation of graphics programming languages, which was his original goal. 1.3.3
Detailed Viewing Pipeline
Onodera and Kawai [2] presented a formalization of computer graphics systems by specifying the concept of a viewing pipeline in detail. They first considered a mapping from the set X to the set Y ' , which is the set of all the tuples of the elements in Y: they named such a mapping a pipeline fuzction from X to Y. They represented
12
C H A P T E R 1. I N T R O D U C T I O N
any component process in a viewing pipeline as a parameterized plpehne function~ which is called an operation. For examples clipping dealing with hnes is a pipehne function from the set of lines
to the set of lines~ with two parameters corresponding to a window and a viewport. Note that clipping a line may generate more than one line. The detailed viewing pipeline can be represented as a sequence of operations. The authors consider a set of detailed viewing pipelines (DVPs) to specify a graphics system. Since any conventional graphics system gives a separate description of attribute rendition to each graphical output primitive, they defined a different DVP for each primitive. They also assumed that output primitives are eventually converted into line segments, or vectors~ in defining operations representing an attribute rendering, which seems to limit its application. They also considered the see of DVPs to formalize the output capabilities of a graphics system and even a graphics terminal. Another contribution of their work was their suggestion of the possibility of automatically generating of a graphics system on ~he basis of the DVP specifications. They presented the following procedure for implementing graphics system G with display device D so that the device capabilities are fully utilized: 1. Construct an operation sequence L O S (logical operation sequence), which is considered to be a formalization of G. 2. Construct an operation sequence P O S (physical operation sequence), which is considered tc be a formalization of D. 3. Transform L O S equivalently so that the component operations existing also in P O S occupy the rlghtmost successive positions in the same order as in P O S . 4. Realize as a device driver the leftmost successive operations, which are considered not to exist in P O S . For third stop, they presented the L O S conversion algorithm together with the proof of its validity. For this purpose, they established the commutative or pseudo-commutative relations between two operations and derived three concepts about two operation sequences: order-adaptiveness, the exceeding set, and realizability.
1.3.4
Comments
The work done by Duce et al. has been to specify the GKS system~ especialiy the external behavior of the system. The given specification appears as complex as if it were a program implementing GKS. In addition, they simply followed the viewing model of GKS and did not devise their own. Mallgren began his work by formalizing the basic graphical concept. Although we will do so in this
1.3. R E L A T E D W O R K
13
book, our purpose is not to specify a graphics programming language but to establish some model of visualization for specifying a graphics system. In this sense, our direction is closer to that of our previous work on a detailed viewing pipeline. However, the detailed viewing pipeline was just an extension of a conventionM viewing model: the treatment of attribute rendition is unsatisfactory and the assumption the authors made was restrictive. As shown in Section 1.3.3, the construction of an appropriate model of a system may be helpful in the automatic generation as well as in the specification of that system. It will also serve as a common model for the comparison of two systems. Carson's work [6], which attempts to make a common model of computer graphics systems, was initiated for this very reason, since we already have many computer graphics standards, including proposals.
Chapter Mathematical
2 Framework
This chapter establishes the mathematical foundation for our discussion. The base concept is correspondence [19], which is a general form of a mapping. Traditionally, one-to-many correspondences receive less attention than many-to-one. The former are not even named, although the latter are called mappings or partial mappings. Both types of correspondence, however, play an important role in this book. Operations on correspondences are introduced. In addition to the normal operations of inverse and composition, those specific to our goal of formalizing a graphics system are defined. They are
restriction, domain-priority-sum, and image-priority-sum. We complete the mathematical framework by defining three forms of extension of a correspondence. When a correspondence on M is given, we try to extend it to the power set of M~ to the closure of M, and to a correspondence space, respectively. We list many equalities in this chapter. Some are used in subsequent chapters and others are presented here for the sake of the completeness of our discussion on correspondences.
2.1
Correspondences
Let M and N be sets. When G C M × N is given, 7 = (G, M, N) is called a correspondence from M to N. The set G is called the graph of the correspondence and denoted as Gr 3'. The domain of 3', Dom 7, is defined as Dora 7 = {m](m, n) E G}, while the image of 7, Im 7, is defined as Im 3"
= {~t(m, ~) c a } . For x C M, 7(z) denotes the set {yl(x, y) C G}, and, for A C M, 3'(A) denotes the set U 3'(z). $CA
(3'(x) = ¢ when z ~ Dom 3'.) Two correspondences are defined to be equal if and only if they have the same graph. Correspondences are the most general form of a mapping: they are inherently partial. When 7 satisfies in addition Dora 7 = M, it is called a ~olal correspondence. A correspondence 7 is caned convergent if the predicate (Vz C Dom 3' : I7(z)l = 1) holds. This
C H A P T E R 2. MATHEMATICAL F R A M E W O R K
16
Figure 2.1: Divergent and convergent correspondences type of correspondence is usually called a parliaI mapping. A convergent correspondence 3` is called
a mapping if it also satisfies M = Dora 3`. A correspondence 3' is called divergent if the predicate (Vy E I m 3' : 17-1(Y)1 -- 1) holds. A correspondence 7 is called suT,verger~, if 7 is both divergent and convergent. E x a m p l e 2.1 Let 71 and 72 be the following correspondences: 3`, = ({(1, a), (2, a), (2, b)}, (1, 2, 3}, (a, b, c})
3`2 = ({(1, b), (3, b)}, (1, 2, 3}, {~, b, c}) See Mso Figure 2.1. The former is divergent and the latter is convergent. correspondence.
2.2
Neither is a total
[]
O p e r a t i o n s on C o r r e s p o n d e n c e s
We consider five unary or binary operations on correspondences. Although not every mapping has an inverse mapping, every correspondence 7 = (G, M, N ) has an
inverse 3,-1 = (G -1, N, M), where G -1 = {(y, z)t(z, y) E G}. For any correspondences 7, = (G1, M1, M2) and 72 = (G2, Mz, Ms), the correspondence from i l to M3, 73 -- (G3, M1, Ma), can be defined, where Ga = {(~,, z3)l(3x2 C m 2 : (~t, x2) E G1 A (z2, x3) e G2)}. 73 is called the composition of 71 and 72~ denoted _by "/2 o 71In addition to these received operations, we introduce three operations for our formalization of graphics systems Let 7 -- (G, M, N) be a correspondence and let R be any subset of M. The restriction of 7 onto
2.3. EQUALITIES
17
R, denoted by "/IR, is defined as follows:
Gr (TLR) = {(~,v)l(~,y) • Gr 7 A ~ •
~}.
For ally correspondences 7, = (G,, M, N) and 72 = (G2, M, N), the image-priority-sum of 72 and 71, denoted by 72 • 71, is defined by the rule Gr (72 @ 71) = {(zl, x2)l(zl, x2) • Gr 71 V ((xx, z2) • Gr 72 A z2 ~ Im 71)}Similarly, the domain-priority-sum of 72 and 71, 72 + 71, is defined by the rule Gr (72 + 7,) : {(*1, xz)[(z,, x2) E Or 71 V ((zl, z2) e Gr "/2 A zl ~ Dom 71)}It is worthwhile to note that these two kinds of sum are not commutative but associative. E x a m p l e 2.2 Consider the correspondences in Example 2.1 again and let R = {1, 3}. Then, the graphs of the restriction of 71 on R and two sums of 72 and 71 are as follows: Gr 711R = {(1,a)} Gr (72 + 71) = {(1, a), (2, a), (2, b), (3, b)}
ar (72 * 7,) = {(1, a), (2, a), (2, b)} The element (1, b) E Gr 72 is not contained in Gr (3'2 + 3'1) since 1 ff Dora 3'1. None of the elements in Gr 3'2 is included in Gr (72 (3 71), since b E I m 71- Similarly, Gr (71 + 72) = {(2, a), (2, b), (1, b), (3, b)} and Gr (71 (3 72) = {(1, b), (3, b), (1, a), (2, a)}. This shows that neither domain-priority-sum nor image-priorlty-sum is commutative.
[]
Table 2.1 shows what type of correspondence the result of each operation in the previous section would be in terms of the types of operand. For instance, we can see from the symbol "CON," which is on the last column in the third row, that if 71 and 72 are both convergent, so is the domain-priority-sum of the two. "DI" indicates that it is a divergent correspondence and "X" that it can be of either type.
2.3
Equalities
The relations, or equalities, between correspondences and their operations are fisted below, and can all be easily verified. We let 3' = (G, M, N), 71 = (G1,3/1, M2) and 72 = (G2, M2, M3). (2.1)
7(Dora 7) = I m 7
18
C H A P T E R 2. M A T H E M A T I C A L F R A M E W O R K
71
'72
71-1
72°71
72@71
72+71
DI
DI
CON
DI
DI
X
CON
CON
DI
CON
X
CON
Table 2.1: Results of applying correspondence operations
(2.2)
( ' 7 - ' ) - ' = "r
(2.3)
Dom '7-' = I m
(2.4)
Im "7-1 = Dom "7
(2.5)
(72 o 71)(A) = 72('71(A)), f o r A C M1.
(2.6)
('72 o ~,)-1 = '7;1 o 7; 1
(2.7)
Dora (72 o 71) = 7;1(D om 72)
(2.8)
Im (72 o 7,) = 7~(Im 7,)
We let R, RI, and R2 be a subset of M in the next four equalities. (2.9)
(7[R)(A) = 7(A N R), f o r A C M.
(2.10)
('TIR,)IR~ = '71(R, n R2)
(2.11)
Dom (TIR) = R N Dom "7
(2.12)
Im (TIR) = '7(R)
We let 7,, '72, and 73 be correspondences from M t o n
in the remaining equalities.
(2.13)
('72 • '71)(A) = ('72(A) N I--m--~l)U 'T,(A), f o r A C M.
(2.14)
('72 * '7,)-' = '7~-' + '7;'
(2.15)
Dora ('72 * '7,) = '7;'(I~ "72 n Ix~ ~)u
(2.16)
Im ('72 @ "7,) = Im 72 U Im 7,
(2.17)
(72 + 71)(A) = 72(A N Dom ~-1) O 71(A), f o r A C M.
(2.1s)
('72 + 7,)-' = "7;' * '7;'
(2.19)
Dom (72 + 71) = Dom '72 O Dora 71
(2.20)
Im (72 + "71) = "72(Dom "72 N Dora ~-1) u Im "71
(2.21)
72 + (72 + '71) = (73 + 72) + "71
(2.22)
"73 @ (72 * "71) : ('72 (B 72) * 71
Dora "7,
Only the proofs of Equalities 2.21 and 2.22 are given ill Appendix A. Here we present four propositions and two basic theorems. The first three propositions highlight the basic properties of divergent correspondences. All the proofs are given in Appendix A.
2.3. EQUALITIES
19
2
Figure 2.2: Correspondence for illustrating Proposition 3 P r o p o s i t i o n 1 Let 7 = ( G , M , N ) , A C M and B C M.
1..y(A u B) = ~(A) u ~(B). ,~. ~(A n
B) c ~(A) n ~(B).
3. 7 ( A N B ) = 7 ( A ) N T ( B )
i f T is divewerd.
D
P r o p o s i t i o n 2 Let 7 = (G, M, N ) and A C M . 1. 7-1(7(A)) D A n Dora 7.
[]
P r o p o s i t i o n 3 Let 7 = (G, M, N) be divergent. For any R C M, (71R)-' -- 7-~17(R). []
E x a m p l e 2.3 Let us show that the equality does not hold if 7 is convergent. Let R = {2} and consider the following convergent correspondence 7: =
frO, z), (2, z)}, {i, 2}, {x})
Then,
Gr @ R ) -1 = {(~, 2)}, while
Gr ~-II~(R ) ----{(~, 1), (~, 2)} since "7(R) = {z}. See also Figure 2.2.
D
P r o p o s i t i o n 4 Let 71 = (G, M, N), 72 : (G, M, N), aud R C M .
I. The equality (72 + 71)]R = (72}R) + (711R) holds. 2. The equality (72 • 7t)lR = (721R) • (7x[R) holds i f ' h ( R ) = Im 71. The first theorem below indicates the way of reducing the composition of two restrictions to one,
20
C H A P T E R 2. M A T H E M A T I C A L
M1
M2
M3 -
R1
FRAMEWORK
X
R2
Figure 2.3: Correspondences for illustrating the equality in Theorem 1 while the other specifies the condition on which the composition operator o is distributive over the image-priority-sum operator ~. Theorem
1 Let 7, = (G,, M,, M2) ~nd 72 = (~s, M2, M3). The eqn~Iitu
(72LRs) o (TdR,) = (Ts o 7,)](7?'(R2) n R,) holds if and only if T1 is convergenL [] Theorem
2 Let 7, = (G,, M,, M2), 72 = (G2, M,, M2) and 73 = (G~, Ms, M3). The equality
~ o (7s • 7,) = (7~ o 72) • ( ~ o 7,)
holds if and only if 73 is divewent. [3 E x a m p l e 2.4 Let us see that the equality in Theorem 1 does not hold if 7, is divergent. Consider the following sets and correspondences: M, = {a, b}, M2 = {1, 2}, M~ = {z, y} R, = M1, R2 = {2} C M2 7, = ({(a, 1), (a, 2)}, 11//1,M2) 72 = ({(1, x), (2, V)}, Ms, 11//3) See also Figure 2.3. In this case, 7, is divergent. Since 7,IR, = 7, and Gr %lR2 = {(2, y)}, Gr (72lR2) o (7,IR,) = {(a,y)}. On the other hand, since 71-'(R2) N R, = {a} and Gr 72 o 7, = {(a, ~), (a, y)}, Gr (72 o 7zlT~-'(Rs) fq R,) = {(a, ~), (a, y)}. []
E x a m p l e 2.5 Let us check that the equafity in Theorem 2 does not hold if 73 is convergent. Suppose that /1//1, 21//2, and 21//3 are the same as in the above example.
Consider the following
2.4. EXTENSIONS OF CORRESPONDENCES
M1
M2
21
M3
Figure 2.4: Correspondences for illustrating the equality in Theorem 2 correspondences: ~,~ = ({(a, ])}, M~, M~) 3'2 = ({(b, 2)}, M,, M2) 3'2 = ({(1, z), (2, z)}, M2, Ms) See also Figure 2.4. Since Gr 3'2 $ 3", = {(a, 1), (b, 2)},
Gr 3'2 o (3"~ ~ 3'~) = {(a, ~), (b,
~)}.
On the other hand, since Gr 3"2 o 3"2 = {(a, z)) and Or 72 o 3'x = {(b, z)},
Gr (3'~ o3"~) ~ (3'203",) = {(a, ~)}. E]
2.4
Extensions of Correspondences
In this subsection we define three extensions of a correspondence on a set. Let 7 = (G, M, M ) be a correspondence on M. W h e n 7 is a correspondence, the mappiug :r = (G, 2 M, 2 M) is naturally derived by the rule, n
i=1
is called the power se~ ez~ensiort of 3'. The ®-closure of a set S, denoted by S*, is defined as S U (S ® S) U (S ® S ® S) .... When 3' is a
mapping, the mapping 7* = (G, M*, M*) can be defined by the rule ( m l , ... , m . ) e M" ~-~ ( 3 " ( m l ) , . . . , ~(m,)).
3" is called the ®-closure ezlertsiort of 3". The last extension of a correspondence is for a set of correspondences. Let us denote by F(X, Y) the set of correspondences (correspondence space) from a set X to a set Y. When the above 3' and
22
C H A P T E R 2. M A T H E M A T I C A L F R A M E W O R K
a set N are given, the mapping from F(M, N) to P(M, N), denoted by .~N, can be obtained by the rule
; e r(M, S') A p' s.~. Gr
o' =
{(m, ,~)[(3(m', m) e Gr 7 A (m', n) e Gr p}.
The superscript of ON may be omitted when there is no confusion. By the definition of ~, the following equalities hold:
(2.23)
5(p) = p o'[-'
(2.24)
Dom 5(P) = 7(Dom p)
These extension operators obey the distributive law as described in the proposition below. Proposition 5 1. When "[1 and "f2 are a total correspondence, 2. When T1 and72 are a mapping,
"[2 o"-'-71 = 72 o ~¢1
('[2o'Yi)* = 7 ~ o 7 ~
3. When 71 and 72 are a correspondence,
'[2 o-~7i = ~'2 o "71
The following two theorems are quite interesting, though neither of these equalities holds unconditionally. The proofs are given in Appendix A.
T h e o r e m 3 Let 7 = ( G , , M , M ) ,
Pl = ( G 1 , M , N ) and P2 = ( G 2 , M , N ) .
1. The equality Zy(p2 + Pl) = Z/(P2) + zf(Pl) holds if "[ is divergent. 2. The equality "Y(P2~ P~) = "Y(P2) q~ 7(Pl) holds if'[ is divergent and Dom "[ = Dora Pt. []
T h e o r e m 4 Let 71 = (GI, M, M ) , "[2 = (G2, M, M ) and p = (Gp, M, N ) . The equality
('y2 • "[,)(p) = ~2(p) + ~,(p) holds if Dom 71 = Dora p.
[]
Figure 2.5 shows that the same pair of sets are given priorities in both sides of the above equality. The reason that the condition Dora 71 = Dora p is required will be explained in an intuitive m a n n e r in Section 3.1.9.
23
2.4. EXTENSIONS OF CORRESPONDENCES
M
P
M
P
--'~N
M "Y2
~'N
~1 (P)
--- N
P
M
M
*N
\ These sets are given priorities.
/
~,2(p)+~.l(p) N
These sets are given priorities
Figure 2.5: Diagram representing both sides in the equality of Theorem 4
Chapter 3 F o r m a l M o d e l of V i s u a l i z a t i o n
This chapter first gives a formalization of basic concepts in computer graphics, resorting to the mathematical framework constructed in the previous chapter. After identifying the two distinct concepts of
geometries and pictures, geometric transformations and restrictive transformations are
defined for each. In addition, a pictorializing transformation and a cumulative transformation are introduced. The former is the key to formalizing attribute rendering. Our formM model of visualization, called a
visualizing net, is then defined by using the above six
transformations. We also give specifications of visualizations of output primitives in conventional graphics systems in terms of a visualizing net. We will reveal ambiguities hidden in conventional specifications and point out deficiencies of conventional visualizing processes.
3.1 3.1.1
F o r m a l i z a t i o n o f B a s i c C o n c e p t s in C o m p u t e r
Graphics
Pictures and Picture Transformations
k picture is defined as a convergent correspondence (partial mapping) whose domain and image are a subset U of a Euclidean space and a set C of reasonable values, respectively. The set of pictures is denoted by P . This is the same as Mallgren's definition of a picture [1], and is generally accepted in the field of picture processing. Partiality is needed because the background region of a picture is supposed not to be assigned any color. The reason neither domains nor images are made very concrete is to deal with various types of pictures, such as two-dimensional or three-dimensional, black-and-white or colored. It is worthwhile noting that we can take U as a more general set than Euclidean spaces, as far as the discussions in Sections 3.1.1 through 3.1.3 are concerned.
A picture traesformation is a mapping from P to P . If a correspondence d on U is divergent, d c is a picture transformation. T h a t is, for any p E P , d(p)(= p o d -1) is also a picture: Table 2.1 shows that, since d -1 and p are both convergent, so is p o d -1. Figure 3.1 gives an intuitive illustration of how d transforms a picture p:
d(p) maps u in its domain to the same color as the one to which p
C H A P T E R 3. FORMAL MODEL OF VISUALIZATION
26
U
Domd
Domd~)-
C
/~
Figure 3.1: Picture transformation derived from a divergent correspondence maps the element that d maps to u. The hatched region represents the domain of the transformed picture.
3.1.2
Picture Sum
The sum of two pictures P2 and Pl is directly defined to be P2 + pl by using domain-priority-sum. Note that Table 2.1 shows that if Pl and P2 are pictures, so is P2 + Pl- This definition can be also regarded as representing the temporal display priority in the picture generation: the picture Pt has been generated after p~ and therefore takes priority of display. The mapping ~¢ from P x P to P, which maps (P2,Pt) to p~ + P l , is called a cumulative transfor-
mation. 3.1.3
Geometries and Geometry
Transformations
A subset of U is called a geometry. The domain of a picture is a geometry.
Usual geometric
entities on U, such as lines, point sequences, and areas, are also geometries. The set of geometries is denoted by G.
A geometry transformation is a mapping from G to G. When c is a correspondence on U, ~ is a geometry transformation.
3.1. FORMALIZATION OF BASIC CONCEPTS IN COMPUTER GRAPHICS 3.1.4
27
Geometric Transformations
The mappings on U called non-singular a ~ n e transformations play the central role in computer graphics systems. We denote the set of those mappings by M, since they can be represented by matrices. For any m E M, r~ and rh can be derived, rh and ~ are named a geometric geometry transformation and a geometric picture transformation, respectively, and are each regarded as a formalization of what is called a geometric transformation. The mapping t 9 from M × G to G, which maps (re, g) E M x G to rh(g), and the mapping t~ from M x P to P, which maps (re,p) E M × P to rh(p), are also referred to as geometric geometry transformation and geometric picture transformation, respectively.
3.1.5
Restrictive Transformations
Let g be a geometry. Two mappings (id[g) and (id[g) can then be derived, where id is the identity mapping from U to U. The two are named restrictive geometry transformation and restrictive
picture ¢ransformation, respectively, and are each thought of as a formalization of clipping. The mapping t, from G × G to G, which maps (9~,g2) E G × G to (id[gl)(g~), and the mapping ~R from G × P to P, which maps (9, P) C M x P to (id[g)(p), are also referred to as restrictive geometry transformation and restrictive picture transformation, respectively. Note that the two concepts of geometric transformation and clipping, which appear inherently different in conventional viewing models, are formalized in a unified manner.
3.1.6
Replications
Pattern filling is widely employed as an interior style for regional output primitives in conventional graphics systems. The filling is performed conceptually in two steps, the first of which is the infinite or sufficient filling of the whole space by the replication of a basic pattern. In the second step, the whole space is clipped against the area to be filled. The first operation is called replieatiou. A replication of a picture p can be represented by (r, @ ...r2 @ rl)-, where rl is a survergent correspondence and Dora ri(1 < :
i which generates from a sequence
of points the picture whose d o m a i n is a regional area defined as in 7r. . . . a n d in which every element in the d o m a i n is m a p p e d to one color c. Let us denote by
p(c)
the uniform-colored picture, t h a t
is, the one whose d o m a i n is U a n d which maps every u E U to c E C. T h e n , the above pictorial primitive is formulated by a restrictive t r a n s f o r m a t i o n as follows: ~p,~, < c >: 9 ~ Dom ~p,~ < c > 4 []
(i4~ .... @)'(p(c))
4.1. GEOMETRIC AND PICTORIAL PRIMITIVES
g
17 (g)
'v
U*
U*-----~ P r~
13"
(g)
'TT
~G
rrl* U* m* (g)
43
"G r~ (~r (g))
m*
U*
-p
m*(g)
~r( m* (g))
,'7( m" (g))
Figure 4.2: Soundness of geometric and pictorial primitives
4.1.2
Sound Property of P r i m i t i v e s
A geometric primitive 7r is called sound if the following predicate holds: (Vm E M : ~ o T r = ~r om*) Similarly, a pictorial primitive 7r is called sound if the following predicate holds: (Vm E M : t h a t
= 7r o m*)
See also the diagram in Figure 4.2. Not all the primitives satisfy this condition, as shown in the example below.
E x a m p l e 4.3 The geometric primitives 7rm, 7r,pt, and 7r. . . . all satisfy the soundness condition. In particular, this property of the methods of generating spllne curves is known as the shape-invariaatunder-transformation or Cauthy relation, which asserts that the sum of the base functions is equal to 1.
[]
E x a m p l e 4.4 The geometric primitive vd, c is not sound, since ~r,~,c always generates a circle but some geometric transformations convert a circle to a skewed ellipse. We believe that this way of generating a circle originated in mathematics but is not suitable for computer graphics. The general forms of circles, or ellipses, should have been specified by three points that define a pair of conjugate diameters. (See [10]).
[]
In fact, not a few graphics terminals or systems provide unsound graphical primitives, such as circles and rectangles. Obviously, these primitives bring about an unpleasant inconsistency in the viewing process. E x a m p l e 4.5 We can verify from the soundness of 7r. . . . that 7rpla is sound. For Vg E U*, ,~(~,.~ < c > (g))
44
CHAPTER 4. GRAPHICAL NUCLEUS = ( ~ o (~dI~ . . . . (g))')(p(c)) = ( ( i d l m ( ~ . . . . (g))- o ~)(p(c))
(3.s)
Since ~(p(c)) = p(c) and r~(A) = re(A) (A C U) by definition, =(idlr~(~r . . . . (g)))'(p(c))
=(idlv .... (m'(g)))'(p(c)) =~
4.2
(soundness of ~ ' ~ )
< c > (m'(g))
Graphical Nucleus
A graphical nucleus is a system whose geometric or pictorial primitives are all sound and which allows any visual net. The requirement for soundness is relevant to the implementability discussed in the next section. If we imitate the title of the famous book on algorithms and data structures by N. Wirth, our approach to specifying a graphics system can be concisely expressed as "primitives + visualizing net = graphical nucleus." The organization of its visualizing net is variable and is not dependent on a primitive.
This
orthogonality of a visual net and primitives makes a graphical nucleus open: adding a new geometric or pictorial primitive causes no problem. The generality of attribute rendering in a graphical nucleus, which is brought about by regarding attribute renditions as pictorializing transformations in a unified manner, make it much more descriptive than conventional systems. For instance, let us consider drawing a railway or road on a map. It is drawn in a graphics nucleus simply by giving an appropriate pattern picture to an appropriate pictorializing transformation. On the other hand, users in a conventional system will have to specify one by one the details of the geometry of railway or road patterns. Moreover, there are no limitations on pictures for pictorializing transformations. If a graphical nucleus provides marker drawing like that in conventional systems, the system can draw any markers, including pictures that are originally provided for the graphical representations of characters. On the other hand, the conventional systems make a strict distinction between makers and characters: markers cannot be drawn by a text primitive, nor can characters be drawn by a marker primitive.
4.3
Implementability
of a Graphical Nucleus
We examine in this section the implementability of a graphical nucleus. Let H~ and H v be the set of its geometric primitives and the set of its pictorial primitives, respectively. Note that all the primitives are sound by definition.
4.3.
IMPLEMENTABILITY
45
OF A G R A P H I C A L N U C L E U S
In the following claims, we first assert that any geometry and any picture comply with certain specific forms. We also present the proofs, which is based upon induction on their structures, that is, on the production rules generating them.
Claim 1 The geometry in a visualizing net is in the form of
N~,(g,),
~here ~, e
rig.
i
We prove the claim by induction on the structure of a geometry.
Proof:
STEPI:
The arbitrary geometry generated by a geometric primitive takes the specified form.
STEP2(A): Suppose the production rule G ---* t g ( M G ) is applied.
~(Ni ~,(g,)) =Ni ~(~,(9,))
(Prop. 1)
=Ni ~,(m*(~,))
(soundness of ~)
STEP2(B): Suppose the production rule G --* t , ( G G ) is applied.
(idl N =J(gJ))'(N~,(g,)) j
i
=(Nj ~J(g~))N(fl~,(g,)) In both cases we have shown that the form is preserved. []
Claim 2 The picture in a visualizing ne~ is in the form of
~ ( id[ N ~r,j(gij) )" ( ~,(gl ) ),
; j where 7rlj E lig and 7ri E lip. Proof:
We prove the claim by induction on the structure of P.
STEP1: Any picture generated by a pictorial primitive takes the specified form. STEP2(A): Suppose the production rule P --* t ~ ( M P ) is apphed.
i
j
(3.13) (3.8)
i
j
=~2(idl n m('~Ag~i))-(~(~',(g0)) i
(Prop. 1)
j
=~2(idl n,~,J(m'(y~A))'(~,(m'(g,)))
(soundness of 7%,Try) i j STEP2(B): Suppose the production rule P --4 t R ( G P ) is applied. From the result of Claim 5.1,
CHAPTER 4. GRAPHICAL NUCLEUS
46
=E( dl ffl :
i
ffl
(idl(f]
(3.12)
f-I(f-I
k
(3.7)
j
STEP2(C): Suppose the production rule
P -~ te(PG ) is applied.
By the definition of pictorializing
transformations,
(m~ @ ... ~ ml)- (~i (id' ~ 7:~j(g~i))'(~r~(gl))1 \" j /
By applying the same transformations as in case (a),
= ~ ~(idl A ~,J(m*k(gq)))-ffr~(m*(g~))) k
i
STEP2(D):
j
The proof in the case that the production rule
In every case we have shown that the form is preserved.
P -~ t:(PP)
is applied is self-evident.
[]
Let us return to our original problem of the implementability of a graphical nucleus. We describe how each component transformation is to be realized. Claims 1 and 2 indicate that the geometric transformations for a picture and for a geometry can both be reduced to the transformations for a finite ordered geometry, which are easily implemented. On the other hand, the restrictive transformations are simply accumulated, because they are inherently unsound. For instance, they usually destroy a geometry. A restricted ellipse is never an ellipse, but an elliptic arc or elliptic arcs. Similarly, a restricted polygon is no longer a polygon but appears to be a collection of line segments. This means that, for 7r E IIg, such a relation as
Vg c
G:
(idlg)
o ~r = ~r o ( i d l g ) *
cannot be established. The implementation of a pictorializing transformation is therefore to handle the form of input geometries into which the restrictive transformations are accumulated. That is, we need to implement a procedure that generates a set of matrices for a replication from its input geometry of the form specified in Claim 1. The final output of a visualizing net is rasterized. It is natural to assume that rasterizing a picture is distributive over the picture sum, +. Together with this, Claim 2 shows that we have to implement a procedure that rasterizes a picture whose form is
(id I ~,(g,))-(~(g))(~, ~ Hg,~ c II~). i
4.4.
OPTIMIZATION CONSIDERATIONS
47
The restrictive transformations also remain here.
4.4
Optimization
Considerations
In this section we discuss how to simplify or optimize an implementation of a graphical nucleus. The two procedures in the previous section can be simplified when we take advantage of the fact that, in most graphics systems, not all kinds of geometry are necessarily used to specify a restrictive transformation.
Neither line geometries nor texts ate never used as clipping regions
in conventional systems. O n the other hand, a considerable reduction in computing costs can be obtained by delaying the effect of a pictorializing transformation. A geometry that can be used to specify a restrictivetransformation is called a restrictive geometry. Let us denote by II,g the set of the geometric primitives that can generate a restrictive geometry. The forms of a geometry and a picture are then simplified to
and (idl n~r~(g~))'(~r(g))
(~r~E lI,g,~r E lip),
i
respectively. This reduces the number of cases that have to be considered in implementing the two procedures. Next, let us consider delaying the effect of a pictorializing transformation. As we have seen, a pictorializing transformation is immediately replaced by a replication in the proof of Claim 2. That is,
~p(v, g) = ( m ~ . . . . .
-~l)(p).
Subsequent picture transformations, if any, are supposed to apply the (R.H.S) in the proof. We consider the alternative, where tp(p,g) is not transformed and is itself subject to picture transformations. Since the successive application of picture transformations can be simplified by using Equalities 3.6~ 3.7, and 3.8, the counterpart of Claim 2 in the implementation of the delayed pictorializing transformation is as follows: Claim 3 The picture in a visualizing ne~ is the sum of pictures of the form (idl N -,(g,))- (,~(g)) i or
((idl n ~(g~)) o m)'(~,(;, ~(g)))
48
C H A P T E R 4. G R A P H I C A L N U C L E U S
where 7rl E Hp and m E M .
[]
It will be obvious that this leads to a reduction in the number of multiplications. Let us consider a picture generated by tp(p,g). Assume that the pattern p contains Np points and is replicated N, times along the geometry g, and that this picture is supposed to be subject to geometric transformations N~ times subsequently. The straightforward implementation needs Np × N, × Nt point-by-matrlx multiplications, whereas the delayed version requires N, matrix-by-matrix multiplications plus Np x N, point-by-matrix ones. This considerably reduces the computing costs. Moreover, if tp is sound for 7r, that is,
~(tp(p, ~(g))) = tAP, ~(-~'(g))), the picture of the second form is simplified to (idl A ~'(g~))-(t~(P, ~('~*(g))))" i
This requires only Nt matrix-by-matrix multiplications and Np point-by-matrix multiplications. Unfortunately~ we must mention that tp is rarely sound for any geometric primitive.
Chapter Implementation
5
of a Graphical
Nucleus
This chapter describes the implementation of a prototype system of a graphical nucleus, called
pNucleus. The system is written in Franz Lisp [20]. We present first a set of primitives in pNucleus, then the representations of the invocation of component transformations of a visualizing net, geometries, and of pictures. These representations are called V-expressions, G-expressions, and P-expressions, respectively. Appendix B contains a formal specification of the syntax in pNucleus denoted by the extended BNF. The implementation details of the component transformations are also described. The claims in Chapter 4 provide support for the validity of our implementation. Finally, the backend function p e v a l , which performs the actual conversion of pictures with specified representations into a visual medium, is mentioned together with the method of implementation. 5.1
G e o m e t r i c a n d P i c t o r i a l P r i m i t i v e s in p N u e l e u s
Suppose II,g,IIg, and IIp are given the same definitions as in Section 4.3. The system of pNucleus contains the following set of primitives:
II,, = {~ .... }
II~ = {%i**} where 7rt,,, 7r..... and 7rpict are introduced in Examples 4.1 and 4.2 and the others are defined as follows: 7rpt
simply generates from a sequence of points the geometry consisting of the specified points.
~rtat
generates from a sequence of three points P1,P2, and P3 the lattice whose reference point is P1 and whose width vector and height vector are P1P2 and P1P3, respectively.
The primitives of 7rrt and 7rz~t are originally meant for polymarker drawing and fillarea drawing, respectively. All the primitives are carefully selected to be sound.
CHAPTER 5. IMPLEMENTATION OF A GRAPHICAL NUCLEUS
50 5.2
Representation of Visualizing Nets
This section introduces V-ezpre~sions, which are the pNucleus representation of a visualizing net. The component transformations of a visualizing net are realized by Lisp functions.
The two
geometry transformations, geometric and restrictive~ are invoked by the following expressions, respectively: (*gtran*geom '<matrix> ') (*rtran*geom ' < r e s t r i c t i v e
geometry> ') .
The apostrophe(') indicates that the quoted argument is evaluated before a function is called. The expressions that represent a geometry are called G-e¢pressions. As defined in the previous section, a restrictive geometry can only be given in pNucleus by the specific geometric primitive 7r~¢~. G-expressions will be described in the next section. The two picture transformations, geometric and restrictive, are represented by the following expressions, respectively: (*gtran*pict
'<matrix> ' < p i c t u r e > )
(*rtran*pict
' ' < p i c t u r e > ) .
The expressions giving a picture are called P-ezpressions, and will be explained in Section 5.4. The other two transformations are as follows:
(*pict*tran ' ' ') (*pict*sum {' }) The invocation of plctorlallzing transformation replicates the pattern given by < p i c t u r e name> along the geometry; the way of replicating is controlled by the control list. This will be discussed in Section 5.5. The braces mean any number of occurrences of the symbol(s) enclosed by them: *pict*sum is extended here from the binary function of the cumulative transformation. A V-expresslon is any valid expression comprising the above six functions. The function of pNucleus is to evaluate the V-expression to a P-expression and to convert the resulting P-expression into an actual visual representation by using its backend function p e v a l . The function p e v a l is therefore device-dependent. It will be described in Section 5.6.
5.3. GEOMETRIES AND GEOMETRY TRANSFORMATIONS 5.3
51
Geometries and Geometry Transformations
This section introduces the representations of restrictive geometries and of other geometries, G-
ezpressions. In addition, it describes how to implement two geometric transformations by manipulations on G-expressions. 5.3.1
Restrictive Geometries
A restrictive geometry is represented by using *area; its syntax is as follows: (*area <area p o i n t s > ) . where <area p o i n t s > is defined to be
{{<point>} close}{<point>}. The data structure built up from *a3coa represents the interior whose boundary is constructed by the following procedure. The keyword(s) of c l o s e can be inserted between two adjacent points so that a region with one or more holes can be produced.
When the sequence of points and keywords is scanned, each point in the sequence is connected to its successor by default. However, if its successor is the keyword c l o s e or there is no successor, it is connected to the current closure point. The closure point is initialized to the first point in the sequence and is reset to the successor when the keyword c l o s e is encountered. E x a m p l e 5.1 The expression
(*area (0.3 . 0.3) (0.7 . 0.3) (0.7 . 0.7) (0.3
•
o.T)
close
(0.4 . 0.4) (0.6 . 0.4) (0.5 . 0 . 6 ) ) represents the restrictive geometry shown in Figure 5.1.
[]
A point is represented by a dotted pair of its x and y coordinates in pNucleus. 5.3.2
Geometries
The system of pNucleus provides a type of G-expressions corresponding to each of the three geometric primitives ~rl., ~rpt, and lrzat. The syntax of G-expressions is as follows:
(*line {<point>} {}) (*point {<point>} {})
52
CHAPTER 5. IMPLEMENTATION OF A GRAPHICAL NUCLEUS
1.0
0.5
0
.5
1.0
Figure 5.1: Region specified by the expression in Example 5.1 (*lattice <point> <point> <point> {})
These denote a line geometry, a point geometry, and a lattice geometry, respectively. Since Claim 1 insists that restrictive transformations must be accumulated, the syntax is determined so that each G-expresslon can maintain restrictive transformations by appending restrictive geometries specifying them. When the G-expresslon has no restrictive geometry, it can be considered a direct application of a geometric primitive.
5.3.3
Geometry T r a n s f o r m a t i o n s
Following the proof of Claim 1, the two geometry transformations are implemented as follows. The geometric geometry transformation *gtran*geom is implemented to return a G-expression by transforming the sequence of points in a given G-expression~ including every sequence of points in the restrictive geometries, if any. E x a m p l e 5.2 The geometry ( * l i n e (0 . 0) (0.1 . 0.1) (0.8 . 0 . 9 ) ) is rotated by 90 degrees around the origin by invoking *gtran*geom. (*gtran*geom ( * m a t r i x * r o t 90) '(*line (0 . O) (0.1 . 0.1)
(0.8 . 0.9)))
The function *matrix*rot is a utility function to generate the transformation matrix for a rotation through the angle specified in its parameter. The pNucleus will evaluate this V-expression to the following G-expression:
5.4. P I C T U R E S AND PICTURE T R A N S F O R M A T I O N S ( * l i n e (0 . 0) ( - 0 . 1
. 0.1)
(-0.9
53
. 0.8))
The geometry is validly rotated by rotating each point in the sequence, because of the sound property o f * l i n e .
[]
The restrictive geometry transformation *rtran*geom is realized to return a G-expression simply by appending the restrictive geometry to a given G-expresslon. E x a m p l e 5.3 Let the geometry in Example 5.2 be restricted against the region in Example 5.1 by invoking *rtran*geom. (*rtran*geom :' ( * a r e a
(0.3 . 0.3)
(0.7 . 0.3)
(0.7 . 0.7)
(0.4 . 0.4)
(0.6 . 0.4)
(0.5
'(*line
(0 . O) (0.1
. 0.1)
(0.3 . 0.7) c l o s e
. 0.6))
(0.8 . 0 . 9 ) ) )
The system of pNucleus will evaluate this V-expression to the following G-expression:
(*line (0
. o)
(0.1
. 0.1)
(0.8
( * a r e a (0.3 . 0.3) (0.4 . 0.4)
. 0.9)
(0.7
(0.6 . 0.4)
. 0.3)
(0.7 . 0.7)
(0.3 . 0.7) c l o s e
(0.5 . 0 . 6 ) ) )
No actual restriction is performed by *rtran*geom; a restrictive geometry is merely appended. 5.4
Pictures and P i c t u r e Transformations
This section presents the syntax of P-expressions and the method of realizing the picture transformations. We also describe picture-naming facilities, which add another type of P-expression to the pNucleus system. 5.4.1
Pictures and Picture N a m i n g
Following Claim 3, the representations of pictures, P-ezpvessious, are given as follows:
(*pitt <area points> {}) (*pict*tran <matrix> {}) (*pict*sum
{})
The first P-expression will be originally created by the only one pictorial primitive in pNucleus. The first parameter of the P-expression specifies the color value.
C H A P T E R 5. I M P L E M E N T A T I O N OF A GRAPHICAL NUCLEUS
54
1.0
0.5
0
l
I
0,5
1.0
Figure 5.2: Picture to which the name *A is assigned. The second and the third P-expressions will be originally generated by the pictorializing transformation and by the cumulative transformation, respectively. Invoking the functions of * p i c t * t r a n and *pict*sum causes the corresponding P-expressions with the same symbols to be returned. Note that our implementation of pNucleus is based on the notion of the delayed pictorializing transformation depicted in Section 4.4. The control list in * p i c t * t r a n is explained in Section 5.5. E x a m p l e 5.4 The expression (*pict 1 (0.1 . 0 . 1 )
(0.5
. 0.9)
(0.9
. 0.1)
(0.8
. o.i)
(0.7 . 0 . 3 0 ) ( 0 . 3 . 0 . 3 0 ) ( 0 . 2 . 0 . 1 ) c l o s e (0.35
. 0.40) (0.65 . 0.40) (0.5 . 0.70))
represents the picture in Figure 5.2. G
Picture-naming facilities are also provided in pNucleus. A name can be given to one or more pictures by invoking the function * d e f * p i c t as follows: (*def*pict {'})
.
Once a picture or group of pictures is given a name, the picture can be instantiated by the following expression using * p i c t * c a l l : (*pict*call <matrix> {}). This is a fourth type of P-expression. The syntax indicates that, when the named picture is copied, it can be subject to picture transformations.
55
5.4. PICTURES AND PICTURE TRANSFORMATIONS E x a m p l e 5.5 The expression ( * d e f * p i c t *A ' (*pict 1 (0.1
• 0.1)
(0.5
. 0.9)
(0.9
. 0.1)
(0.8
. 0.1)
(0.7 . 0.30) (0.3 . 0.30) (0.2 . 0.1) c l o s e (0.35 . 0.40) (0.65 . 0.40) (0.5 . 0 . 7 0 ) ) ) is evaluated to assign the name *A to the picture, as in Figure 5.2. The picture obtained by rotating this by 45 degrees around the origin is represented by the P-expression , ( * p i c t * c a l l *A , (*mat*rot 4 5 ) ) . The function *mat*rot returns the matrix for the rotation by the degrees specified by its argument.
The backquote macro is used in this example. If the Lisp reader encounters the backquote when reading a list, it constructs a list by evaluating the inner elements preceded by a comma. For example, when the Lisp reader reads the input, ' (pen p e n c i l , (car ' ( e r a s e r r u l e r ) ) ) it obtains the list (pen p e n c i l e r a s e r ) . Although P-expressions have two sequences of < r e s t r i c t i v e geometry>, they can by no means be merged: restrictive geometry transformations and restrictive picture transformations are essentially different. Similarly, the element <matrix> cannot be removed by applying it to a part of : geometric geometry transformations and geometric picture transformations are inherently different. 5.4.2
Picture Transformations
There are three picture transformations - - cumulative transformation, geometric picture transformation, and restrictive picture transformation. The cumulative transformation *pict*su~ is implemented to return a P-expression similar to its invoking ~orm. Further evaluation will be performed in the backend function. Note that the symbol *pict*sum is used both in V-expressions and in P-expressions. The geometric picture transformation ( * g t r a n * p i c t N P) is implemented to return a P-expression as follows: 1. When the picture is in the form of a picture sum, the transformation applies itself recursively to each of the component pictures.
56
CHAPTER 5. IMPLEMENTATION OF A GRAPHICAL NUCLEUS
2. Otherwise, it transforms each part of < r e s t r i c t i v e
geometry> by using the matrix M and
accumulates the matrix ~i into <matrix>. Claims 2 and 3 validate the above algorithm. The restrictive picture transformation ( * r t r a n * p i c t 6 P) is realized to return a P-expression in the follow process: 1. When the picture is the form of a picture sum, it applies itself recursively to each of the component pictures. 2. Otherwise, it simply appends the restrictive geometry to the P-expression. 5.5
Pictorializing Transformations
The pictorializing transformation * p i c t * t r a n is invoked by
(*pict*tran ' ' '). A geometry is given as a G-expression, while a pattern is supplied as a P-expression. A control list is literally used to control the method of replication. This and the allowable elements in a control list depend on a given geometry, which will be described in detail later. The function * p i c t * t r a n is implemented to return a P-expressions ( * p i c t * t r a n < c o n t r o l l i s t > < p i c t u r e > <matrix> { < r e s t r i c t i v e
geometry>}).
The symbol * p i c t * t r a n is used both in V-expressions and in P-expressions. Although the above P-expression is considered to represent the picture in which a pattern is replicated along a geometry~ the actual effect will be achieved in the backend function. In the rest of this section, we describe the picture that the P-expression returned by * p i c t * t r a n represents. 5.5.1
Pictorializing a Point Geometry
When a given geometry is a point geometry, the returned P-expression is considered to represent the picture constructed by translating the pattern to each point P of a point geometry. The vector of translation is A~P, where A is the a*fention poin~ of the pattern picture. The default attention point is (0.5, 0.5) since * p i c t * t r a n assumes that the pattern Lies within [0, 1] x [0, 1]. The element ( a t t e n p <point>) in the control list overrides the default and changes the attention point to the specified point.
5.5. PICTORIALIZING TRANSFORMATIONS
57
1.0
A 0.5
A
A
0
;0
Figure 5.3: Pictorialization of a Point Geometry E x a m p l e 5.6 Here is an invocation of * p i c t * t r a n with a point geometry: (*pict*tran '((attenp
(0.I
~(*pict*call ~(*point
(0.3
. 0.I))) *A
,(*mat*seal
. 0.3)
(0.5
0.2 0.2))
. 0.7)
(0.8
. 0.2)))
.
We assume that *A is already assigned to a picture by using *de:E*pict* as in Example 5.5. The picture referred to as *A was defined within [0, 1] × [0, 1]. The picture to which the original is reduced by one fifth is instantiated here and the attention point is made (0.1,0.1), accordingly. The system of pNucleus evaluates the above V-expression to a P-expression similar to the very V-expression, which is considered to represent the picture as in Figure 5.3 []
5.5.2
Pictorlalizing a Lattice Geometry
When a supplied geometry is a lattice geometry, the returned P-expression is considered to represent the picture constructed by pasting the pattern to each cell of a lattice geometry. This pasting is done through affine transformations, each of which maps the pa~ern recLangle to a parallelogram of a ceil. The default pattern rectangle is [0: 1] x [0, 1]. The element ( p r e c t <point> <point>) in the control list overrides the default and changes the pattern rectangle to the one whose diagonal corners are the specified points. E x a m p l e 5.7" Here is an invocation of * p i c t * t r a n with a lattice geometry: (*pict*tran '() ' ~(*pitt*call
*A
,Unit*Matrix)
C H A P T E R 5. IMPLEMENTATION OF A GRAPHICAL NUCLEUS
58
1.0
0.5
m
0
0.5
1.0
Figure 5.4: Pictorialization of a Lattice Geometry '(*lattice
(0.0 . 0 . 0 )
(0.1 . 0.05) (0.0 o 0 . 1 )
(*area
(0.3 . 0.3)
(0.7 . 0 . 3 ) ( 0 . 7
. 0.7)(0.3
. 0.7))))
We assume that *A is already assigned to a picture by using picture-naming facilities as in Example 5.5. The system of pNucleus evaluates the above V-expression to a P-expression of a similar form. The P-expression is considered to represent the picture as in Figure 5.4.
5.5.3
Pietoriallzing a Line Geometry
When a given geometry is a line geometry, the returned P-expression is considered to represent the picture constructed in the following steps: 1. Develop sections, which are normally congruent to the pattern rectangles, along a given geometry.
The default pattern rectangle is [0, 1] × [0,1].
The element ( p r e c t < p o i n t >
< p o i n t > ) in the control list overrides the default in the same way as in a lattice geometry. 2. Replicate a pattern in each of the sections by mapping the whole pattern rectangle onto the whole section. The first step is called sectioning. The algorithm for this is depicted in Appendix C. Sectioning does not necessarily result in the creation of rectangles. Most sections might be rectangles congruent to the replication rectangle, but some are mandatorily fractions of rectangles, or even trapezoids or fractions of trapezoids, at the connecting points of pairs of adjacent line segments. E x a m p l e 5.8 The result of developing sections along the line ( * l i n e (0.15 . 0.25)
( 0 . 4 . 0.5)
(0.6 . 0.5)
(0.9 . 0 . 8 0 ) )
is as shown in Figure 5.5. The pattern rectangle is assumed to be [0, 0.1] × [0, 0.1].
[]
5.5. PICTORIALIZING TRANSFORMATIONS
1.0
59
j
0.5
!
0.5
0
1.0
Figure 5.5: Development of Sections When Step 2 maps the pattern rectangle to a section congruent to it, the mapping is simply a combination of rotation and translation. When the section is a rectangular fraction, the corresponding fraction of the pattern rectangle is mapped in the same way. The mapping can no longer be any affine transformation when the target section is a trapezoid or its fraction.
The system of pNuclens provides two types of transformation for mapping a
rectangular region onto a trapezoid. One is ~wo-diraeusional projeclive transformation,
and the
other is what we call zy-transformation, since the transformation equations for a point (z, y) contain the second-order term zy. The former can be represented in a 3 × 3 matrix, but can cause nnsmooth pattern development if a pattern lies across the section boundary.
The latter is not a linear
transformation but can paste patterns smoothly along a line. Appendix C contains the details of these transformations, such as their transformation matrices. By default, the latter transformation is used when required. The element ( t r a n < r t - t r a n s f o r m > ) , where < r t - t r a n s f o r r a > is IT/ or PR03, overrides this default. E x a m p l e 5.9 Here is an invocation of * p i e t * t r a n with a fine geometry: (*pict*tran '((trans
XY) ( p r e c t (0 . O) (0.1
. 0.1)))
' ( ( * p i c t * c a l l *A , (*mat*scal 0.1 0 . 1 ) ) '(*line
(0.15
. 0.25)
(0.4
. 0.5)
(0.6
. 0.5)
(0.9
. 0.80)))
The symbol *A is assumed to be assigned to a picture by using * d e f * p i c t as in Example 5.5. This example explicitly specifies that a zy-transformation should be used in the pictorialization. The system of pNucleus evaluates the above V-expression to a P-expression of a similar form. This
C H A P T E R 5. I M P L E M E N T A T I O N OF A GRAPHICAL NUCLEUS
60
1.0
0.5
m
0
0.5
i
1.0
Figure 5.6: Pictorialization of a Line Geometry P-expression is considered to represent the picture, as shown in Figure 5.6.
5.6
[]
B a c k e n d Display F u n c t i o n - - p e v a l
The function p e v a l takes a P-expression and converts it into a visual representation on the display media, which in our implementation of pNucleus are a black-and-white bitmap display and a laser printer . The function p e v a l is realized as follows: 1. When the first element of a P-expresslon is *p±ct, p e v a l converts it into a visual representation by issuing commands dependent upon a target output device. 2. When the first element of a P-expression is * p i c t * t r a n , peval performs actual pictorialization. Let p, ra, and r be the pattern, the matrix, and the sequence of restrictive geometries in the P-expression. Then, peval constructs a set of transformation matrices for a replication and, for each matrix ml, generates a P-expression by geometrically transforming p by m i × m and appending r to the transformed p. This P-expression is pevaled in turn. 3. When the first element of a P-expression is *pict*sum, p e v a l applies itself recursively to the component P-expressions in order. 4. When the first element of a P-expression is * p i e r * c a l l , p e v a l applies itself recursively to its definition. Let ra and r be the matrix and the sequence of restrictive geometries in the P-expression. Then, p e v a l generates a P-expression for each picture in the definition by geometrically transforming it by m and then appending r to the result. This P-expression is
pevaled in turn. The distributivity of rasterization over the picture sum is intensively used in this algorithm. In
5.6.
BACKEND DISPLAY FUNCTION -- PEVAL
61
addition, Claim 2 indicates that the evaluation of a picture eventually reaches that of a picture created by a pictorial primitive. The routine for handling the first case is therefore regarded as the lowest and most device-dependent portion in the implementation of pNucleus.
Chapter Extending
6
a Graphical
Nucleus
The system of pNucleus is open and {ranspareat: any intermediate result within a visualizing net is represented as a G- or P-expression and is accessible to users of pNucleus. This is in contrast to most graphics systems, where there is no access to the data during its processing in the viewing pipeline. The intermediate accessibility of a visualizing net, together with variability in organization, makes pNucleus an extensible system. The broader range of visualization can be realized on the pNucleus. We discuss in this chapter a couple of possible and useful extensions to pNucleus. First, we deal with the simulation of a conventional graphics interface that seems concise in its input form. Second, we describe how to realize a general type of picture storage that allows any number of storages within a visualizing net. Finally, we present a text drawing method as a general picture arrangement facility.
6.1
Simulating a Conventional Graphics Interface
We get pNucleus to do some drawing by supplying a V-expression. This not only contains objects such as matrices, geometries, and pictures, but also represents the organization of a visualizing net. The latter is required because it is variable. On the other hand, the users of a conventional graphics system only have to supply graphical objects. The reason for this is simply that the viewing pipeline is predefined and fixed. In addition, the representation of such graphical objects is generally more concise or partly specified. The system holds an environment - - a set of state variables whose values are assumed to be less often varied. During the visualization processing, the system binds them to the initial representations to obtain a larger, more complete representation. Most systems hold attributes and matrices for geometric transformations in their environments. We can realize such conciseness in pNucleus~ too, by providing a filter that holds state variables. When the filter receives input acts to change the value(s) of some state variable(s) or generate an output (normally a V-expressions), or both.
CHAPTER 6. EXTENDING A GRAPHICAL NUCLEUS
64
For example, consider polyline in GKS. The following V-expression can be considered to represent a simplified version of a visualization of the GKS polyline primitives illustrated in Figure 3.6. The number of geometric transformations is reduced to one. (*rtran*pict ' ( * a r e a (0 . 0) (1 . 0) (1 . 1) (0 . l ) ) (*pict*tran '((prect
(0 . 0) (0.01 . 0 . 0 1 ) ) )
' ~ ( * p i c t * c a l l Dotted , U n i t * M a t r i x ) (*gtran*geom Matrix '(*line
(0.2 . 0.2)
(0.8 . 0 . 8 ) ) ) ) )
The symbols Dotted and Matrix are a picture name referring some appropriate pattern, and a matrix for the normalization transformation: respectively. The corresponding representation in the GKS system would be something like ( P o l y l i n e (0.2 . 0.2)
(0.8 . 0 . 8 ) )
if it were represented in list structures.
During the visualization, it is successively refined by
retrieving from the environment the current values of line type~ normalization transformation, clipping rectangle, and so on. The filter can then be realized in pNucleus. It holds three state variables, P a t t e r n P i c t u r e , Matrix, and R e c t a n g l e , and accepts the following forms of input: (SetLineType < l i n e type>) (SetLineWidth < l i n e width>) (SetLineColor ) ( S e t N o r m a l i z a t ionTr arts format i o n <matrix>)
(SetClippingRectangle
<point> <point>)
(Polyline {<point>}) . The first three commands change the value of p a t t e r n P i c t u r e , while the fourth and the fifth vary Matrix and Rectangle~ respectively. The final form of input causes the system to generate the abovementioned V-expression. Subsequently, this V-expression will be evaluated to a P-expression, which will in turn be delivered to the function p e v a l for further processing. It is possible to embed such a filter in the system, since the data representations are 'open' in
6.2. PICTURE STORAGE
65
pNucleus: they are just V-, G-, and P-expressions. The users can obtain any intermediate result of one visualizing net, process it, and enter it into another visualizing net.
In this sense, the
visualizing net in pNucleus can be said to be ~ranspavent This transparency is far from being achieved in conventional graphics systems: those systems can do nothing but the fixed viewing process it supplies, and users can never customize it.
6.2
Picture Storage
The picture storage explained in Section 1.2.3 can also be realized in pNucleus. Our picture-storing facilities can, however, place any number of storages between any two adjacent transformations in a visualizing net. Each storage will contain intermediate results taken from a visualizing net, depending on the position of the storage, as groups with their own names.
The intermediate
accessibility of pNucleus makes it possible to access these intermediate expressions, while picturenaming facilities enable the expressions to be stored as a group. As the initial representation of GKS polyline, graphical objects in a storage may have their own representations. We call these
s~ovage representations. The implementation of a storage is given by three translators.
The first translator converts an
initial representation into a V-expression, which represents a visualizing net obtained by chopping off the whole visualizing net at the position of a storage. The V-expression is evaluated to a G- or P-expression. The second translator converts the G- or P-expression into a storage representation. This is placed in the picture storage by picture-naming facilities. The third translator converts the storage representation into a V-expression representing an invocation of the rest of the visualizing net. The V-expression is evaluated to a P-expression and the result is dehvered to the function p e v a l . All these operations are illustrated in Figure 6.1.
E x a m p l e 6.1 Let us consider again the GKS polyline. One storage is placed in GKS between * g t r a n * g e o m and * p i c t * t r a n . Three translators can then be realized as follows. The first translator holds a state variable M a t r i x and coverts an initial representation such as (Polyline
(0.2
. 0.2)
(0.8
. 0.8))
into a V-expression such as (*gtran*geom M a t r i x
'(*line
(0.2
The V-expression is evaluated to a G-expression (*line
(-0.2
. 0.2)
(-0.8
. 0.8)).
. 0.2)
(0.8
. 0.8))).
CHAPTER 6. EXTENDING A GRAPHICAL NUCLEUS
66
initial representation -- •-1st Translator ----~
V-expression "
l eval 2rid Translator-, [G-,P-expression]
I
storage representation " ' ~ 3rd Translator
peval ~
,~[ V-expression J l eval P-expression [
Figure 6.1: Conventional picture storing by pNucleus The second translator holds four state variables, LineType, LineWidth, L i n e C o l o r and R e c t a n g l e , and converts the G-expression into a storage representation such as (Polyline
Lt Lw Lc ( - 0 . 2
. 0.2)
(-0.8
. 0.8) R e c t ) ,
where Lt, Lw, Lc, and Rect denote the current values of the above four state variables in order. This storage representation is one possible representation of a polyline in GKS segments.
The
third translator converts the storage representation into a V-expression such as (*rtran*pict Rect (*pict*tran '((prect
(0 . 0) (0.01
. 0.01)))
' ~ (*pitt*call
Dotted
,Unit*Matrix)
'(*line
. 0.2)
(-0.8
(-0.2
. 0.8)))).
The picture D o t t e d is assumed to be selected through Lt) Lw~ and Lc.
6.3
[]
Generalized Texts
Although pNucleus has no geometric primitive corresponding to a text primitive, most graphics systems provide text drawing as a graphical output primitive. For example, a text is drawn by invoking the function TEXT with a text position and a character string as parameters, such as (TEXT ( 0 . 5
. 0.5)
"ABC").
The appearance is controlled by a set of attributes, such as text font, text precision, character expansion factor, character spacing, text color, character height, character up vector, text align-
6.3. G E N E R A L I Z E D T E X T S ment, and text path.
67
We do not describe the details of how these attributes collectively and
interdependently (not independently) control the visual representation of a text. Since the representations of the characters are drawn successively in the text parallelogram containing the entire graphical representation of a string, the implementation of text drawing can be considered to contain a procedure that generates pairs of a picture and a matrix from the values of parameters and attributes. A picture contains the graphical representation of a character in a font description coordinate system, while a matrix is constructed so that a definition rectangle in the font coordinate system is mapped onto a parallelogram where the graphical representation is located. This notion immediately leads to our implementation of a text. We simply use a translator that accepts as input the above set of parameters and attributes in GKS to output a number of Pexpressions of ( * p i c t * c a l l <matrix>). We call a text thus realized by the translator
a generalized ~ezt, because, as we mentioned in Section 3.3.5, the pictures are not always restricted to those for graphical representations of characters. The system of pNucleus provides the translator as one of the general picture arrangemenl faciligies.
Chapter
7
Conclusion
A great deal of effort has been made to standardize graphics systems in the last decade. It is natural that these systems tend to be greatly affected by the current technological constraints and by existing graphics hardware and software. For instance, the designers of CGI tried to cover as many kinds of graphical terminaIs as possible, which resulted in a very rich set of the functions at the interface without any systematic view and without much theoretical consideration. The above view is supported by the thick and incomprehensible documents specifying the systems. We took a different approach in devising a visualizing net and a graphical nucleus, and tried to be as little influenced as possible by the current status of graphics hardware. Visualizing Net We have proposed in this book the first formal model of visualization in the kernel systems of computer graphics. This involved the identification and formalization of basic concepts in graphics systems, which were presented as an unified and axiomatic system. Having established the model, we can present a precise description of a graphics system in terms of the model, including the system's semantic features. In addition, as Chapter 3 shows, we can compare one graphics system with another on the basis of the model. The presented model is sufficiently concise and comprehensive to be the center of the documentations. Graphical Nucleus We did not simply give a formalization of a graphics system, but also presented a new generation graphics system, which derives from the model of a visualizing net. Abstracting attribute rendition as a pictorializing transformation brings about an expressive drawing technique,
geometry-driven drawing,
which is not only practical but also theoretically backed
up. Fig 7.1 shows various pictorialization of a line geometry, all of which can be drawn as simply as dotted lines. The routine drawing the pie chart in Figure 7.2 can be embedded into pNucleus as part of the general picture arrangement facilities if it is realized as a pictorialization of a polygon geometry in which a pattern is positioned at the center of gravity of the polygon. The routine
70
C H A P T E R 7. C O N C L U S I O N
would be implemented 'outside' the viewing pipeline in a conventional system. This implies that, in conventional systems, geometric transformations to the pie chart itself, if necessary, would have to be done on the side of the application program. Such capabilities on the side of a graphics system could not be used. In pNucleus, however, they can be treated within a visualizing net. It is not sufficient to provide hardware facilities, such as matrix multiplication, for geometric transformations; it have to be possible to extend functions of pictorialization. Note that we can further generalize the concept of a pictorializing transformation as long as it remains a mapping from P×GtoG.
A graphical nucleus is literally a core of graphics systems. The higher-level features of a system should be built up from it, as suggested in Section 6. The variable organization of transformations and the accessibility of intermediate results allow such extensibility. A graphical nucleus can treat a wider range of viewing processes than conventional systems. We take the example of three-dimensional graphics to demonstrate the usefulness of a visualizing net, although at present pNuclens handles only two dimensional graphics. The process of hidden line elimination [17] is usually implemented either to eliminate all the hidden lines or draw them as dotted lines. The GRIP system [18] performs more sophisticated hidden line eliminations where users acquire control of the process of deleting hidden lines. For instance, they can specify that lines hidden by more than one object are ehminated and that lines hidden by only one object are drawn as dotted-dashed lines. They can also specify that only lines hidden by a certain specific object are deleted. The current implementation of GRIP uses graphics terminals based on Core or GKS. However, it only uses them as if they were vector generators, because of the fixed viewing pipelines. Another implementation would be possible in a visualizing net. Although we admit that current hardware technology might not allow a graphical nucleus to be an efficient system, this kind of an open and transparent system is long-expected. Future Work The rasterization we touched on in Section 4.3 and the handling of aspects peculiar to threedimensional graphics, such as modeling, are under consideration. We are currently considering the introduction of rasterized pictures as a third type of graphical object. We will have to define transformations over them separate from those on geometries or pictures.
m~
L~
o
r~
o
o~
C~
I-
,i
0
,
D
8
c~
o
c~
c:)
*8
~o
73
Figure 7.2: Pictorialization of a polygon geometry.
Appendices
Appendix A Proofs of Propositions and Theorems
This appendix contains the proofs of the propositions and theorems in Chapter 2. Our reasoning is based on first-order logic. In particular, we intensively use the following equalities involving existential quantifiers: (A.1)
( 3 z : S(~) Vg(~)) = ( 3 z : S(~)) V ( 3 ~ : g(~))
(A.~)
( 3 ~ : S(~)) A ~(~) = ( ~ : S(~) ~ ~(~))
First, we prove the associativity of the domain-priority-sum and image-priority-sum. Let 71, 72, and 73 be correspondences from M to N. Then, 1. 77773+ (77772+ 7777,)= (77773+ 7~) + 7777, 2. 77773• (77772• 7777,)= (7~ • 77772)• 7,.
Proof.. We prove that the graphs of both sides are equal in either case. 1.
Gr (77773+ (75 + 71)) = { ( z , y ) ] ( z , y ) • Gr (72 + 7777,)V ( ( z , y ) e Gr 73 A z ~ Dora (72 + 77771))} ={(x, y)]((z, y) • Gr 77771V((~,y) • Gr 77772A z ~ D o m 71)) V ( ( z , y ) e Gr 73 A z ¢ Dora (72 + 71))} ={(x, y)l(z, y) • Gr 77771V ((z, y) • Gr 72 A x ~ Dom 77771) v ((~, y) • Gr 73 A • ~ (Dom 77772u Dom 7,))}
(2.m
Gr ((77773+ 72) + 7777,) ={(~, Y)I(~, Y) • Or "~, V (((~, y) • Or 72 V ((~, y) • Or 7~ A • ¢ Dom 7~)) A ~ ~ Dom 7,)} = { ( ~ , y ) [ ( ~ , y ) • Gr 7, V ((~,y) e Gr 72 A z ~ Dom 7,) V ((x,y) • Gr 73 A z ~ Dom 3'5 A ~c ~ Dom 7777
2.
Or (73 • (77772• 7,)) ={(z, y)[(z, y) • Gr (75 @ 7,) V ((z, y) E Gr 73 A y ~ Im (7~ ~ 7,))} : { ( z , y)l((x, y) • Gr 71 V ((z, y) • Gr 77772A y ¢ I m 71)) V ((z, y) • Gr 77773A y ¢ Im (72 * 7777,))}
={(~, y)l(*, y) • Or 7, V ((~, y) • Or 7~ A y ¢ Im 7,) v ((,~, y) • Or 7~ ." .~ ¢ ( I ~ "-,,~U Im 7777,))}
(2.16)
Or ((7~ • 72) • 77771)
={(~, y)l(~, y) e Or 7, V (((~, y) • Gr 77772V ((~, y) • Gr 7777,A y ~ Im "~)) A y ¢ Im 71)} ={(~, y)l(~, y) ~ Or 71 V ((~, y) e Or 77775A y ¢ Im 7,) V ((~, y) • Or 73 A y Z Im 7~ A y ¢ Im 77771)} The above transformations have now shown that the two graphs are equal in either case.
[]
78
APPENDIX A. PROOFS OF PROPOSITIONS AND THEOREMS
Proposition
1 Let T = ( G , M , N ) , A C M and B C M .
1. ~(A
u
B) = ~(A)
u
~(B).
2. 7(A
n
B) c ~(A)
n
7(B).
3. 7(A n B) = 7(A) n 7(B)
if 7 is divergent.
Proof: 1.
y • "y(A U B) ~--,(3x : z • A U B A y E 7(~)) ~ ( 3 ~ : (z e A v ~ • B) A y e 7(z)) ~ ( 3 ~ : ~ • A A y • 7(~)) v (3~: • • B A y e 7(~))
(A.1)
~ y e 7(A) v y • 7(B) ~ y • 7(.4) u 7(B) 2.
y E ~(A n B) ~ ( 3 ~ : ~ e A n B A y e 7(~))
~ ( 3 ~ : (x • A A y • 7(x)) A (z E B/~ y • 7(:c))) ---*y • ~(A) A y • 7(B) ~ y • ~(A) n 7(B) 3. It is enough to infer y • 7(A n B) from y • ~(A) ~ 7(B). y e 7(A) n 7(B) ~ ( 3 z , : x, • A A y • ~'(x,)) A ( 3 z 2 : z 2 • B A y • 7(z~)) If x~ ~ ~2, then [7-~(y)[ ) 2, which contradicts the assumption that 7 is divergent. Hence,x,(= x2) • A N S and y • 7(A N B).
[]
P, r o p o s i t i o n 2 Let 7 = (G, M, N) and A C M. 1. 7 - ' ( 7 ( A ) ) D A N Dom 7-
Proof: 1.
zEAADom7 ~ ( 3 y : ~ e A A y e ~(~) A ~ e ~ - ' ( y ) )
(a)
~ ( ~ y : ~ C 7 ( a ) A ~ e 7-'(Y))
(b)
~
e 7-'(7(A))
2. It is sufficient to infer (a) from (b). The predicate (b) is equivalent to what follows. (~y: (3a: a e A A y e 7(a)) A y • ~(~))
(b9
Since 7 is divergent, we can infer from this that z = a and that (b') implies (a).
[]
79
P r o p o s i t i o n 3 Let 7 = (G, M, N) be divevgenl. For any R C M, (7IR) -x = 7-xlT(R).
Proof: We prove that Gr (7JR) -1 = Gr (7-117(R)). We first transform the (L.H.S) and (R.H.S) as follows: Gr (TIR) -~ ={(y, x)l(~, y) • Gr (TIR)} = ( ( y , ~)1(~, y) • Gr ~ A • • R}
Or ( ~ - ' I'y(n)) ={(Y, ~)!(~, y) e Gr ~ A y • ~(R)} = { ( y , ~)ly • "y(~) A y • ~(R)}
(b)
Since (y e 7(~) A x • R) --~ y ~ 7(R), we can verify from (a) and (b) thai Gr (TlR) - ' C Gr (7-117(R)). On the other hand, e 7-~(~) ~ ~ • 7(R)
~
• ~-~(7(R))
- - ~ G R ~ Dom 7
(Prop. 2)
Together with (c) and (a) this shows that Gr (TIR) -* D Gr (7-*[7(R)). Hence, the conclusion.
[]
P r o p o s i t i o n 4 Let 7~ = (G, M, N), 72 = (G, M, N), and R C M.
I. rh~ ~quality (-y~ + ~'i)ln = (~,~IR) + ('~IR) hour.
2. The equality (72 q~71)1R = (721R)@ (TxIR) holds if 7 t ( R ) = Im 71. Proof: We show that the graphs of both sides are equal. 1.
Gr (72 + 71)IR = { ( ~ , y)l(~,y) e Gr (-y~ + "~1) A ~ • .~) = ( ( ~ , Y)t((~, Y) • Gr 71 v (Gr 72 A ~ ~ Dora "~1)) A • • R}
={(~, Y)l((~, Y) • Gr "y, A • • R) v (Or 72 A ~ ¢ Dora 71 A ~ • R)) Gr ((TuIR) + (711R)) ={(~, y)](:~, y) • Gr 7,1R V (Gr 72]R A x ~ Dom 7,IR)} ={(x,y)]((~,y)•GrTxAx•R)
v (Gr 7 2 A ~ • R A x ~ R n D o m 7 1 ) }
(2.11)
Since x • R A ( z ~ R N D o m 71) ~ ~ E R A x ({ Dom 71, we could now prove the two graphs
A P P E N D I X A. PROOFS OF PROPOSITIONS AND T H E O R E M S
80 are equal. 2.
Gr (3'2 • 71)[R
--{(~, y)l(~, y) E Gr (72 @ 71) A x E R} ={(~,y)l((x,y) E G r 7, V ( G r ' ) ' 2 A y ~ I m ~ h ) )
A x ER}
= { ( ~ , y)l((~, y) ~ Gr ~, A ~ E R) v (Gr ~ ~ ~ d Im ~, * x E R)}
G, (('~21R) • b , lR)) --{(~, y)l(~, y) e Gr 7,IR v (Gr 721R A y ~ ~m 711R)}
(2.12)
={(~, y)l((~, u) e Gr 7, A x E R) V (Gr ~'~ A x e R A y g 7,(R))} From the assumption, we can conclude that the two graphs are equal.
T h e o r e m 1 Leg 71 = (G1, M1, M2) and "y~ = (G2, Ms, M3). The equality (72fR~) o (7,JR,) =
(72 o 71)t(7;'(R2)
n R,)
holds if and only if 71 is convergent. Proof:
Let us compute the graphs of both sides and prove them to be equal.
Gr (721R~.) o (7, [R,)
= { ( x , , x3)l(qx2 e M2: (~1, x2) e Gr 7, A z, E R, A (=2, xa) E a r "f~ A :c2 E R2)}
Gr (72 o 7,)I(Tj-'(R2) n R,)
Since ( ( , , , ~=) e Gr S, A ~, e R=) -~ ~, e S?'(R=), we can ~tate that Gr (72lR2) o (7,IR,) c Gr (72 o ~ , ) I ( ~ - ' ( R , ) n R,). O n the other hand,
(x,, z2) e Gr 7t A x, e "7~-'(R~) r] R,
---~z2 E R2 A Dora 7~-1
(Prop. 2)
----*Z2 E R2
It is 7 -1 that is divergent when Proposition 2 is applied. This shows that Gr (7~IR~) o (TtIR1) D Gr (7~ o 71)l(7i-'(R2) n R1). Since we have already shown in Example 2.4 that the equality does not hold if 7, is divergent, we have proved the theorem.
[]
81 Theorem
2 Let 7, = (G1, M,, M2), 3'2 = (G2, M,, M2) and 3"3 = (an, M2, M3). The equality
3"~ o (~2 • > ) = (3"3 o 3"2) e (3"3 o 3"1) holds if and only if 3"3 is divergenL Proof:
We show that the graphs of both sides are equal.
Gr % o (3'2 @ 3',) = ( ( z l , za)[(3z2 G M2: (z,, a%) G Gr (3'2 @ 7,) A (z2, za) G Or %)} = { ( z l , xa)[(3z2 E M2: ((zl, z~) e Gr 71 v ((x,, z2) E Gr 72 A x2 i~ Im 3'1)) A (~2, za) E Gr %)}
(3z2 E M2: (zl, z2) E Gr 3'2 A z2 ~ Im 3', A (z2, za) E Gr 3'3)}
(A.1)
~r (3'3 o 3"2) • (3", o > ) = { ( z , , za)l(za, ~a) 6 Gr (3"a o 3',) v ((z,, ~za) e Gr (% o 3'2) A xn £ Im 7a o 71)} = { ( x , , za)l(3z2 E M2: (~1, =2) G Gr % A (x2, z3) G Gr 3'3)V ((3x2 e M~: (z,, z2) G Or 3"2 A (z2, z3) G Gr %) A z3 ~ %(Im 7,))}
(2.8)
(3x2 G M2: (z,,x2) e Gr % A (~2,~a) G Gr % A xa ~ 3's(Im 3'1))}
(A.2)
Thus, it is sufficient to prove that ((x2, z3) G Gr 3'3 A z2 ¢ I m 7~) ~-+ ((x2, as) G Gr 3"3 A a~s ~ %(Im 3"~)).
(a)
It is self-evident that (L.tt.S) is implied by (R.H.S). We have only to infer (R.H.S) from (L.H.S). We show this by contradiction. Assume za e 3'3(Im 7~). When,(3a : (a, z3) e Gr 7a A a ~ Im 71)Since 3'3 is divergent, we can conclude that z2 = a and that z2 G Im 3't. This is a contradiction. Since we have already shown in Example 2.5 that the equality does not hold if % is convergent, we have proved the theorem.
Proposition
[]
5
1. When % and 72 are a total correspondence, 2. When 71 and 72 are a mapping,
~[1
(72o71)= = 3 " ~ o 7 ;
3. W~en 71 and 72 are a correspondence, Proof:
%-5"3"1 ---- 2~20
3'2 o~71 = ")2 o "~1
We only prove the third: the others are easily verified. We show that
(Vp C F ( M , N ) : (%'-~3',)(p) = (% o "h)(p)).
Gr (3'~
o
3',)(p)
= G r p o (3'2 o 3"1)-1
(2.23)
={(-~,n)l(3m' : (.~, m') e ¢ r (3';1 o 3';,) A (m',n) e Gr p)}
(2.6)
82
APPENDIX A. PROOFS OF PROPOSITIONS AND THEOREMS
Or (~s o ~,)0) =Gr (@l(P) o 3'~-1)
(2.23)
= { ( m , ~ ) l ( 3 ~ , : ( m , ~ , ) • Gr 3"e* A (m,, ~) • er ~,0))} ={('~,,01(3m, : (.~,m,) • Gr 3'~-i A (m,, n) • Or (p o 3';'))} ={(-~,,~)1(3~, : (~,m,)
e G , 3";'
A (3~:
(2.23)
(m,, ms) e G. 3"~' A (.~,, n) e Cr Z))}
= { ( m , ~ ) l ( 3 ~ l : (3ms: (m, mi) • Gr 3'fl A (m,, m2) • Gr 7[-I A (ms, n) • Gr p))}
(A.2)
={(m, n)l(3ms : (qmi : (m, ml) • Gr 3'~-1A (m,, ms) • Gr 3'~-1A(ms, n) • Gr p))}
(A.3)
={(-~, ~)l(3m~ : ( q m l : (m, ml) • Gr 3'~-1A (ml, ms) • Gr 7~-i) A (ms, n) • g r p)}
(A.2)
----{(m,n)l(3ms : (re, ms) • or (3';' o 3'~')A (m~,,~) • Or p)} The graphs have now been proved equal.
[]
T h e o r e m 3 Let 3' = (G~, M, M), Pl = (Gi, M, N) and P2 = (Gs, M, N). 1. The equality 7(Ps + P , ) = "}(Ps)+ "~(Pl) holds if 7 is dlvergeul. The equality ~(p~ e p,) = ~(p~) e ~(m) holds i f 7 i, d i ~ e w ~ ~ d Dom 7 = D o m m -
2.
Proof: 1. Let us prove the graphs of the two sides to be equM. Gr ~'(P2+ Pl) =Gr (Ps + Pl) o 7 -1
(2.23)
={(m, n)l(3mi : (m, mi) E Gr 3"-' A (mi, n) G Gr (P2 + Pl))}
= { ( . . , n)l(3m, : (m, m,) • Gr 3'-' A ((m,,,0 • Gr p, V ((m,, ~) • a. Ps A m, ~ Dora p~)))} ={(m, ~)l(3m, : ((.~, m,) • Gr ~-'
(m,,~) • O r p,)v
A
((m, ml) • Gr 3"-1A (ml,n) • Gr p2Aml ~Dom Pl))} ={(-.,,01(3m, : (re, m,) • Or 3"-'
A
(m,, n) • Gr p,)v
(3m,: (m, ml) • Gr 7-i A (ml, n) • Gr P2 A m i d Dora Pi)}
(A.1)
={(-~, =)1(~, ~) • a r ~O,)v
(gmi : (m, ml) • Gr 7 -1A (ml,n) • Gr P2 Aml ~ Dom Pl)}
(2.23)
~r (~Os) + ~(p,)) ={(m, n)[(m, n) • Gr 7(Pi) V ((m, n) • Gr (Ps o 3'-1) A m d Dom (Pl o 7-1))}
(2.23)
={(m,n)[(m,n) • Gr ~(pl)V ((Bml : (m, ml) • Gr .y-1 A (ml, n) • Gr P2) A m ~ 3"(Dora Pl))}
(2.7)
={(m, n)l(m ,n) E Gr ~(pl)V
(gm~ : (m, m,) • Gr 7-'
A
(ml, n) E Gr p2 A m ¢ 7(Dora p,))}
By the same reasoning about the predicate (a) in Theorem 2, we can verify that
((ml,m) • Gr 3' A ml ~ Dom Pl) ~ ((m,,m) E Gr 3'A m ~ 3'(Dom Pi)),
(A.2)
83 since =/is divergent. This is equivalent to the following:
((m, ml) e Cr =/-1 A ml Z Don, Pl) ~ ((m, ml) e ¢r =/-1 A m Z =/(Dom Pl)). The two graphs have now been proved to be equal. 2. Similarly, we prove the equality of the graphs of the two sides.
Gr ~(P2 • pl) = G r (p~ ~ Pr) o =/-1
(2.23)
={(m,n)](3ml: (m, ml) • Gr =/-1A((ml,n) • Gr P l v ((ml,n) • Gr p 2 A n t i m Pl)))}
={(~,~)1(3m1 : ((re, m1) • Gr =/-1A (ml,=) • ar pl)v
((re, m1) • Gr =/-1A (ml,n) • Gr p2An ~ Im Pl))} ={(-,,~)1(3~1
: (m,-~l) • Gr =/-1 A (-,1,~) • Gr pl)V
(3ml : (m, ml) • Gr =/-1 A (ml,n) • Gr P2 A n ~ Im Pl)}
(A.1)
={(~, ~)1(-~, ~) • Gr ~(pl)v (3mi : (m, ~1) • Gr =/-1 A (..1, ~) • Cr p~ A ~ ~ Im Pl)}
(2.23)
Gr (~(P2) G) ~(pl)) : { ( m , n)[(m, n) • Or 7(P1) V ((m, n) • Gr (P2 o 7 -1) A n ~ Im (Pl o ?-1))}
(2.23)
={(-~,=)l(m,n) • Gr ~(pl)V ((3ml : (m, ml) • Gr =/-I A (ml,n) • a r P2) A n ~ pl(Dom =/))}
(2.8)
={(-., ~)l(m, ~) • Gr ~(pl)v (2ml : (re, m1) • Gr =/-1A(ml,n) • Gr P2 A n ~ pl(Dom =/))}
(A.2)
Since pl(Dom =/) = Im Pl from the suppositi0u~ we can conclude that the two graphs are equal.
T h e o r e m 4 Let 71 = (G1, M, M), =/2 = (a2, M, M) and p = (Gp, M, N). The equalily
(=/2 • =/1)(p) = ~2(p) + :yl(p) holds if Dora =/1 = Dora p. Proof: Let us prove the graphs of the tow sides to be equal. Gr (=/~ e =/1)(p) = G r (p o (=/2 • 71) -I)
(2.23)
= G r (p o (=/~i+ =/~-,))
(2.14)
={(m,n)l(3ml : ((m, ml) 6 Gr =/~-1V ((m, rnl) 6 Gr =/~-i A m ~ Dom =/~-1)) A (ml,n) G Gr p)} ={(m, ~)1(3ml : ((-~, ~1) c Or =/~1A (ml,~) e Gr p)V ((re, m1) E Gr =/~-1A m ~ Im =/1A (ml,n) E Gr p))}
(2.3)
84
A P P E N D I X A. PROOFS OF PROPOSITIONS A N D T H E O R E M S
= { ( ~ , ~)E(-~,~) c Gr (po ~;-') A ( 3 ~ , : ( m , ~ l ) e O,: ~i-' A ~ ~ h-. ~, A (,~,,n) ~ Gr p)}
G, (~(p) + "h(p)) =Or (P o -~;' + p o ~ ; ' )
(~.23)
={(-~, ,01(,~, ~) c or (p o ~i-1) v ((~, ~) c Cr (p o ~ ; 9 A ~'~ ~ Dora (p o % 9 ) }
(3,~, : (,~, m,) c Cr ~ ' A (m,,n) e Or to) A m ¢ ~,(Dom to)}
(2.7)
={(m, ~)l(m, n) e Or (to o ~?')v
(3m,
: (m, ml) G Gr "/~-' A (ml, '/%)~ GE to A Tit ~ "~q(Dom tO)))
(A.2)
Since the condition of the theorem, Dora 7x = Dom to, is equivalent to Im 7~ = 71(Dom p) if 7x is divergent, we can infer that the two graphs are equal. Hence, the conclusion.
[]
Appendix B p N u c l e u s Reference M a n u a l
B.1
Introduction
The system of pNucleus runs under UNIX 4.3BSD I on Sony NEWS. The machine is equipped with one black-and-white bitmap display and a laser printer, on both of which graphics can be drawn with the paradigm of the visualizing net. In short, the system can interpret a V-expression and transform it into a P-expression, and cau pevaI the resulting P-expression to generate its final representation on either of the two visual media.
B.2
Starting the pNucleus System
Most of pNucleus is written in Franz lisp. Before you can run it, you usually have to type the program name l i s p after the UNIX Shell prompt. Once you have succeeded in entering the Lisp system, you can load the pNucleus system into the Franz Lisp system by issuing the command ( l o a d 'pNucleus) after the Lisp prompt. By default, graphics is drawn on the NEWS bitmap display. To switch from one display medium to the other, the system provides two files called device files. If you want to draw on the laser printer, you should order the system to do so by issuing the command ( l o ad ' l a s e r ) .
If you want to
go back to drawing on the bitmap display~ you should type the command ( l o a d ' b i t m a p ) . Note that you should load device files outside the brackets of the pNucleus commands ( * G i n i t ) and (*Gterra). (See also the next section.)
B.3
Functions
This sect;on describes the functions that the pNucleus system provides for you. We follow the notation of Franz lisp manual [20]. Each argument has a name beginning with a letter or letters and an underscore. The letter(s) indicates the allowable data type(s) for that argument according to Table B.I. Data types marked with an asterisk are original in the Franz Lisp system, while the others are those in the pNucleus system whose structures are formally specified in the next section. Arguments preceded by a single-quote are supposed to be evaluated before the function is called. 1UNIX is a trademark of Bell Laboratories.
APPENDIX B. PNUCLEUS REFERENCE MANUAL
86
~
Allowable type G
geometry
A
area geometry
P
picture
T
point
M
matrix
N
picture name
C
control list
n
number*
Table B.I: Data type notation The system of pNucleus provides *gtran*geom~ *rtran*geom: * g t r a n * p i c t , a n d * r t r a n * p i c t as functions~ while * l i n e . *point, * l a t t i c e , *area, * p i c t , and * p i c t * c a l l are simply keywords with which the data structures are constructed. The symbols * p i c t * t r a n and *pict*sum are used both as functions and as keywords. B.3.1
Control Functions
(*Ginit) RETURN:
t.
SIDE EFFECT:
This starts the driver process of the currently selected device (the bitmap display
or the laser printer) to produce the visual effect on the device. NOTE:
The driver process is executed in the background. All the subsequent outputs of the
function p e v a l are arranged to be delivered to this process for further device-dependent processing. The process to be invoked is stored in the system variable *tier*process, whose value is dependent on which of the two device files was last loaded. (See also the previous section.)
(*6term) RETURN:
t.
SIDE EFFECT:
This terminates the driver process started by ( * G i n i t ) . Hereafter, the function
p e v a l has no visual effect on either display medium.
(*Gclear) RETURN:
nil.
B.3. FUNCTIONS SIDE EFFECT:
87
This clears the visual media. For the laser printer, it involves the medium being
advanced and being made ready for the next output, which means that any drawings are accumulated and that the printer produces no output until this command or (*6term) are issued. B.3.2
Graphical Functions
(peval 'P_pict) RETURN:
nil.
SIDE EFFECT:
This produces the visual representation of the picture P_pict on the dis-
play medium through the corresponding driver process, which is supposed to be started by (*Ginit). NOTE:
There is no concept of a specificcoordinate system such as the world coord!nate system
(WC) in GKS. You are, however, supposed to construct a picture to be pevaled in [0,1] × [0 , 1] so that you can obtain device independence in producing a picture. The coordinates are adjusted to the currently-selected device in this function. The system variable *dev*matrix holds this transformation matrix.
(*gtran*geora 'MJaat 'G_geom) RETURN:
the geometry into which the geometry G_geomis geometrically geometry-transformed
with the matrix M_mat.
(*rtran*geora 'A_geom 'G_geom) RETURN:
the geometry into which the geometry G_geora is restrictively geometry-transformed
against the geometry A_geom.
(*gtran*pict RETURN:
'MJaat ' P _ p i c t )
the picture into which the picture P_pict is geometrically picture-transformed with
the matrix Mnnat.
(*rtran*pict RETURN:
'A_geom ' P _ p i c t )
the picture into which the picture P_pict is restrictively picture-transformed against
the geometry A_geom.
(*pict*tran 'C_list ~P_pict 'G_geom)
88
A P P E N D I X B. PNUCLEUS R E F E R E N C E M A N U A L
RETURN:
the picture which is built up by replicating along the geometry G_geom the pattern
specified by P_pict. NOTE:
The replication is controlled by C_clist. The contents of ¢ _ c l i s t and the ways in
which they control repfication are dependent upon G_geora. 1. When G_geom is a point geometry, the pattern is replicated by translating it to each point in a point geometry. The translation vector is given as the one from the attentior~ point of the pattern to the point in a geometry. The default attention point is (0.5, 0.5), since the system assumes that the pattern lies within [0, 1] × [0, 1]. The valid element C_clist is as follows: (a) ( a t t e n p <point>) tells the system that the attention point is as specified. 2. When G_geom is a lattice geometry, the pattern is replicated in each cell of the lattice geometry by an affine transformation that maps the pattern rectangle onto each parallelogram of a cell. The default pattern rectangle is [0, 1] × [0, 1]. The valid element in C_clist is as follows: (a) (prect <point> <point>) overrides the default pattern rectangle and changes it to the one whose two diagonal corners are given as specified. 3. When G_geomis a llne geometry, the replication of a pattern is performed in two steps. The first is called sectioning, and develops the sections along a llne geometry. The sections are made as congruent to the pattern rectangle as possible. However, sectioning entails generating of fractions of a rectangle or even trapezoids. The default pattern rectangle is [0, 1] × [0, 1]. The second step is to map the pattern rectangle to each of the sections. When the target section is a fraction, the corresponding fraction of the pattern is mapped. When the target section is a trapezoid, either two-dimensional projective transformation or zy-transformation is used. The default is the latter. The valid elements in C_clist are as follows: (a) (prect <point> <point>) changes the pattern rectangle to the one whose diagonal points are given as specified. (b) ( t r a n < r t - t r a n s f o r r a > ) determines which of the two ways to replicate a pattern picture onto a trapezoid section is preferred. If it is ( t r a n XY), zy-transformation is adopted; if it is ( t r a n PROJ), two-dimensional projective transformation is preferred.
(*pier*sum 'P_pict . . .) RETURN:
the picture that is the left-to-right sum of the pictures given as arguments.
B.3. FUNCTIONS
89
( * d e ~ * p i c t N_pname 'P_pict . . .) RETURN:
N_pname.
SIDE EFFECT:
This assigns to g_pname the picture which is the left-to-right sum of all the
pictures given as arguments. Hereafter, the sum of pictures is referred to simply as N_pname. B.3.3
Utility Functions
(*mat ' n _ e l l 'n_e12 ~n_e13 'n_e21 ~n_e22 'n_e23) RETURN:
the 2 × 3 matrix: the elements in the first row are ' n _ e l l , 'n_e12 and 'n_e13, in
order, and those in the second row are 'n_e21, 'n_e22 and 'n_e23.
(*mat*scal 'n_x 'n_y) RETURN:
the matrix for scaling by n_x along the x-axis and by n_y along the y-axis.
(*mat*scalx 'n_x) RETURN:
the matrix for scaling by n-x along the x-axis.
(*mat*scaly 'n_y) RETURN:
the matrix for scaling by n_y along the y-axis.
(*mat*rot ~n_theta) RETURN:
the matrix for rotation through n_theta about the origin.
(*mat*rot*point 'n_theta 'T_point) RETURN:
the matrix for rotation through n_theta about the point T_point.
(*mat*tran 'n_x 'n_y) RETURN:
the matrix for translation by n_x parallel to the x-axis and by n_y parallel to the
y-axis.
(*mat*tranx 'n_x) RETURN:
the matrix for translation by n_x parallel to the x-axis.
(*mat*trany 'n_y)
90
APPENDIX B. PNUCLEUS REFERENCE MANUAL
RETURN:
the matrix for translation by n_y parallel to the y-axis.
(*mat*skew 'n_x 'n_y) RETURN:
the matrix for skewing by n_x parallel to the x-axis and by n_y parallel to the y-axis.
(*mat* ske~.Tx 'n_x) RETURN:
the matrix for skewing by n_x parallel to the x-axis.
(*mat*skewy 'n_y) RETURN:
the matrix for skewing by n_y parallel to the y-axis.
(*mat*cat 'M_mat . . . ) RETURN: B.4
the left-to-right product of all the matrices given as arguments.
F o r m a l S y n t a x of the p N u c l e u s S y s t e m
We present in this section the syntactic feature of pNucleus in terms of the extended BNF [21]. Extended BNF grammars are composed of production rules, each of which has a recta-variable on its left side and alternative specifications on its right side. The two sides are separated by the metasymbol : :=, each variable is enclosed by angle brackets < and >, and if there is more than one alternative, they are separated by the metasymbol I. In addition, any sequence of symbols enclosed by square brackets indicates that it is optional, while any sequence of symbols enclosed by braces indicates that it occurs any number of times in succession. B.4.1
Basic Data T y p e s
The data type <point> is realized by a dotted pair of numbers, while <matrix> is implemented as a vector whose length is 6 and whose property is the symbol matrix. The data type < p i c t u r e name> is represented by the Lisp symbol, and is given as an integer. B.4.2
Geometries
::= < l i n e geometry> I <point geometry> I
B.4. FORMAL S Y N T A X OF THE PNUCLEUS S Y S T E M
91
::= (*line {<point>} {})
<point geometry> ::= (*point {<point>} {})
::= (*lattice <point> <point> <point> {})
::= (*area <area points>)
<area points> ::= {{<point>} close}{<point>} B.4.3
Pictures
::= I <simple picture> I I
::= (*pict*tran <matrix>
<simple picture> ::= (*pict {<area points>} {})
::= (*pict*call <matrix> {})
::= (*pict*sum {}) B.4.4
Invoking Transformations
::= (peval ')
92
APPENDIX B. PNUCLEUS REFERENCE MANUAL I (*gtran*geom '<matrix> ') t (*rtraa*geom ' < r e s t r i c t i v e
geometry> ')
I (*pict*tran '
' ')
] ( * g t r a n * p i c t '<matrix> ') I (*rtran*pict
' ')
] (*pict*sum { ' < p i c t u r e > } ) [ (*def*pict { ' < p i c t u r e > } )
::=
(attenp I (prect
<point>
I (trans
)
B.5
<paint>)
::= XY
<point>)
I PRGJ
Examples
Here we reproduce a sample interaction between you and pNncleus, which generates the picture in Figure 5.2. As you can see, backquote macros are used in the interaction: various functions provided by Franz lisp are available and will make your programming and debugging easier.
lisp Franz Lisp,
Opus 38.92
-> (load pNucleus)
t -> (*Ginit) t -> (setq Point
'((0.15
((0.25
(0.4.
. 0.25)
-> (setq LineGeom (*line
(0.15
0.5)
((*line
. 0.25)
-> (setq LinePict
. 0.25)
(0.4
(0.4 . 0.5)
(0.6.
o.s)
(0.6
(0.9
. 0.5)
(0.9 . 0.80)))
. 0.80))
,@Point)) . 0.5)
(*pict*tran
(0.6
'((prect
. 0.5)
(0.9
. 0.80))
(0 . O) (0.1
. 0.I)))
'~(*pict*call
*A
B.5. E X A M P L E S ,Unit*Matrix) (*pict*tran )(0.4
. 0.5)
LineGeom) ) ((prect (0.6
-> (peval LinePict) nil -> (*Gt erm) t
93
(0 . O) ( 0 . 1 . 0.5)
(0.9
. O. 1)) ) ( * p i c t * c a l l . 0.80) matrix[6])
*A m a t r i x [ 6 ]
(0.15
. 0.25
Appendix C Implementation Issues in pNueleus
This appendix contains a description of the sectioning algorithm and two types of transformation that map the unit square onto a quadrangular region. These are used in pNucleus for pictorialization of a line geometry. C.1
Sectioning a Line Geometry
Let us consider developing sections, whose width and height are w and h, respectively, along a line
P1P2...Pn. The procedure is as follows: 1. Determine the point sequence/1, 12, ..., Im 'on' the polyfine such that
I1 = P1, I+I~+l = w(1 < i < m - 1), I,,,_lZm O.
(a) When Si is equal to P,, ~ . e,~'2 = O. (b) When S, is equal to P,~, l~. P , ~ P , , = O. (c) When S, is equal to PS(1 < j < n), h,. P 3 ~ e j = ]~. ei_~Pi. (d) When Si lies on PjPj+I,
,',i.
=o
if S+S~ - intersects with neither
_~+Pfi nor
P~+IP~+I.
(e) Otherwise, = (s,&+,~_, + &_,&h,+,)/s,_,&+,,
where 4-1 and S~+, are the two points nearest to S~ such that S~ lies on &_rS;+, and their section height vectors can be determined by (a)-(d).
APPENDIX C. IMPLEMENTATION ISSUES IN PNUCLEUS
96
lh4 S3+h3~S4)
) P3
s, 4 qh4
1h ~ S ~ '~~3Sh-_~
P3
P1($1)
P1($1) (a)
P~ (S~) (b)
(c)
Figure C.1: Determining section height vectors The sections are then given as S+S++tS~ISI-(1 < i < n
-
-
1).
E x a m p l e C.1 Figure C.1 illustrates Step 3 in the above algorithm, that is, the determination of section height vectors. Sections are developed along P1P2P3, and section height vectors are considered at the points St, S~, $3, and $4 iu Figure CA(a). The vectors h~, h~, and h~ are calculated by the rules (a), (d), and (c) in Step 3, respectively. They are also drawn in Figure CA(a). Rule (d) cannot be applied to h~, because, if it were, S+S~ and S+S~ would cross, as in Fignre C.l(b). The vector h"3 must be calculated by rule (e), as in Figure CA(c). That is, h3 is given
Most sections are rectangles congruent to the replication rectangle, but some are mandatorily fractions of the rectangle, or even trapezoids or fractions of trapezoids, usually at the connecting point of two adjacent line segments. Other more sophisticated sectionings are also possible, which are more sensitive at the points connecting adjacent line segments.
C.2 C.2.1
T r a n s f o r m a t i o n s for m a p p i n g a r e c t a n g l e o n t o a q u a d r a n g l e xy-transformation
Consider the transformation that maps a point (z, y) in the unit square onto the point (X, Y) in the quadrangular P Q R S in the following way: (z, y) --~ (X, Y) = O~P + (1 - y)(z. P"S) + y(P~Q + ~. QfR). When the coordinates of P, Q, R, and S are given as (p~,py), (q,,,qy), (r~,ry), and (s~,sy), respectively, this transformation is represented in the following matrix form:
C.2.
TRANSFORMATIONS
/x Y \ 1
F O R MAPPr_NG A R E C T A N G L E
s~ - p~: q~ - p~ p~
3~
s~-py
py
y
1
1
%-py
0
0
+ :cy
ONTO A QUADRANGLE
97
py - q~ + ry - s~ 0
This transformation maps the entire unit square onto the entire quadrangle.
We name it an
×y-transformation, since the equation contains the second-order term xy. Obviously, this transformation has a couple of flaws when used with graphics systems. It does not always send lines into lines and it does not preserve the ratio of each pair of parallel segments. In addition, the composition of two xy-transformations cannot be a xy-transformation. Atl the same, we use a xy-transformation because, for the very points on the boundary of the quadrangle, the property of preserving the ratio of each pair holds: it enables a pattern picture to be smoothly and continuously developed from one section to another. Figures 5.2 and ?? are generated by using ×y-transformation. C.2.2
Two-Dimensional
Projective Transformation
Let us look for the transformation that maps the unit square onto the quadrangle P Q R S that is still represented by a 3 × 3 matrix.
and
Suppose this transformation maps the four corners
in the unit square (0,0), (0,1), (1,1), and (1,0) to P(p~,py), Q(q~,qy), R(r~,ry), and S(s~,s~)~ respectively. This results in eight simultaneous equations with nine unknowns (nine elements in a 3 by 3 matrix). We can solve them to obtain the following mMrix: . ( P-R × ff s ) - p. . (
× S'Q )
% . ( P~R x f f S ) - Pu " ( f f S x S~Q) P~R x l ( S -
t~S x S Q
. ( S-Q × Q'e ) -
.(
× SQ )
.(
× SQ )
r y . ( S'Q x Q~P) - py . ( t~S x S~Q) p~ . ( t ( s x S Q ) S~Q x Q f P - t~S x S~Q
t~s × s~Q
This transformation is what we call a two-dimensional projective transformation. Its advantages are that it sends lines to lines and that the composition of the two two-dimensional projective transformations is still a two-dimensional projective transformation. However, it does not preserve the ratio of each pair of parallel segments, even for the points on the boundary of the quadrangular. This leads to an unpleasant distortion of a pattern picture in the trapezoid sections. Figure C.2 shows an example of pictorialization of a line geometry by this type of transformation, which uses the same pattern picture and the same geometry as Figure 5.2.
98
APPENDIX C. IMPLEMENTATION ISSUES IN PNUCLEUS
1.0
/AJ
0.5
!
0
n
0.5
1.0
Figure C.2: Pictorialization of a line geometry by two-dimensional projective transformation
Bibliography [1] Mallgren, W.R. Formal Specification of Interactive Graphics Programming Language. The MtT Press, Cambridge, Massachusetts, 1983. [2] Onodera, T. and S. Kawai. A Formalization of the Specification and Systematic Generation of Computer Graphics Systems. Visual Computer (May 1986)~ 112-126. [3] Duce, D.A., E. V. C. Fielding, and L. S. Marshall. Formal Specification and Graphics Software. Rutherford Appleton Laboratory, RAL-84-068, August 1984. [4] Duce, D.A. and E. V. C. Fielding. Formal Specification - - A Comparison of Two Techniques. Rutherford Appleton Laboratory, RAL-85-051, July 1985. [5] Carson, G.S. An Approach to the Formal Specification of Computer Graphics Systems. Com-
puters and Graphics (January 1984), 51-57. [6] Carson, G.S. A formal Specification of the Programmer's Minimal Interface to Graphics. American National Standards Institute, X3H34 Working Document, 1982. [7] Gnatz~ R. An Algebraic Approach to the Standardization and the Certification of Graphics Software. Computer Graphics Forum (1983). [8] Status Report of the Graphics Standards Planning Committee. Computer Graphics 13(3) (August 1979). [9] Information processing systems - - Computer graphics - - Graphical Kernel System (GKS) - functional description. ISO TC97/SC21 IS 7942 (August 1985). [10] Information processing systems - - Computer graphics - - Interfacing Techniques for Dialogues with Graphical Devices - - functional specification. ISO TC97/SC21 DP 9636 (December 1986). [11] Information processing systems - - Computer graphics - - Programmer's Hierarchical Interactive Graphics System (PHIGS). ISO/IEC 9592 (April 1989). [12] Adobe Systems Incorporated. PostScript Language Reference Manual. Addison Wesley, 1986. [13] Enderle, G., A K. Kansy, and A G. Pfaff. Computer Graphics Programming. Springer-Vertag, 1984. [14] Hopgood, F.R.A. Introduction ~o The Graphical Kernel System (GKS). Academic Press, 1983. [15] Foley, J.D. and A. Van Dam. Fundamenials of Interactive Computer Graphics. Addison Wesley, 1983. [16] Newman, W.M. and R. F. Sprou]l. Principles of Interactive Computer Graphics. McGraw-Hill,
BIBLIOGRAPHY
100
[16] Newman, W.M. and R. F. Sproull. Principles of Interactive Computer Graphics. McGraw-Hill, 1973. [17] Sutherland, I.E., R.F. Sproull, and R.A. Schumacker. A Characterization of Ten Hidden Surface Algorithms. Compuling Surveys6(1) (1974), 1-55. [18] Kamada, T. and S. Kawai. An Enchaneed Treatment of Hidden Lines. ACM Transactions on Graphics 6(4) (October 1987), 308-323. [19] Cohn, P.M. Universal Algebra. D. Rewdel Publishing Company, Dordrecht, Holland, 1981, 9-11. [20] Foderaro, A.J.K., K.L. Sklower, and A.K. Layer. The FRANZ LISP Manual. The Regents of the University of California, 1983. [21] Pagan, F.G. Formal Specification of Programming Languages. Prentice-Hall, 1981. [22] Hoare, C.A.R. An Axiomatic Basis to Computer Programming. Comm. ACM 12 (October 1969), 576-580. [23] Bjorner, D. and C.B. Jones. The Vienna Development Me~hod: The Meta-Languaye. SpringerVerlag, LNCS 61, 1978. [24] Goguen, J.A. and J.J. Tardo. An Introduction to OBJ: a language for writing and testing formal algebraic program specifications. Proceedings of the Conference on Specifications of Reliable Software, IEEE Computer Society(1979), 170-189.