home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / tutorials / geometer / geom.doc < prev    next >
Encoding:
Text File  |  1994-08-02  |  20.3 KB  |  580 lines

  1. Geometer illustrates geometric theorems and proofs.  It also contains code
  2. that solves 2-D constraint problems, and illustrates an interesting
  3. form of user interface that allows both a graphical and a textual
  4. interaction.  This version will work with a standard system 5.2
  5. installation.  Geometer uses the program "jot" to do its text
  6. manipulation, and uses jot's file browser (/usr/lib/jot/browsegizmo) for
  7. its file browser.
  8.  
  9. As an example, try running geom on the theorem "Medians.T" by typing:
  10.  
  11. geometer Theorems/proofs/Medians.T
  12.  
  13. As the text at the bottom of the window explains, this example
  14. illustrates the fact that the three medians of a triangle always meet
  15. at a point.  Try mousing down on one of the vertices labelled A, B, or
  16. C with the left mouse and move it around.  The triangle changes shape,
  17. but watch the intersection of the three medians.
  18.  
  19. After you have convinced yourself that the theorem is true (or at least
  20. approximately so, to the precision of the machine), you can see a proof
  21. by clicking on the button labelled "next" in the upper right portion of
  22. the controls area.  Each click of the "next" button takes you one step
  23. further through the proof.  In this example, the proof takes only two
  24. steps.  You can go back to the beginning with the "start" button, and
  25. you can go back one step in the proof with the "prev" button.
  26.  
  27. At any stage in the proof, the free vertices can still be moved around
  28. to show how constructed lines, etc. change with different
  29. configurations of the problem.
  30.  
  31. In any of the example files, the left mouse button can drag the free
  32. vertices.  Only vertices can be moved, however.  Everything else is
  33. ultimately defined in terms of free vertices or partially constrained
  34. vertices (vertex on a line, on a circle, etc.).
  35.  
  36. For a far more interesting theorem and proof, try loading the example
  37. called Theorems/proofs/Ninepoint.T.
  38.  
  39. Try any of the other examples.  Most do not yet have a proof built in,
  40. but the theorems are explained in the accompanying text.  There is some
  41. junk mixed in as well, but an attempt has been made to sort the example
  42. files into subdirectories.  All the example files for geometer have the
  43. suffix ".T", although it's not required.
  44.  
  45. The constraint evaluation code is pretty robust, and "reasonable" things
  46. happen if you ask to find the intersection of parallel lines, etc.
  47.  
  48.             Geometer Documentation:
  49.  
  50. The program is invoked as:
  51.  
  52. geometer
  53.  
  54. or
  55.  
  56. geometer <filename>
  57.  
  58. where <filename> is a geometry file in the correct format.
  59.  
  60. The geometric primitives currently include:
  61.  
  62.     vertices, lines, circles, bezier curves, lengths, ratios,
  63.     conics, and angles
  64.  
  65. Not all are accessible from the button interface, and lengths, ratios,
  66. and angles are all stored internally in the same way -- as a floating
  67. point number.  In other words, you can multiply an angle by an angle,
  68. and geometer won't care, although it doesn't make much sense
  69. geometrically.
  70.  
  71. To create a vertex, click on "New Vert", and then click in the black
  72. area.  If you middle-click most buttons like "New Vert", you can
  73. make as many as you want.  Click a new button, or in some blank space
  74. in the controls area to get out of multiple creation mode.
  75.  
  76. There is a small feedback window that displays the status -- namely,
  77. what geometer expects you to do next.  In basic mode, it's just waiting for
  78. you to select a vertex and move it, or to pick a new command from the
  79. menu.
  80.  
  81. Under "Make Vert" are a number of ways to make a new vertex.  They are:
  82.  
  83. New Vert:    click in a free vertex
  84. L,L=>V:        make a vertex thats at the intersection of 2 lines
  85. VVmid:        make a vertex at the midpoint between 2 vertices
  86. V on L:        make a vertex constrained to lie on a given line
  87. V on C:        make a vertex constrained to lie on a given circle
  88. L,C=>V        vertex at intersection of a line and circle (there
  89.         are up to 2 solutions; click near the one you want.)
  90. C,C=>V        same as above, but at the intersection of 2 circles
  91.  
  92. For making lines:
  93.  
  94. V,V=>L        make a line connecting 2 vertices
  95. V,L=>Lprp    construct the line perpendicular to a line and passing
  96.         through the vertex
  97. V,L=>Lpar    construct the line parallel to a line and passing
  98.         through the vertex
  99. V,C=>L        make a line through a vertex and tangent to a circle
  100. C,C=>Lext    make a line externally tangent to two circles
  101. C,C=>Lint    make a line internally tangent to two circles
  102.  
  103. For circles:
  104.  
  105. Ctr,Edg=>C    use the first vertex as the center, the second as a
  106.         point on the radius.
  107. V,V,V=>C    make a circle through 3 vertices.
  108.  
  109. For conics:
  110.  
  111. 5*V=>Conic    Make a conic through 5 points.
  112.  
  113. Lines can be infinite (Line), semi-infinite (Ray), or finite (Segment). 
  114. Select a line and click on the correct button to change the line type. 
  115. It also changes the mode, so all lines afterwards will have the new
  116. type.
  117.  
  118. Click on a color to change the color of the selected thing, and to set
  119. the current color.  The special color "Inv" is invisible.  The object's
  120. constraints will be satisfied, but the object will be invisible.  This
  121. is great for hiding construction lines.  The color "Sm" stands for
  122. "Smear".  Items painted the smear color will smear as a vertex is
  123. dragged around.
  124.  
  125. "Show Invis" toggles whether invisible lines are shown.  If they are not
  126. shown, they can't be selected.
  127.  
  128. "Show Info" toggles whether the text descriptions are shown.  If the screen
  129. is too cluttered, you may want to turn descriptions off.
  130.  
  131. "Set color" allows you to click on an object to change its color.  You
  132. usually want to middle click it so you can change lots of colors.
  133.  
  134. There is a pull-down menu bar along the top of the window.  Under the
  135. "File" heading are commands to save files, visit new files, and so on.
  136. All file name specification is done using the Showcase file browser, so
  137. Showcase has to be installed to use these commands.  If you don't have
  138. Showcase installed, you can still run geometer on individual files from
  139. the shell command line.
  140.  
  141. The "Print" command makes a PostScript file and calls lp on it, if a
  142. printer is magically hooked up in the right way, you can get a picture
  143. of what's on the screen.  Invisible lines will be displayed as dotted
  144. lines in your print, if you are showing invisible lines when you issue
  145. the print command.  (There's no feedback that the printing was
  146. successful, so don't go banging away on the button, or you'll get lots
  147. of copies.)
  148.  
  149. The "Print EPS" makes an encapsulated PostScript file called geom.eps,
  150. but does not send it to the printer.
  151.  
  152. There's also a hack for getting postscript-like output during a smear
  153. operation.  Alt-x toggles it on and off, and while it is on, PostScript
  154. for the smeared primitives is dumped to standard output.  To use it,
  155. you'll have to capture the output and hand-edit it into a file, but it's
  156. better than nothing.
  157.  
  158. Alt-l (that's lowercase L) draws all the lines double width which
  159. improves the appearance for demos sometimes.
  160.  
  161. Under the "Edit" menu are the commands "Delete", "Edit Source", and
  162. "Describe Item".
  163.  
  164. "Delete" deletes the current selection if possible.  It can't do so if
  165. some other geometric object depends on it.
  166.  
  167. "Edit Source" fires up the jot text editor on the text form of the file and
  168. rereads the modified file when jot exits.  Jot does it's work on the
  169. file /tmp/geom.x.  If jot is not installed, you can't use the edit
  170. command; however, you can edit the file from another editor, and
  171. repeatedly view it from geometer.  It's much easier just to install jot,
  172. however.
  173.  
  174. Finally, "Describe Item" gives a short textual description of the
  175. selected item.  When possible, it gives the names displayed on the
  176. screen, but if the item has no displayed name, it gives the internal
  177. name.  Displayed names are presented in double quotes; internal names
  178. are enclosed within parentheses.
  179.  
  180. The arrow buttons between the main keyboard and the numeric key pad move
  181. the entire figure up, down, left, and right a little bit.  They are used
  182. primarily for small adjustments of the entire figure prior to printing. 
  183. Similarly the "Page Up" and "Page Down" keys in the cluster above the
  184. arrow keys increase and decrease the size of the figure by factors of
  185. 1.01 and 1/1.01, respectively.  This zooming is relative to the center
  186. of the display area.
  187.  
  188.     Layers
  189.  
  190. There are 16 layers (0 through 15).  Geometry can appear on any or all
  191. the layers.  The layers currently being viewed are highlighted in the
  192. layer display in the controls area.  Layers can be enabled or disabled
  193. by clicking in the appropriate boxes.  "on" turns on all the layers;
  194. "start" turns off all but layer 0, "next" increases the number of all
  195. the visible layers by one, and "prev" decreases by one all the visible
  196. layers.
  197.  
  198. When you create geometry, it appears on all the layers indicated.  When
  199. you display the drawing, any items that have any layers in common with
  200. the currently active layers are drawn.
  201.  
  202.     File Format
  203.  
  204. If you muck with the files with an editor (like jot in interactive
  205. mode), the format is C-like.  I've designed it to be easy to extend,
  206. but I have only a primitive parser now, and a lot of obvious things
  207. can't yet be done.  Look at the sample theorem files for examples. 
  208. Here's a quick explanation of some of the commands:
  209.  
  210. Any word beginning with a period (".") is reserved.
  211.  
  212. Variables are defined by their first appearance.  After it has been
  213. defined, a variable can be used in future definitions.  Variables stand
  214. for any of the geometric primitives.  For example, here's a complete
  215. file that defines two points and a line connecting them:
  216.  
  217.     .geometry "version 0.1";
  218.     v1 = .free(-0.293478, 0.222826, "1");
  219.     v2 = .free(0.358696, -0.0163043, "2");
  220.     l1 = .l.vv(v1, v2);
  221.  
  222. The first line is currently optional, but it's a good idea to include it
  223. for future upward compatibility.
  224.  
  225. The second and third lines define two free vertices called v1 and v2
  226. ("free" means that they can be moved with the left mouse button).  The
  227. coordinates are initial positions on the screen (normally, geometer's
  228. coordinate system displays data in the range -1.0 <= x, y <= 1.0).
  229. Finally, the "1" and "2" represent the names to be displayed.
  230.  
  231. Finally, the line l1 is defined to be the line passing through the two
  232. vertices v1 and v2.  l1 has no name.
  233.  
  234.     Properties
  235.  
  236. Every geometric primitive has a few properties associated with it.
  237. These currently include such things as color, layer, name, line-type
  238. (if it's a line), and vertex type (if it's a vertex).
  239.  
  240. There are default values for each property, and if none is specified in
  241. a primitive's description, the default is used.  The defaults are:
  242.  
  243.     color:        white (color index 7, really)
  244.     name:        none
  245.     layer:        all (0-15)
  246.     line-type:        segment
  247.     vertex-type:    diamond
  248.  
  249. Any property information in a primitive's description overrides the
  250. default.  For example, the line:
  251.  
  252.     vert23 = .free(0.0, 0.0, .red, .cross, "foo");
  253.  
  254. defines a vertex with internal name vert23, displayed name "foo", drawn
  255. in red, and shaped like a cross.  Since nothing about layers was stated,
  256. it will be in all layers (the default).
  257.  
  258. Each primitive description has a few required fields, and after all
  259. those have been filled in, any combination of properties may be
  260. specified.
  261.  
  262. The overriding properties can appear in any order, and there is no error
  263. if inconsistent data is given.  The later data overrides the earlier
  264. data.  For example:
  265.  
  266.     vertex561 = .free(0.0, 0.0, .red, .green);
  267.  
  268. will be drawn in green.
  269.  
  270. If no layer information is given, the primitive will appear on all
  271. layers; if any layer information is given, the primitive will be drawn
  272. on all and only the layers given.  For example:
  273.  
  274.     vv = .free(0.0, 0.0, .L2, .L3, .L4);
  275.  
  276. will be drawn only on layers 2, 3, and 4.
  277.  
  278. If line-type information is given for a non-line or vertex-type
  279. information for a non-vertex, it is ignored.
  280.  
  281. Here is a list of all the allowed properties:
  282.  
  283.     line-types
  284.  
  285.     .segment -- joins the two endpoints
  286.     .ray -- starts at the first point and goes
  287.         forever through the second
  288.     .longline -- infinite line through the two vertices
  289.  
  290.     vertex-types
  291.  
  292.     .diamond, .plus, .cross, .nomark, .soliddiamond
  293.  
  294.     colors
  295.  
  296.     .black = .c0 -- black
  297.     .red = .c1   -- red
  298.     .green = .c2 -- green
  299.     .yellow = .c3 -- yellow
  300.     .blue = .c4 -- blue
  301.     .magenta = .c5 -- magenta
  302.     .cyan = .c6 -- cyan
  303.     .white = .c7 -- white
  304.     .c8, .c9, ..., .c31 -- color map colors 8 through 31
  305.     .invisible -- not drawn
  306.     .smear -- color smears while vertex is dragged
  307.     .blink -- blinking yellow and black
  308.  
  309.     layers
  310.  
  311.     .L0, .L1, ..., .L15
  312.  
  313.     names
  314.  
  315.     anything enclosed in "double quotes".
  316.  
  317. If a length, ratio, or angle is assigned a name, it's numerical value is
  318. displayed to the left of the figure.  If there's no name, the value is
  319. hidden.
  320.  
  321.     Constraints
  322.  
  323. Every primitive is defined in terms of constraints.  In one of the
  324. examples above, ".l.vv" defines a line constrained to pass through two
  325. given vertices.
  326.  
  327. Most of the constraints are of the form: .x.yyyy, where the first part,
  328. "x" is what's being made (v=vertex, l=line, c=circle, ...).  The next
  329. entries are the things from which it's made.  (.v.ll, for example, makes
  330. a vertex that's the intersection of 2 lines.)  Sometimes there's more,
  331. like .l.vlperp (which makes a line passing through a vertex, and
  332. perpendicular to a given line.
  333.  
  334. If there are multiple possibilities, there may be an integer to tell
  335. which one, for example:
  336.  
  337.     vv = .v.cc(circ1, circ2, 1);
  338.  
  339. makes a vertex at the intersection of two circles.  Replace the "1" with
  340. a "2" to get the other intersection.
  341.  
  342. Here are forms of the rest of the recognized commands.  Note that the
  343. set may increase in the future as new primitives are added.  There is no
  344. possibility of conflict with user-defined names, since all the new
  345. primitives will be defined with names beginning with a period.
  346.  
  347. In the listing below, only the required fields are specified; any number
  348. of additional properties can be specified in any order.  The types of
  349. the parameters are important and are checked.  For example, ".l.vv",
  350. which makes a line from two vertices, will barf if its parameters are
  351. not variables representing vertices.
  352.  
  353. In what follows, "vertex" stands for any vertex identifier, "circle", for
  354. any circle identifier, and so on.  Remember that "length", "angle", and
  355. "ratio" are all synonyms and can be used interchangeably.  However, a
  356. ratio constructed in one insturction will usually be used in another
  357. line where "ratio" is specified as the input type.
  358.  
  359. vertex = .free(<float>, <float>);
  360.  
  361.     Make a completely unconstrained vertex whose initial coordinates
  362.     are given by the two floating-point numbers.
  363.  
  364. vertex = .vonl(<float>, <float>, line);
  365.  
  366.     Make a vertex constrained to be on the line, so it has one
  367.     degree of freedom.  The floating point values are the vertex's
  368.     initial coordinates (which need not be on the line -- the
  369.     vertex will instantly be projected to the line for the first
  370.     display).
  371.  
  372. vertex = .vonc(<float>, <float>, circle);
  373.  
  374.     Make a vertex constrained to be on the circle, so it has one
  375.     degree of freedom.  The floating point values are the vertex's
  376.     initial coordinates (which need not be on the circle -- the
  377.     vertex will instantly be projected to the circle for the first
  378.     display).
  379.  
  380. vertex = .v.vvmid(vertex, vertex);
  381.  
  382.     Make a vertex constrained to be the midpoint of the other two
  383.     vertices.
  384.  
  385. vertex = .v.ll(line, line);
  386.  
  387.     Make a vertex constrained to be at the intersection of the
  388.     two given lines.
  389.  
  390. vertex = .v.lc(line, circle, <integer>);
  391.  
  392.     The vertex is at the intersection of the line and the circle.
  393.     Since there are two possible intersections, they are
  394.     distinguished by the value of the integer, which must be 1 or
  395.     2.
  396.  
  397. vertex = .v.cc(circle, circle, <integer>);
  398.  
  399.     The vertex is at the intersection of the two circles.  Since
  400.     there are two possible intersections, they are distinguished by
  401.     the value of the integer, which must be 1 or 2.
  402.  
  403. vertex = .v.vvratio(vertex, vertex, ratio);
  404.  
  405.     A ratio is basically a floating point value that represents
  406.     the distance between a pair of points.  It is 0.0 at the
  407.     first point, and 1.0 at the other.  Numbers outside this
  408.     range represent points on the line outside the endpoints.
  409.     Ratios are constructed like any other primitive (see below).
  410.     This constructs a new vertex having the given ratio between
  411.     the given vertices.
  412.  
  413. vertex = .v.avv(angle, vertex, vertex);
  414.  
  415.     A new vertex is constructed such that the angle formed
  416.     using it and the other two vertices is equal to the given
  417.     angle.
  418.  
  419. vertex = .v.ccenter(circle);
  420.  
  421.     The vertex is at the center of the given circle.
  422.  
  423. vertex = .v.lvmirror(line, vertex);
  424.  
  425.     The mirror image of the vertex through the line is generated.
  426.  
  427. vertex = .vonconic(conic, <float>, <float>);
  428.  
  429.     Constrains the vertex to be on the given conic section.
  430.  
  431. vertex = .v.vcinv(vertex, circle);
  432.  
  433.     Inverts the given vertex through the circle.
  434.  
  435. vertex = .v.lconic(line, conic, <integer>);
  436.  
  437.     The vertex is at the intersection of the line and the
  438.     conic section.  There are up to 2 possibilities, so
  439.     <integer> can be 1 or 2.
  440.  
  441. line = .l.vv(vertex, vertex);
  442.  
  443.     The new line passes through the two given vertices.
  444.  
  445. line = .l.vlperp(vertex, line);
  446.  
  447.     A new line is constructed, passing through the given
  448.     vertex and perpendicular to the given line.
  449.  
  450. line = .l.vlpar(vertex, line);
  451.  
  452.     A new line is constructed, passing through the given
  453.     vertex and parallel to the given line.
  454.  
  455. line = .l.vc(vertex, circle, <integer>);
  456.  
  457.     The new line passes through the vertex and is tangent to
  458.     the given circle.  In general, there are two possibilities,
  459.     so <integer> is 1 or 2.
  460.  
  461. line = .l.ccext(circle, circle, <integer>);
  462.  
  463.     The new line is an exterior tangent to the two given
  464.     circles.  <integer> is 1 or 2, since there are two
  465.     possibilities.
  466.  
  467. line = .l.ccint(circle, circle, <integer>);
  468.  
  469.     The new line is an interior tangent to the two given
  470.     circles.  <integer> is 1 or 2, since there are two
  471.     possibilities.
  472.  
  473. line = .l.conicv(conic, vertex, <integer>);
  474.  
  475.     Constructs a line tangent to the conic, and passing through
  476.     the vertex.  There are 2 possibilities, so <integer> is 1
  477.     or 2.
  478.  
  479. circle = .c.vv(vertex, vertex);
  480.  
  481.     The new circle is constrained to have its center at the
  482.     first vertex, and to pass through the second.
  483.  
  484. circle = .c.vvv(vertex, vertex, vertex);
  485.  
  486.     The new circle passes through all three vertices.
  487.  
  488. circle = .c.lll(line, line, line, <integer>);
  489.  
  490.     The new circle is tangent to all three lines.  There are,
  491.     in general, 4 possibilities, so <integer> is 1, 2, 3, or 4.
  492.  
  493. circle = .c.vlen(vertex, length);
  494.  
  495.     The circle has a center at the vertex, and a radius equal
  496.     to the length.  Length is a primitive that must already be
  497.     defined.  See below.
  498.  
  499. circle = .c.ccinv(circle, circle);
  500.  
  501.     The new circle is the inverse of the first circle 
  502.     through the second circle.
  503.  
  504. circle = .c.lcinv(line, circle);
  505.  
  506.     The new circle is the inverse of the line through the circle.
  507.  
  508. bezier = .bez.vvvv(vertex, vertex, vertex, vertex);
  509.  
  510.     A new cubic Bezier curve is constructed having the four
  511.     vertices as control points.
  512.  
  513. ratio = .ratio.vvv(vertex, vertex, vertex);
  514.  
  515.     A ratio is constructed using the distances between the
  516.     three vertices.  This will make much better sense if the
  517.     three vertices happen to fall on a line.
  518.  
  519. length = .len.vv(vertex, vertex);
  520.  
  521.     The length is the length between the two vertices.
  522.  
  523. length = .len.plus(length, length);
  524.  
  525.     The new length is the sum of the two given lengths.
  526.  
  527. length = .len.minus(length, length);
  528.  
  529.     The new length is the sum of the two given lengths.
  530.  
  531. length = .len.times(length, length);
  532.  
  533.     The new length is the sum of the two given lengths.
  534.  
  535. length = .len.divide(length, length);
  536.  
  537.     The new length is the sum of the two given lengths.
  538.  
  539. length = .len.f(<float>);
  540.  
  541.     The value of length is given by a floating point number.
  542.  
  543. angle = .a.vvv(vertex, vertex, vertex);
  544.  
  545.     The angle is the angle made by the three vertices.
  546.  
  547. conic = .c.vvvvv(vertex, vertex, vertex, vertex, vertex);
  548.  
  549.     Make a conic section passing through the five vertices.
  550.  
  551. conic = .c.lllll(line, line, line, line, line);
  552.  
  553.     Make a conic section tangent to the five lines.
  554.  
  555. .text("Any text you want.");
  556.  
  557.     Makes a line of text to be displayed at the bottom of the
  558.     screen.  The order in which text lines appear dictates the
  559.     order in which they are displayed.  In the current
  560.     implementation, at most 8 lines are visible.  Use the
  561.     text in combinations with layers for more information.
  562.  
  563. // any comment text in the world.
  564.  
  565.     Any line beginning with "//" is ignored, but is saved and
  566.     printed in any output files generated.
  567.  
  568.  
  569.     Programming hints:
  570.  
  571. If you want a demonstration where more and more information appears each
  572. time you press the "next" button, draw your initial figure with all
  573. layers enabled.  Then disable layer 0, and draw the next set of stuff,
  574. then disable layer 1 and draw the next set, and so on.
  575.  
  576. Lots of constructions can be accomplished using the tools provided, and
  577. then "erased" using the invisible color.
  578.  
  579.  
  580.