1# macros for chem; 1.1 (CWI) 87/03/31 2 3pi = 3.141592654 4deg = 57.29578 5# cr = 0.08 # radius of invis circle at ring vertices (see cr[vh]) 6# crh = 0.16; crw = 0.12 # ht & wid of invis ellipse around atoms at ring vertices 7# dav = 0.015 # vertical shift up for atoms in atom macro 8 9# atom(text, wid, ht, carbon position, crh, crw, dav) 10define atom { [ 11 T: $1 wid $2 ht $3-2*$7 12 C: ellipse invis ht $5 wid $6 at T.w + ($4,$7) 13 L: ellipse invis ht $5 wid $6 at T.w + (cwid/2,$7) 14 R: ellipse invis ht $5 wid $6 at T.e + (-cwid/2,$7) 15] } 16 17# bond(length, angle in degrees, whatever) 18define bond { 19 line $3 by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg) 20} 21 22# fancy bonds: r, theta, from/at 23define doublebond { 24 line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg) 25 V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y 26 norm = sqrt(dx*dx + dy*dy) 27 ny = dx * .02 / norm 28 nx = -dy * .02 / norm 29 line from V1 + (nx,ny) to V2 + (nx,ny) 30 line from V1 - (nx,ny) to V2 - (nx,ny) 31 move to V2 32} 33define triplebond { 34 line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg) 35 V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y 36 norm = sqrt(dx*dx + dy*dy) 37 ny = dx * .025 / norm 38 nx = -dy * .025 / norm 39 line from V1 + (nx,ny) to V2 + (nx,ny) 40 line from V1 - (nx,ny) to V2 - (nx,ny) 41 line from V1 to V2 42 move to V2 43} 44define backbond { 45 line $3 invis by ($1) * sin(($2)/deg), ($1) * cos(($2)/deg) 46 V1: last line.start; V2: last line.end; dx = V2.x-V1.x; dy = V2.y-V1.y 47 norm = sqrt(dx*dx + dy*dy) 48 n = norm / .025 49 ny = dx * .02 / norm 50 nx = -dy * .02 / norm 51 for i = 1 to n-1 do { 52 XZ: i/n <V1,V2> 53 line from XZ + (nx,ny) to XZ - (nx,ny) 54 } 55 move to V2 56} 57define frontbond { 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 ah = arrowht; aw = arrowwid; ahead = arrowhead 61 arrowht = sqrt(dx*dx + dy*dy) 62 arrowwid = 0.05 63 arrowhead = 7 64 line <- from V1 to V2 65 arrowht = ah; arrowwid = aw; arrowhead = ahead 66} 67