* tmac/eqnrc (.EQ, .EN): Provide default definitions. Reported
[s-roff.git] / contrib / chem / chem.pic
blob13fdd55ab1f7862677a4a4dddbf2ff1b031e7679
1 # macros for chem
2         
3 # Source file position: <groff-source>/contrib/chem/chem.pic
4 # Installed position: <prefix>/lib/groff/chem
6 # Copyright (C) 2006 Free Software Foundation, Inc.
7 # Written by Brian Kernighan <http://cm.bell-labs.com/cm/cs/who/bwk>,
8 # modified by Bernd Warken.
10 # This file is part of `chem', which is part of `groff'.
12 # `groff' is free software; you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
15 # any later version.
17 # `groff' is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with `groff'; see the files COPYING and LICENSE in the top
24 # directory of the `groff' source.  If not, write to the Free Software
25 # Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301,
26 # USA.
28 ########################################################################
30 pi = 3.141592654
31 deg = 57.29578
32 # cr = 0.08             # radius of invis circle at ring vertices (see cr[vh])
33 # crh = 0.16; crw = 0.12 # ht & wid of invis ellipse around atoms at ring vertices
34 # dav = 0.015           # vertical shift up for atoms in atom macro
36 # atom(text, wid, ht, carbon position, crh, crw, dav)
37 define atom { [
38         T: $1 wid $2 ht $3-2*$7
39         C: ellipse invis ht $5 wid $6 at T.w + ($4,$7)
40         L: ellipse invis ht $5 wid $6 at T.w + (cwid/2,$7)
41         R: ellipse invis ht $5 wid $6 at T.e + (-cwid/2,$7)
42 ] }
44 # bond(length, angle in degrees, whatever)
45 define bond {
46         line $3 by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg)
49 # fancy bonds:  r, theta, from/at
50 define doublebond {
51         line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg)
52         V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y
53         norm = sqrt(dx*dx + dy*dy)
54         ny = dx * .02 / norm
55         nx = -dy * .02 / norm
56         line from V1 + (nx,ny) to V2 + (nx,ny)
57         line from V1 - (nx,ny) to V2 - (nx,ny)
58         move to V2
60 define triplebond {
61         line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg)
62         V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y
63         norm = sqrt(dx*dx + dy*dy)
64         ny = dx * .025 / norm
65         nx = -dy * .025 / norm
66         line from V1 + (nx,ny) to V2 + (nx,ny)
67         line from V1 - (nx,ny) to V2 - (nx,ny)
68         line from V1 to V2
69         move to V2
71 define backbond {
72         line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg)
73         V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y
74         norm = sqrt(dx*dx + dy*dy)
75         n = norm / .025
76         ny = dx * .02 / norm
77         nx = -dy * .02 / norm
78         for i = 1 to n-1 do {
79                 XZ: i/n <V1,V2>
80                 line from XZ + (nx,ny) to XZ - (nx,ny)
81         }
82         move to V2
84 define frontbond {
85         line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg)
86         V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y
87         ah = arrowht; aw = arrowwid; ahead = arrowhead
88         arrowht = sqrt(dx*dx + dy*dy)
89         arrowwid = 0.05
90         arrowhead = 7
91         line <- from V1 to V2
92         arrowht = ah; arrowwid = aw; arrowhead = ahead
94 ### Emacs settings
95 # Local Variables:
96 # mode: Nroff
97 # End: