prlisp.mss 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
  1. @Device(lpt)
  2. @style(justification yes)
  3. @style(linewidth 80, spacing 1,indent 5)
  4. @use(Bibliography "<griss.docs>mtlisp.bib")
  5. @make(article)
  6. @modify(enumerate,numbered=<@a. @,@i. >, spread 1)
  7. @modify(appendix,numbered=<APPENDIX @A: >)
  8. @modify(itemize,spread 1)
  9. @modify(description,leftmargin +2.0 inch,indent -2.0 inch)
  10. @define(up,use text,capitalized on, break off)
  11. @define(mac,use text, underline off, break off)
  12. @define(LISPmac,use text, underline alphanumerics, break off)
  13. @pageheading(Left "Utah Symbolic Computation Group",
  14. Right "September 1981",
  15. Line "Operating Note 59"
  16. )
  17. @set(page=1)
  18. @newpage()
  19. @begin(titlepage)
  20. @begin(titlebox)
  21. @b(PictureRLISP)
  22. @center[A LISP-Based Graphics Language System
  23. with Flexible Syntax
  24. and Hierarchical Data Structure
  25. by
  26. Fuh-Meei Chen, Paul R. Stay and Martin L. Griss
  27. Computer Science Department
  28. University of Utah
  29. Salt Lake City, Utah 84112
  30. Last Revision: @value(date)]
  31. @end(titlebox)
  32. @begin(abstract)
  33. This report is a description and a users manual for PictureRLISP, a
  34. LISP based interactive graphics language. PictureRLISP has an
  35. ALGOL-like syntax, with primitives to create, manipulate and apply 3D
  36. transformations to hierachical data structures called "Models".
  37. PictureRLISP is entirely written in RLISP which is a high-level
  38. interface to Standard LISP.
  39. @end(Abstract)
  40. @begin(Researchcredit)
  41. Work supported in part by the National Science Foundation
  42. under Grant No. MCS80-07034.
  43. @end(Researchcredit)
  44. @end(titlepage)
  45. @pageheading(Left "PictureRLISP",Center "@value(date)",
  46. Right "@value(Page)"
  47. )
  48. @set(page=1)
  49. @newpage
  50. @section<Introduction>
  51. PictureRLISP is a graphic specification language in an interactive
  52. RLISP environment. PictureRLISP usage typically consists of creating,
  53. modifying, and requesting the display of graphical objects, called
  54. "Models". A model is a three dimensional representation of the
  55. spatial, topological and graphical features of an object. Models can
  56. contain any number of primitives, which can generally be in any order.
  57. The hierarchical structure and implementation of the PictureRLISP
  58. system are designed to support both the beginning and the expert user
  59. as well. The sophisticated PictureRLISP user can utilize low level
  60. primitive operations to support customized modeling, syntax or device
  61. environments; yet the beginner need not know how to use these
  62. features.
  63. PictureRLISP is a re-implementation of an earlier system,
  64. PICTUREBALM@cite[Goates80], with a number of additions. The major
  65. improvement is that the entire system is now written in RLISP, including
  66. the low-level clipping and transformation routines. RLISP is an ALGOL-like
  67. interface to LISP, found more convenient to use by many people. The
  68. extensible, table-driven RLISP parser itself is written in LISP, permitting
  69. rapid syntactice customization. The version of RLISP used for PictureRLISP
  70. is built upon PSL@cite[Griss81,Griss82b], an efficient, portable and
  71. interactive LISP system. PSL provides rich data structures, dynamic storage
  72. management, and an efficient LISP to machine code compiler@cite[Griss79b],
  73. which makes PSL-based PictureRLISP much more efficient than the previous
  74. PictureBALM system. A complete PSL currently runs on DECSystem-20,
  75. VAX-11/750 under UNIX. A preliminary PSL now runs on an Apollo DOMAIN (a
  76. Motorola MC68000-based personal machine with high-resolution graphics).
  77. PictureRLISP is capable of driving a number of different graphic output
  78. devices, and is fairly easy to extend to others. The current devices that
  79. built-in PictureRLISP drivers support include: Tektronix 4010 (and 'clones,
  80. such as ADM3a with retrographics board, Apollo Tektronix emulator,etc.);
  81. Hewlett-Packard HP2648a; Evans and Sutherland MPS-1; AED-512 color
  82. terminal; and "checkout" graphics on low-resolution devices such as 60 x 80
  83. Ann-Arbor Ambassador, or 24 x 80 Teleray-1061 or VT100.
  84. PictureRLISP has also been extended to run under EMODE@cite[Galway82], an
  85. interactive LISP-based, full-screen editor which is similar to EMACS. EMODE
  86. runs within the PSL environment, and permits the editing of PictureRLISP
  87. commands and procedures, and then immediate execution from within the
  88. editing window. One can also define graphics windows to display the models
  89. presented.
  90. @section(Basic concepts)
  91. @subsection(Models)
  92. PictureRLISP usage typically consists of creating, modifying, and
  93. requesting the display of graphical objects, called "Models". A Model
  94. is a three dimensional representation of the spatial, topological and
  95. graphical features of an object. Models can contain any number of
  96. primitives, which can generally be in any order. PictureRLISP Model
  97. primitives include: Point Sets, which might be interpreted as
  98. polygons, connected line segments, curve control points, etc.;
  99. transformations of objects or coordinate systems in three dimensional
  100. space; color or appearance attributes; Repeat Specifications, which
  101. cause sub-sections of the Model to be replicated; named references to
  102. other Models to be displayed as if they were part of the current
  103. Model; and procedure calls.
  104. Allowing Models to contain references to other Models
  105. facilitates dynamic displays and allows the user to structure his data
  106. in Clusters in a meaningful manner. Sub-Models may be shared among a
  107. number of Models. Allowing procedure calls to be imbedded within
  108. Models provides the user with a mechanism which can easily effect
  109. arbitrary displays, transformations, parameterized models or other
  110. functions that may be required by a specific application; in some
  111. cases, it is essential to represent objects by algorithms or
  112. procedural models.
  113. @subsection<Coordinate systems, Viewport>
  114. [ *** This section needs more work ****]
  115. Currently, each device supported by has its own "screen" coordinates,
  116. and the user has to think of his model sizes in a device specific
  117. fashion. This is a defect, and we are planning to change the basic system
  118. so that each device driver will normalize coordiates so that a square
  119. of side N world-coordinates (or M inches?) will map onto the physical
  120. screen, with a square aspect ratio. Clipping of objects outside this square
  121. (cube) and exact placement of the square will be controlled by default
  122. settings of the View Port and a Global transformation matrix.
  123. Since both view port and global transformation (for perspective and scaling)
  124. are adjustable, the idea will be to provide a more natural default.
  125. Perhaps two or three sets of defualts are desirable, selectable by the user:
  126. A device independant WORLD view, a semi-device independant PHYSICAL size
  127. and a very device specific SCREEN view.
  128. @subsection<Example of PictureRLISP>
  129. As a small example of the flavor of PictureRLISP, the following
  130. commands will display a set of BOX's of different sizes, after suitable
  131. device initialization:
  132. @begin(verbatim)
  133. BOX := {0,0}_{0,10}_{10,10}_{10,0}_{0,0};
  134. % Assigns to BOX a set of connected points for 10*10 box
  135. SHOW BOX & BOX | ZROT(45) & BOX | SCALE(2);
  136. % Display 3 boxes, the original, a rotated box, and
  137. % a 20 * 20 box. The & collects a set of unconnected models
  138. % and | attaches a transformation (matrix)
  139. @end(verbatim)
  140. @section(Specification of the PictureRLISP Language)
  141. PictureRLISP supports the creation and manipulation of Models both by
  142. means of built-in procedures for the various primitives (points,
  143. pointsets, and groups) and by means of syntactic extensions, i.e.
  144. operators which construct Models out of primitives. PictureRLISP
  145. contains five operators designed to make graphics programs easy to
  146. read and write. They are denoted by the following special characters:
  147. {, }, _, & and |, and map to an appropriate set of Lisp procedures.
  148. The following is the set of legal Model primitives:
  149. @begin(enumerate)
  150. @u(Point.) Points are constructed by using curly brackets, or by the
  151. function POINT(x,y,z,w), e.g. {x,y} [denotes the point (x, y, 0) in three
  152. dimensional space]. Points can be described by any one of four ways. A
  153. single value on the x axis, a two dimensional point, a three
  154. dimensional point or in homogeneous coordinate space.
  155. @u(Pointset.) The function POINTSET(p,q,..s) or the infix "_" operator is
  156. used to make Point Sets; e.g. it can be used to make polygons out of
  157. Points. For example, the usual graphical interpretation of the
  158. sequence A@ _@ B@ _@ C, where A, B, and C are Points, moves the
  159. display beam to the point represented by A, draws to B, and then draws
  160. to C.
  161. @u(Group) A Group is a set of Point Sets or Points and is formed by
  162. the infix operator & or the function GROUP(ps1,ps2,...psN). Thus models may be
  163. grouped together and formed into larger models for reference.
  164. @u(Point Set Modifiers.) Point Set Modifiers alter the interpretation
  165. of any Point Sets within their scope. The curved Point Set Modifier
  166. BEZIER() causes the points to be interpreted as the specification
  167. points for a BEZIER curve. The BEZIER curve has as its end points the
  168. endpoints of the control polygon. BSPLINE() does the same for a closed
  169. Bspline curve. If a control polygon is not closed then then algorithm
  170. will create a closed polygon by assuming there is a line segment
  171. between the endpoints. In order to get these curves a pointset acting
  172. as control points need to be given. Even though the control points may
  173. not be closed for a BSPLINE curve the system will close the polygon to
  174. form a closed BSPLINE curve. Another modifier is that of COLOR() where
  175. on color drawing systems different color values can be given to the
  176. model.
  177. @u(Transforms.)
  178. Transforms are the Model primitives which correspond to
  179. transformations of objects or coordinate systems in three dimensional
  180. space. PictureRLISP supports rotation, translation, scaling, perspective
  181. transformation and clipping. The Transform primitives are:
  182. @begin<enumerate>
  183. Translation: Move the specified amount along the
  184. specified axis.
  185. @*XMOVE (deltaX) ; YMOVE (deltaY) ; ZMOVE (deltaZ)
  186. @*MOVE (deltaX, deltaY, deltaZ)
  187. @blankspace(1 line)
  188. These Transforms are implemented as procedures which return a transformation
  189. matrix as their value.
  190. Scale : Scale the Model SCALE (factor)
  191. @*XSCALE (factor) ; YSCALE (factor) ; ZSCALE (factor)
  192. @*SCALE1 (x.scale.factor, y.scale.factor, z.scale.factor)
  193. @*SCALE <Scale factor>. Scale along all axes.
  194. @blankspace(1 line)
  195. These Transforms are implemented as a transformation matrix which will scale
  196. Models by the specified factors, either uniformly or along only one dimension.
  197. Rotation: Rotate the Model
  198. @*ROT (degrees) ; ROT (degrees, point.specifying.axis)
  199. @*XROT (degrees) ; YROT (degrees) ; ZROT (degrees)
  200. @blankspace(1 line)
  201. These procedures return a matrix which will rotate Models about the axis
  202. specified. Currently rotation are limited to being about the three
  203. coordinate axes, though one would like to be able to specify an arbitrary
  204. rotation axis.
  205. WINDOW (z.eye,z.screen): The WINDOW primitive assumes that the viewer
  206. is located along the z axis looking in the positive z direction, and
  207. that the viewing window is to be centered on both the x and y axis.
  208. The window function is used to show perspective for models and the
  209. default window at initialization of the device is set with the eye at
  210. -300 and with the screen at 60. If one wish to use a right handed
  211. coordinate system then the eye is in the positive direction.
  212. VWPORT(leftclip,rightclip,topclip,bottomclip): The VWPORT, which specifies
  213. the region of the screen which is used for display. This is set to a
  214. convenient default at the time a device is initialized by the device
  215. drivers.
  216. @end<enumerate>
  217. @u(Repeat Specifications.)
  218. This primitive provides the user with a means of replicating a
  219. section of a Model any number of times as modified by an arbitrary
  220. Transform, e.g. in different positions.
  221. The primitive is called REPEATED (number.of.times, my.transform),
  222. where number.of.times is an integer.
  223. The section of the Model which is contained within the scope of the Repeat
  224. Specification is replicated.
  225. Note that REPEATED is intended to duplicate a sub-image in several different
  226. places on the screen; it was not designed for animation.
  227. @u(Identifiers of other Models.)
  228. When an identifier is encountered, the Model referenced is displayed
  229. as if it were part of the current Model. Allowing Models to contain
  230. identifiers of other Models greatly facilitates dynamic displays.
  231. @u(Calls to PictureRLISP Procedures.)
  232. This Model primitive allows procedure calls to be imbedded within
  233. Models. When the Model interpreter reaches the procedure identifier
  234. it calls it, passing it the portion of the Model below the procedure
  235. as an argument. The current transformation matrix and the current pen
  236. position are available to such procedures as the values of the global
  237. identifiers GLOBAL!.TRANSFORM and HEREPOINT. This primitive provides
  238. the user with a mechanism which can be used to easily effect arbitrary
  239. displays, transformations, functions or models required by a specific
  240. application. The value of the procedure upon its return is assumed to
  241. be a legal Model and is SHOW'n; PictureRLISP uses syntax to
  242. distinguish between calling a procedure at Model-building time and
  243. imbedding the procedure in the Model to be called at SHOW time; if
  244. normal procedure call syntax, i.e. proc.name@ (parameters), is used
  245. then the procedure is called at Model-building time, but if only the
  246. procedure's identifier is used then the procedure is imbedded in the
  247. Model.
  248. @u(Global Variables) There are a number of important global variables
  249. in PictureRLISP whose meaning should be aware of, and which should be
  250. avoided by the user, unless understood:
  251. @begin<description>
  252. @u<Globals>@\@u<Meaning>
  253. HEREPOINT@\Current cursor position as a 4-vector.
  254. HERE@\Current cursor position as a '(POINT x y z)
  255. ORIGIN@\The vector [0,0,0,1].
  256. GLOBAL!.TRANSFORM@\A global transform specified by the user,
  257. which is applied to everything as the "last" transformation.
  258. A default is set in the Device initializtion, but can be changed by
  259. user as convenient.
  260. MAT!*1@\Unit 4 x 4 transformation matrix.
  261. MAT!*0@\Zero 4 x 4 transformation matrix.
  262. DEV!.@\Name of the current device, for device dependent code.
  263. CURRENT!.TRANSFORM@\The current (cumulative) transformation matrix.
  264. All points are transformed by this before a move
  265. or draw. Initialized to GLOBAL!.TRANSFORM before each Display.
  266. CURRENT!.LINE@\The current Pointset modifier, can be 'BEZIER,
  267. 'BSPLINE or the default straight line modifier 'LINE.
  268. !*EMODE@\Tells the system and or user if PictureRlisp is
  269. in EMODE status.
  270. @end(description)
  271. @end(enumerate)
  272. @newpage
  273. The following is a BNF-like description of the set of legal Models.
  274. The meta-symbols used are ::= for "is a" and | for "or".
  275. Capitalized tokens are non-terminal symbols of the grammar of Models,
  276. a usage that is adhered to in the text of this report.
  277. Upper case tokens are PictureRLISP reserved words, which have been defined
  278. as RLISP procedures, operators and/or macros.
  279. Lower case tokens can be either numbers or identifiers, but not
  280. quoted number identifiers,
  281. except for "string" which denotes either a RLISP item of type string
  282. or a string identifier.
  283. @begin(verbatim)
  284. <Model> ::= NIL
  285. | <Simple Model>
  286. | <Model> & <Model>
  287. <Simple Model> | <Model Object>
  288. | ( <Model> )
  289. | <Model> | <Model Modifier>
  290. | <Model Identifier>
  291. | '<Model Identifier>
  292. <Model Object> ::= NIL
  293. | <Point Set>
  294. | <Model Object Identifier>
  295. | '<Model Object Identifier>
  296. <Model Modifier> ::= NIL
  297. | <Transform>
  298. | <Point Set Modifier>
  299. <Transform> ::= XROT (degrees)
  300. | YROT (degrees) | ZROT (degrees)
  301. | XMOVE (deltaX) | YMOVE (deltaY)
  302. | ZMOVE (deltaZ)
  303. | MOVE (xdelta, ydelta, zdelta)
  304. | SCALE (factor) | XSCALE (factor)
  305. | YSCALE (factor)| ZSCALE(factor)
  306. | SCALE (x.factor, y.factor, z.factor)
  307. | WINDOW (z.eye,z.screen)
  308. | <Transform Identifier>
  309. | ' <Transform Identifier>
  310. Repeat Specification ::= REPEATED (number!.of!.times, Transform)
  311. <Point Set Modifier> ::= | BEZIER()
  312. | BSPLINE()
  313. | CIRCLE(r)
  314. | COLOR(value)
  315. <Point Set> ::= <Point>
  316. | <Point> _ <Point Set>
  317. | <Point Set Identifier>
  318. | '<Point Set Identifier>
  319. <Point> ::= {x} | {x, y} | {x, y, z}
  320. | {x,y,z,w}
  321. | Point Identifier
  322. | ' Point Identifier
  323. @end(verbatim)
  324. @section<Basic PictureRLISP Procedures>
  325. It should be emphasized that the typical user of the PictureRLISP
  326. language need never use some of these primitives directly, nor need he
  327. even know of their existence. They are called by the procedures which
  328. are written in RLISP which implement the standard PictureRLISP user
  329. functions. Nevertheless, they are available for the sophisticated
  330. user who can utilize them to implement a customized language
  331. environment. Also, they might serve as an example of the primitives
  332. that a PictureRLISP implementor would want to add to support other
  333. devices.
  334. @subsection(Common Functions)
  335. @begin<description>
  336. @b<ERASE()>@\Clears the screen and leaves the
  337. cursor at the origin.
  338. @b<SHOW (pict)>@\Takes a picture and display it on the screen
  339. @b<ESHOW (pict)>@\Erases the whole screen and display "pict"
  340. @b<HP!.INIT()>@\Initializes the operating system's (TOPS-20) view
  341. of the characteristics of HP2648A terminal.
  342. @b<TEK!.INIT()>@\Initializes the operating system's (TOPS-20) view
  343. of the characteristics of TEKTRONIX 4006-1 terminal and
  344. also ADM-3A with Retrographics board.
  345. @b<TEL!.INIT()>@\Initializes the operating system's (TOPS-20) view
  346. of the graphics characteristics of the Teleray 1061 terminal.
  347. This is rather crude graphics, on a 24*80 grid, using the character X.
  348. Nevertheless, it provides a reasonable preview.
  349. @b<MPS!.INIT()>@\Initializes the operating system's (UNIX) on the vax
  350. to handle the MPS commands. (currently on the VAX).
  351. @b<ST!.INIT()>@\Initializes the operating system's view of the
  352. characteristics of the Apollo workstation (a 68000 based system hooked
  353. up to the DEC 20 or Vax), emulating a TekTronix 4006 and VT-52
  354. simultaneously in multiple windows.
  355. @b<AED!.INIT()>@\Initializes the operating system's view of the
  356. graphics color device AED-512 a 4006 tektronix color system.
  357. @end(Description)
  358. @subsection(Low Level Driver Functions)
  359. Most of these are "generic" names for the device specific procedures
  360. to do basic drawing, moving, erasing etc. The initialization routine for device XX,
  361. called XX!.INIT() above, copies the routines, usually called XX!.YYYY into
  362. the generic names YYYYY.
  363. @begin(description)
  364. @b<ERASES()>@\Erase the Graphics Screen
  365. @B<GRAPHON()>@\Called by SHOW, ESHOW and ERASE() to put the device into
  366. graphics mode. May have to turn off normal terminal ECHO, using ECHOOFF(),
  367. unless running under EMODE.
  368. @b<GRAPHOFF()>@\Called by SHOW, ESHOW and ERASE() to put the device back
  369. into text mode. May have to turn normal terminal ECHO back on, using ECHOON(),
  370. unless running under EMODE.
  371. @b<MOVES (x, y)>@\Moves the graphics cursor to the point (x, y) where
  372. x and y are specified in coordinates. These coordinates will be
  373. converted to absolute location on the screen allowing different
  374. devices to display the same models whether they have the same
  375. coordinate systems internaly or not.
  376. @b<DRAWS (x, y)>@\Draws a line from the current cursor position to the
  377. point specified in screen space.
  378. @end(description)
  379. @subsection(Low Level Matrix Operations)
  380. @begin(description)
  381. @b<MAT!*MAT (new!.transform, current!.transform)>@\This procedure is passed
  382. two transformation matrices. Each matrix is represented by a 16 element
  383. vector of floating point or interger numbers. They are concatenated via
  384. matrix multiplication and returned as the new value of current transform.
  385. @b<PNT!*PNT(point!.1,point!.2)>@\This procedure is passed two 4-vector
  386. matrices, a value is returned.
  387. @b<PNT!*MAT(point,transformation)>@\This is passed 4-vector and a 4 by
  388. 4 matrix, and returns a new (transformed) point.
  389. @end<description>
  390. @section<Internal Representations of PictureRLISP Graphical Objects>
  391. In the LISP-like internal form, Points and Transforms are
  392. represented by 4 vectors (homogeneous coordinates, also assuming the model
  393. has been placed on w=1.0 plane) and 16 element vectors respectively.
  394. Other Model primitives are represented as operators in LISP S-expressions
  395. of the form "(operator arg1 arg2... argN)".
  396. Points and matrices can also be represented as S-expression operators, if
  397. this is desirable for increased flexibility.
  398. It will be helpful for the PictureRLISP user to know what the
  399. meaning of the interpreted form is in terms of the PictureRLISP
  400. parsed form. The operator is some meaningful token, such as POINT,
  401. TRANSFORM, POINTSET or GROUP; e.g. GROUP is the representation of the user
  402. level operator "&". The operator is used as a software interpreter
  403. label, which makes this implementation of a PictureRLISP interpreter
  404. easy to extend. Here is the table to show the external and corresponding
  405. internal forms for some basic PictureRLISP operators.
  406. @begin <verbatim>
  407. @u[Internal Form] @u[External Form] @u[Result on Draw]
  408. (POINT x y z ) {x,y,z} [x,y,z,w]
  409. (POINTSET a b c d) a_b_c_d move to a, then
  410. connect b, c, and d.
  411. (GROUP (pointset a b a_b_c_d & e do each pointset in
  412. c d) e) turn.
  413. (TRANSFORM f g) f | g apply the transform
  414. g to the picture f.
  415. (TRANSFORM point point | draws a circle with
  416. (CIRCLE radius)) CIRCLE(radius) radius specified about
  417. the center "point".
  418. (TRANSFORM pict pict | draws Bezier curve for
  419. (BEZIER) BEZIER() "pict".
  420. (TRANSFORM pict pict | same as (pict |BEZIER())
  421. (BSPLINE) BSPLINE() but drawing Bspline curve.
  422. (TRANSFORM pict pict | REPEATED the "pict" is replicated
  423. (REPEATED (count,trans) "count" times as modified
  424. count trans )) by the specified transform
  425. "trans".
  426. For example, the Model
  427. @end<verbatim>
  428. @begin(display)
  429. (A _ B _ C & {1,2} _ B) | XROT (30) | 'TRAN ;
  430. maps to the LISP form:
  431. (TRANSFORM
  432. (TRANSFORM
  433. (GROUP (POINTSET A B C) (POINTSET (POINT 1 2) B))
  434. (XROT 30))
  435. (QUOTE TRAN))
  436. @end(display)
  437. These structures give a natural hierachical structure as well as
  438. scope rules to PictureRLISP.
  439. @section<How to run PictureRLISP>
  440. Models can be built using any number of primitives and transformations
  441. and assigned to model ID's. Once a model is defined and the device
  442. has been choosen then the object can be drawn on the graphics device
  443. by using the commands Show and Eshow, both of which will display the
  444. model or object on the graphics device and the difference being that
  445. Eshow will first erase the screen. To erase the screen one can issue
  446. the command Erase() and all models and object will be erased from the
  447. screen. Unfortunately one cannot erase individual objects from the
  448. display device. The following section will give an idea on other
  449. aspects of running PictureRLISP by example.
  450. @section<Examples of PictureRLISP Commands>
  451. In the following examples, anything following a % on the same line is
  452. a comment. Rlisp expressions (or commands) are terminated with a
  453. semicolon. It is suggested that you execute these examples while
  454. executing PictureRLISP at one of the terminals to see the correct
  455. response one would get. Most of these are located in the file
  456. <stay.pict>exp.red on the DecSystem 20 at Utah and is supplied with the
  457. release of PictureRLISP.
  458. @begin(verbatim)
  459. %
  460. % PictureRLISP Commands to SHOW lots of Cubes
  461. %
  462. % Outline is a Point Set defining the 20 by 20
  463. % square which will be part of the Cubeface
  464. %
  465. Outline := { 10, 10} _ {-10, 10} _
  466. {-10,-10} _ { 10,-10} _ {10, 10};
  467. % Cubeface will also have an Arrow on it
  468. %
  469. Arrow := {0,-1} _ {0,2} & {-1,1} _ {0,2} _ {1,1};
  470. % We are ready for the Cubeface
  471. Cubeface := (Outline & Arrow) | 'Tranz;
  472. % Note the use of static clustering to keep objects
  473. % meaningful as well as the quoted Cluster
  474. % to the as yet undefined transformation Tranz,
  475. % which will result in its evaluation being
  476. % deferred until SHOW time
  477. % and now define the Cube
  478. Cube := Cubeface
  479. & Cubeface | XROT (180) % 180 degrees
  480. & Cubeface | YROT ( 90)
  481. & Cubeface | YROT (-90)
  482. & Cubeface | XROT ( 90)
  483. & Cubeface | XROT (-90);
  484. % In order to have a more pleasant look at
  485. % the picture shown on the screen we magnify
  486. % cube by 5 times.
  487. BigCube := Cube | SCALE 5;
  488. % Set up initial Z Transform for each cube face
  489. %
  490. Tranz := ZMOVE (10); % 10 units out
  491. % Now draw cube
  492. %
  493. SHOW BigCube;
  494. @blankspace(4 inches)
  495. % Draw it again rotated and moved left
  496. %
  497. SHOW (BigCube | XROT 20 | YROT 30 | ZROT 10);
  498. @blankspace(4 inches)
  499. % Dynamically expand the faces out
  500. %
  501. Tranz := ZMOVE 12;
  502. %
  503. SHOW (BigCube | YROT 30 | ZROT 10);
  504. @blankspace(4inches)
  505. % Now show 5 cubes, each moved further right by 80
  506. %
  507. Tranz := ZMOVE 10;
  508. %
  509. SHOW (Cube | SCALE 2.5 | XMOVE (-240) | REPEATED(5, XMOVE 80));
  510. @blankspace(4 inches)
  511. %
  512. % Now try pointset modifier.
  513. % Given a pointset (polygon) as control points either a BEZIER or a
  514. % BSPLINE curve can be drawn.
  515. %
  516. Cpts := {0,0} _ {70,-60} _ {189,-69} _ {206,33} _ {145,130} _ {48,130}
  517. _ {0,84} $
  518. %
  519. % Now draw Bezier curve
  520. % Show the polygon and the Bezier curve
  521. %
  522. SHOW (Cpts & Cpts | BEZIER());
  523. @blankspace(4 inches)
  524. % Now draw Bspline curve
  525. % Show the polygon and the Bspline curve
  526. %
  527. SHOW (Cpts & Cpts | BSPLINE());
  528. @blankspace(4inches)
  529. % Now work on the Circle
  530. % Given a center position and a radius a circle will be drawn
  531. %
  532. SHOW ( {10,10} | CIRCLE(50));
  533. @blankspace(3inches)
  534. % Define a procedure which returns a model of
  535. % a Cube when passed the face to be used
  536. %
  537. Symbolic Procedure Buildcube;
  538. List 'Buildcube;
  539. % put the name onto the property list
  540. Put('buildcube, 'pbintrp, 'Dobuildcube);
  541. Symbolic Procedure Dobuildcube Face$
  542. Face & Face | XROT(180)
  543. & Face | YROT(90)
  544. & Face | YROT(-90)
  545. & Face | XROT(90)
  546. & Face | XROT(-90) ;
  547. % just return the value of the one statement
  548. % Use this procedure to display 2 cubes, with and
  549. % without the Arrow - first do it by calling
  550. % Buildcube at time the Model is built
  551. %
  552. P := Cubeface | Buildcube() | XMOVE(-15) &
  553. (Outline | 'Tranz) | Buildcube() | XMOVE 15;
  554. %
  555. SHOW (P | SCALE 5);
  556. @blankspace(4inches)
  557. % Now define a procedure which returns a Model of
  558. % a cube when passed the half size parameter
  559. Symbolic Procedure CubeModel;
  560. List 'CubeModel;
  561. %put the name onto the property list
  562. Put('CubeModel,'Pbintrp, 'DoCubeModel);
  563. Symbolic Procedure DoCubeModel HSize;
  564. << if idp HSize then HSize := eval HSize$
  565. { HSize, HSize, HSize} _
  566. {-HSize, HSize, HSize} _
  567. {-HSize, -HSize, HSize} _
  568. { HSize, -HSize, HSize} _
  569. { HSize, HSize, HSize} _
  570. { HSize, HSize, -HSize} _
  571. {-HSize, HSize, -HSize} _
  572. {-HSize, -HSize, -HSize} _
  573. { HSize, -HSize, -HSize} _
  574. { HSize, HSize, -HSize} &
  575. {-HSize, HSize, -HSize} _
  576. {-HSize, HSize, HSize} &
  577. {-HSize, -HSize, -HSize} _
  578. {-HSize, -HSize, HSize} &
  579. { HSize, -HSize, -HSize} _
  580. { HSize, -HSize, HSize} >>;
  581. % Imbed the parameterized cube in some Models
  582. %
  583. His!.cube := 'His!.size | CubeModel();
  584. Her!.cube := 'Her!.size | CubeModel();
  585. R := His!.cube | XMOVE (60) &
  586. Her!.cube | XMOVE (-60) ;
  587. % Set up some sizes and SHOW them
  588. His!.size := 50;
  589. Her!.size := 30;
  590. %
  591. SHOW R ;
  592. @blankspace(4inches)
  593. %
  594. % Set up some different sizes and SHOW them again
  595. %
  596. His!.size := 35;
  597. Her!.size := 60;
  598. %
  599. SHOW R;
  600. @blankspace(4inches)
  601. @end<verbatim>
  602. @section<How to run PictureRLISP on the various devices>
  603. The current version of PictureRLISP runs on a number of devices at the
  604. University of Utah. PictureRLISP source is in PU:PRLISP.RED,
  605. and the device driver library is in the file
  606. PU:PRLISP-DRIVERS.RED. These files, compiled into the binary LOAD form
  607. are PRLISP-1.B and PRLISP-2.B. Both are automatically loaded if
  608. the user invokes LOAD PRLISP; from PSL:RLISP
  609. (see PSL documentation for implementation and usage of the loader). The
  610. following contains information concerning the generic form of a device
  611. driver, and the execution of PictureRLISP under PSL. PictureRLISP is such
  612. that device drivers can be written for what ever device you are using for a
  613. graphics display device.
  614. @subsection<Generic Device Driver>
  615. The following is an example of an xxx device driver and its associated
  616. routines. The main routines of the driver may be divided into three
  617. areas: low level I/O, basic graphics primitives (eg. move, draw,
  618. viewport etc.), and the setup routine.
  619. @begin(verbatim)
  620. %***************************
  621. % setup functions for *
  622. % terminal devices *
  623. %***************************
  624. % FNCOPY(NewName,OldName) is used to copy equivalent a
  625. % device specific function (e.g. xxx-Draws) into the generic
  626. % procedure name
  627. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  628. % xxx specific Procedures %
  629. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  630. % device low level routines to drive the escape sequences for
  631. % a graphics device. These output procedures will send the various
  632. % codes to the device to perform the desired generic function
  633. Procedure xxx!.OutChar x; %. RawTerminal I/o
  634. Pbout x;
  635. Procedure xxx!.EraseS(); %. EraseS screen, Returns terminal
  636. <<xxx!.OutChar Char ESC; %. to Alpha mode and places cursor.
  637. xxx!.OutChar Char FF>>;
  638. % The following procedures are used to simulate the tektronix
  639. % interface for picturerlisp and are considered the graphics
  640. % primitives to emulate the system.
  641. Procedure xxx!.4BYTES (XDEST, YDEST)$ %. Convert graphic plot
  642. << xxx!.OutChar HIGHERY NormY YDEST$ %. information to the
  643. xxx!.OutChar LOWERY NormY YDEST$ %. terminal in a 4 byte
  644. xxx!.OutChar HIGHERX NormX XDEST$ %. sequences containing the
  645. xxx!.OutChar LOWERX NormX XDEST >>$ %. High and Low order Y
  646. %. informationand High and
  647. %. Low order X information.
  648. Procedure HIGHERY YDEST$ %. convert Y to higher order Y.
  649. FIX(YDEST) / 32 + 32$
  650. Procedure LOWERY YDEST$ %. convert Y to lower order Y.
  651. REMAINDER (FIX YDEST,32) + 96$
  652. Procedure HIGHERX XDEST$ %. convert X to higher order X.
  653. FIX(XDEST) / 32 + 32$
  654. Procedure LOWERX XDEST$ %. convert X to lower order X.
  655. REMAINDER (FIX XDEST,32) + 64$
  656. Procedure xxx!.MoveS(XDEST,YDEST)$
  657. <<xxx!.OutChar 29 $ %. GS: sets terminal to Graphic mode.
  658. xxx!.4BYTES (XDEST,YDEST)$
  659. xxx!.OutChar 31>> $ %. US: sets terminal to Alpha mode.
  660. Procedure xxx!.DrawS (XDEST,YDEST)$ %. Same as xxx!.MoveS but
  661. << xxx!.OutChar 29$ %. draw the line.
  662. xxx!.4BYTES (CAR2 HERE, CAR3 HERE)$
  663. xxx!.4BYTES (XDEST, YDEST)$
  664. xxx!.OutChar 31>> $
  665. Procedure xxx!.NormX DESTX$ %. absolute location along
  666. DESTX + 512$ %. X axis.
  667. Procedure xxx!.NormY DESTY$ %. absolute location along
  668. DESTY + 390$ %. Y axis.
  669. Procedure xxx!.VWPORT(X1,X2,Y1,Y2)$ %. set the viewport for
  670. << X1CLIP := MAX2 (-512,X1)$ %. the display device
  671. X2CLIP := MIN2 (512,X2)$
  672. Y1CLIP := MAX2 (-390,Y1)$
  673. Y2CLIP := MIN2 (390,Y2) >>$
  674. Procedure xxx!.Delay(); %. some devices may need a
  675. NIL; %. delay to flush the buffer output
  676. Procedure xxx!.GRAPHON(); %. set the device in graph mode
  677. If not !*emode then echooff();
  678. Procedure xxx!.GRAPHOFF(); %. Take the device out of graphics mode
  679. If not !*emode then echoon();
  680. Procedure xxx!.INIT$ %. Initialization of device specIfic
  681. Begin %. Procedures equivalent.
  682. PRINT "XXX IS DEVICE"$
  683. DEV!. := ' XXX;
  684. FNCOPY( 'EraseS, 'xxx!.EraseS)$ % should be called as for
  685. FNCOPY( 'NormX, 'xxx!.NormX)$ % initialization when using
  686. FNCOPY( 'NormY, 'xxx!.NormY)$ % xxx as the device
  687. FNCOPY( 'MoveS, 'xxx!.MoveS)$
  688. FNCOPY( 'DrawS, 'xxx!.DrawS)$
  689. FNCOPY( 'VWPORT, 'xxx!.VWPORT)$
  690. FNCOPY( 'Delay, 'xxx!.Delay)$
  691. FNCOPY( 'GraphOn, 'xxx!.GraphOn)$
  692. FNCOPY( 'GraphOff, 'xxx!.GraphOff)$
  693. Erase()$
  694. VWPORT(-800,800,-800,800)$
  695. GLOBAL!.TRANSFORM := WINdoW(-300,60)
  696. end$
  697. @end(verbatim)
  698. The following is a sample session of PSL:Rlisp initializing the device xxx.
  699. @begin(verbatim)
  700. @@psl:rlisp
  701. *PSL 3.0 Rlisp, 9-May-1982
  702. *[1] load prlisp; % The system types the [1] prompt
  703. *[2] xxx.init();
  704. @end(verbatim)
  705. The system is now ready for pictureRlisp use, and one could then load
  706. in any other routines for their application.
  707. It should be noted that a number of devices can be loaded into the
  708. system but presently only one is the current display device at any
  709. given time.
  710. The following are specifics on each of the devices currently being
  711. used in PictureRlisp. The coordinate systems mentioned are device
  712. coordianates and should be transparent to the user.
  713. @subsection<Hp terminal 2648A>
  714. The screen of the HP terminal is 720 units long in the X direction,
  715. and 360 units high in the Y direction. The coordinate system used in
  716. HP terminal places the origin in approximately the center of the
  717. screen, and uses a domain of -360 to 360 and a range of -180 to 180.
  718. The procedure HP!.INIT() will load in the functions used for the HP
  719. terminal.
  720. @subsection<Tektronix terminal>
  721. Similarly, the screen of the TEKTRONIX 4006 and 4010 terminala are 1024
  722. units long in the X direction, and 780 units high in the Y direction.
  723. The same origin is used but the domain is -512 to 512 in the X
  724. direction and the range is -390 to 390 in the Y direction. TEK!.INIT()
  725. will initialize the tektronix device for displayable graphics.
  726. @subsection<Apollo work station>
  727. Currently the APOLLO DOMAIN can work station is being used as a terminal to
  728. the Decsystem 20, using the ST program on the Apollo. The screen is
  729. split into 2 windows, on of 24*80 lines, emulating a Teleray 1061,
  730. and the other a 400 * 700 tektronix likes graphics terminal.
  731. ST!.INIT() is used for initializing the commands for the apollo.
  732. @subsection<Teleray Terminal>
  733. The teleray terminal can only display characters on the screen. It
  734. can be used as a "rapid-checkout" device, by
  735. drawing all lines as a
  736. sequence of x's. To initialize the teleray the command TEL!.INIT()
  737. will setup the graphics device to be the teleray terminal.
  738. This gives a 24 * 80 resolution.
  739. @subsection<Ann Arbaor Ambassador Terminal>
  740. The teleray terminal can only display characters on the screen. It
  741. can be used as a "rapid-checkout" device, by
  742. drawing all lines as a
  743. sequence of x's. To initialize the teleray the command TEL!.INIT()
  744. will setup the graphics device to be the teleray terminal.
  745. This gives a 60 * 80 resolution.
  746. @subsection<Evans and Sutherland Multi Picture System>
  747. Currently, the MPS can be driven on the gr-vax at the University of
  748. Utah and is an example of a high level graphics device being driven by
  749. PictureRLISP. Thus it may be interesting to look at the device driver
  750. for the mps to get the feel for how PictureRLISP drives high level
  751. graphics devices. The initialization is done by calling the procedure
  752. MPS!.INIT().
  753. [???? add the other devices such as the AED, ADM3a+Retro ???]
  754. @section<Future Work>
  755. PictureRLISP currently uses a large number of vectors, regenerating points
  756. at the very lowest level. Since all Clipping and transformation is
  757. done in LISP, using vectors. This results in very frequent garbage collection,
  758. a time-consuming and expensive process. On the DEC-20, a grabage takes about 2.5 secs. On the VAX, GC is only 1 second, and happens much less frequently.
  759. It is planned to optimize this lower level.
  760. Perhaps this could be fixed by using a number of fluid point vectors
  761. as the only points which exist as vectors.
  762. Since all devices currently defined in PRLISP-DRIVERS.RED use a standard
  763. tektronix interface it becomes impossible under the current version to use
  764. some features that the devices have defined in hardware. For instance the
  765. MPS system has bult in clipping, viewport and windowing functions all
  766. defined in hardeware as well as 3-d display. At this point it is impossible
  767. for one to use the full features offered by the mps and it seems that it
  768. would be nice if one could use some of these features.
  769. @section(References)
  770. @bibliography()