Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / contrib / groff / contrib / chem / chem.pic
1 # macros for chem
2         
3 # Source file position: <groff-source>/contrib/chem/chem.pic
4 # Installed position: <prefix>/share/groff/<version>/pic
5
6 # Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
7 # Written by Brian Kernighan <http://cm.bell-labs.com/cm/cs/who/bwk>,
8 # modified by Bernd Warken.
9
10 # This file is part of `chem', which is part of `groff'.
11
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 3 of the License, or
15 # (at your option) any later version.
16
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.
21
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24
25 ########################################################################
26
27 pi = 3.141592654
28 deg = 57.29578
29 # cr = 0.08             # radius of invis circle at ring vertices (see cr[vh])
30 # crh = 0.16; crw = 0.12 # ht & wid of invis ellipse around atoms at ring vertices
31 # dav = 0.015           # vertical shift up for atoms in atom macro
32
33 # atom(text, wid, ht, carbon position, crh, crw, dav)
34 define atom { [
35         T: $1 wid $2 ht $3-2*$7
36         C: ellipse invis ht $5 wid $6 at T.w + ($4,$7)
37         L: ellipse invis ht $5 wid $6 at T.w + (cwid/2,$7)
38         R: ellipse invis ht $5 wid $6 at T.e + (-cwid/2,$7)
39 ] }
40
41 # bond(length, angle in degrees, whatever)
42 define bond {
43         line $3 by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg)
44 }
45
46 # fancy bonds:  r, theta, from/at
47 define doublebond {
48         line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg)
49         V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y
50         norm = sqrt(dx*dx + dy*dy)
51         ny = dx * .02 / norm
52         nx = -dy * .02 / norm
53         line from V1 + (nx,ny) to V2 + (nx,ny)
54         line from V1 - (nx,ny) to V2 - (nx,ny)
55         move to V2
56 }
57 define triplebond {
58         line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg)
59         V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y
60         norm = sqrt(dx*dx + dy*dy)
61         ny = dx * .025 / norm
62         nx = -dy * .025 / norm
63         line from V1 + (nx,ny) to V2 + (nx,ny)
64         line from V1 - (nx,ny) to V2 - (nx,ny)
65         line from V1 to V2
66         move to V2
67 }
68 define backbond {
69         line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg)
70         V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y
71         norm = sqrt(dx*dx + dy*dy)
72         n = norm / .025
73         ny = dx * .02 / norm
74         nx = -dy * .02 / norm
75         for i = 1 to n-1 do {
76                 XZ: i/n <V1,V2>
77                 line from XZ + (nx,ny) to XZ - (nx,ny)
78         }
79         move to V2
80 }
81 define frontbond {
82         line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg)
83         V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y
84         ah = arrowht; aw = arrowwid; ahead = arrowhead
85         arrowht = sqrt(dx*dx + dy*dy)
86         arrowwid = 0.05
87         arrowhead = 7
88         line <- from V1 to V2
89         arrowht = ah; arrowwid = aw; arrowhead = ahead
90 }
91 ### Emacs settings
92 # Local Variables:
93 # mode: Nroff
94 # End: