Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/extras/Chuck.m4

raw
1 .PS
2 # Chuck.m4
3 gen_init s_init(Views) sinclude(tst.dim)
4 #
5 #################################################################
6 divert(-1)
7
8 `r_box(angle,pos,string)
9 Rotated text on a white background
10 (requires pstricks)'
11 define(`r_box',
12 `ifpstricks(`M4tmp: ifelse(`$2',,Here,`$2')
13 command sprintf("\rput{%g}(%g,%g){",`$1',crl(M4tmp.x),crl(M4tmp.y))
14 f_box(`$3') at Orig
15 command "}%"')')
16 define(`crl',`int(`($1)'/scale*1000000)/1000000')
17
18 `r_dimen(linespec,offset,label,tic offset,<->,pos)
19 dimension_ with rotated text on white background'
20 define(`r_dimen',
21 `M4tmp: dimension_(`$1',`$2',,,`$4',`$5')
22 r_box(rp_ang*rtod_,ifelse(`$6',,M4tmp+vec_(0,`$2'),`$6'),`$3')')
23
24 `ctrline(linespec,len)
25 Centerline'
26 define(`cdashl',0.1*scale)
27 define(`cgapl',0.03*scale)
28 define(`ctrline',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1'))
29 define(`m4h',ifelse(`$2',,1*scale,`$2'))dnl
30 m4n = int(rp_len/2/(m4h))*2+1
31 for i=1 to m4n do {
32 line to rvec_(rp_len/m4n/2-cdashl/2-cgapl,0)
33 move to rvec_(cgapl,0); line to rvec_(cdashl,0); move to rvec_(cgapl,0)
34 line thick dimensionth to rvec_(rp_len/m4n/2-cdashl/2-cgapl,0) } ')
35
36 `ctrarcr(pos,radius,startang,endang,len)
37 Arc cr centerline'
38 define(`ctrarcr',`dnl
39 define(`m5h',ifelse(`$5',,1*scale,`$5'))dnl
40 rp_len = abs((`$2')*(`$4'-(`$3')))
41 m5n = int(rp_len/2/(m5h))*2+1
42 m5a = (rp_len/m5n/2-cdashl/2-cgapl)/(`$2')
43 m5s = cdashl/(`$2')
44 m5sa = `$3'
45 for m4irr=1 to m5n do {
46 arc from `$1'+(rect_(`$2',m5sa)) to `$1'+(rect_(`$2',m5sa+m5a)) \
47 with .c at `$1'
48 m5sa = m5sa+m5a+cgapl/(`$2')
49 arc from `$1'+(rect_(`$2',m5sa)) to `$1'+(rect_(`$2',m5sa+m5s)) \
50 with .c at `$1'
51 m5sa = m5sa+m5s+cgapl/(`$2')
52 arc from `$1'+(rect_(`$2',m5sa)) to `$1'+(rect_(`$2',m5sa+m5a)) \
53 with .c at `$1'
54 m5sa = m5sa+m5a
55 } ')
56
57 divert(0)dnl
58 #################################################################
59
60 scale = 25.4*2
61 tic = 3.6bp__
62
63 command "{\sf"
64
65 define(`visible_thick',`linethick_(visibleth)')
66 define(`hidden_thick',`linethick_(hiddenth)')
67 define(`dimension_thick',`linethick_(dimensionth)
68 arrowwid = 1.5*arrowwid; arrowht = 1.5*arrowht; ')
69
70 d1 = 230
71 d2 = 204
72 d3 = 140
73
74 visibleth = 1.2
75 dimensionth = 0.4
76 hiddenth = dimensionth
77
78 Orig: Here
79 visible_thick
80 D3: circle diam d3 at Orig
81 D2: circle diam d2 at Orig
82
83 rr = d1/2
84 r = 40
85 h = 110/2
86 thet = asin((h+r)/(rr+r))
87 X1: rect_(rr,thet)
88 P1: rect_(rr+r,thet)
89
90 dimension_thick
91 cross(at (P1.x,-P1.y))
92 cross(at (-P1.x,P1.y))
93
94 # Top outer visible line
95 visible_thick
96 # top arcs
97 arc ccw from (-P1.x,h) to (-X1.x,X1.y) with .c at (-P1.x,P1.y)
98 arc cw to X1 with .c at Orig
99 arc ccw from X1 to (P1.x,h) with .c at P1
100 # right end
101 line from (P1.x,h) to (305/2,h) then to (305/2,32/2) then left 40-3
102 arc ccw rad 3
103 line down 32-2*3
104 arc ccw rad 3
105 dimension_thick {
106 r_dimen(up 32 with .c at (305/2-5,0),0,32)
107 arrow <- up 8 right 8 then right 4 from last arc.sw
108 "3$\,$R" ljust
109 r_dimen(up h*2 at (305/2,0),-10,110)
110 }; visible_thick
111 line right 40-3 then to (305/2,-h) then to (P1.x,-h)
112 # bottom arcs
113 arc ccw to (X1.x,-X1.y) with .c at P1.x,-P1.y
114 arc cw to (-X1.x,-X1.y) with .c at Orig
115 arc ccw to (-P1.x,-h) with .c at (-P1.x,-P1.y)
116 # left end
117 line from (-P1.x,-h) to (-305/2,-h) then to (-305/2,-25/2) then right 25
118 down; arc ccw rad 3
119 line right 40-25-2*3
120 arc ccw rad 3
121 line up 25
122 {R: line invis down 10 at (2nd last line,last line) }
123 arc ccw rad 3
124 line left 40-25-2*3
125 arc ccw rad 3
126 line to (-305/2,25/2) then to (-305/2,h) then to (-P1.x,h)
127
128 dimension_thick
129 # centre
130 ctrline(right 305-30 with .c at Orig,60)
131 ctrline(up d1+10 with .c at Orig,)
132
133 {BX: box invis ht 25+2*3 wid 40-25 rad 3 with .w at (-305/2+25,0)}
134 Q: line invis from BX.n to BX.s; R: line invis from BX.se up 10 left 10
135 X: Intersect_(Q,R)
136 line <-> from BX.se to X then to (X.x,-X.y) then to BX.nw
137 r_box(90,BX,```3$\,$R''')
138
139 # Drill centres
140 D[1]: 35,sqrt(85^2-35^2)
141 D[2]: -D[1].x,D[1].y
142 D[3]: -D[1].x,-D[1].y
143 D[4]: D[1].x,-D[1].y
144 ctrline(from D[3] to D[1] chop 15)
145 ctrline(to rvec_(2*15,0))
146 ctrline(from D[3]+vec_(-15,0) to D[3]+vec_(15,0))
147 ctrline(from D[2] to D[4] chop 15)
148 ctrline(to rvec_(2*15,0))
149 ctrline(from D[2]+vec_(-15,0) to D[2]+vec_(15,0))
150 visible_thick
151 for i=1 to 4 do {
152 circle diam 16 at D[i]
153 for j = 0 to 7 do { arcr(D[i],23/2,j/8*twopi_,(j+3/4)/8*twopi_) ccw }
154 }
155
156 hidden_thick
157 for s=-1 to 1 by 2 do {
158 line dashed from (-305/2,s*h) to (305/2,s*h)
159 line dashed from (-305/2,s*30.6) to (305/2,s*30.6)
160 line dashed from (-305/2,s*21.1) to (305/2,s*21.1)
161 # line dashed from (-305/2+25+2,s*21.1) to (305/2,s*21.1)
162 line dashed dashwid/2 from (-305/2+25,s*25/2) down -s*(40/2-25/2-2);
163 if s<0 then { arc dashed dashwid/4 ccw rad 2 } \
164 else { up; arc dashed dashwid/4 cw rad 2 }
165 line dashed to ((305/2,0),Here)
166 for k = -1 to 1 by 2 do {
167 move to (k*305/2,s*(30.6+10))
168 { dashline(from Here+(0,s*9.5/2) right -k*16,,dashwid/2)
169 dashline(right -k*9.5/2/2 up -s*9.5/2,,dashwid/3)
170 dashline(left -k*9.5/2/2 up -s*9.5/2,,dashwid/3)
171 dashline(left -k*16,,dashwid/2)
172 dashline(from Here+(-k*16,0) up s*9.5,,dashwid/2.5) }
173 { dashline(from Here+(0,s*11/2) right -k*36.5,,dashwid/2)
174 dashline(right -k*11/2/2 up -s*11/2,,dashwid/3)
175 dashline(left -k*11/2/2 up -s*11/2,,dashwid/3)
176 dashline(left -k*36.5,,dashwid/2)
177 dashline(from Here+(-k*36.5,0) up s*11,,dashwid/2.5) }
178 { dashline(from Here+(0,s*13/2) right -k*32,,dashwid/2)
179 dashline(down s*13,,dashwid/2)
180 dashline(left -k*32,,dashwid/2) }
181 ctrline(right -k*20 chop -3 chop 0); ctrline(right -k*20 chop 0 chop -3)
182 }
183 }
184
185 dimension_thick
186 # bottom
187 dimension_(from (-305/2,-h) to (305/2,-h),-(rr*1.1-h),"305",20pt__)
188 # outer radii
189 r_dimen(from (-P1.x,P1.y) down 40*cosd(30) right 40*sind(30),0,40,,->)
190 r_dimen(from (P1.x,-P1.y)+(Rect_(40,120)) \
191 down 40*cosd(30) right 40*sind(30),0,40,,<-)
192 # main diameter
193 r_dimen(from (Rect_(rr,180+50)) to (Rect_(rr,50)),,230,,,(Rect_(50,50)))
194 # inner circles
195 r_dimen(from (Rect_(d2/2,180+25)) to (Rect_(d2/2,25)),,204,,,(Rect_(25,25)))
196 r_dimen(from (Rect_(d3/2,180-12)) to (Rect_(d3/2,-12)),,140,,,(Rect_(25,-12)))
197
198 # bolt hole placement diameter
199 r_dimen(from Orig to (Rect_(85,-43)),,``85$\,$R'',,->,(Rect_(20,-43)))
200 # left slot
201 r_dimen(from (-305/2+6,-25/2) up 25,0,25)
202 r_dimen(from (-305/2,-26) right 40,0,40)
203 line from last line.end to (last line.end.x,BX.s.y) chop -tic chop 0
204 r_dimen(from (-305/2,26) right 25,0,25)
205 line from last line.end to (last line.end.x,BX.n.y) chop -tic chop 0
206 # right slot
207 r_dimen(from (305/2-40,-32/2-10) right 40,0,40)
208 line from (305/2-40,-32/2) down 10+tic
209 # drill-holes
210 for i=1 to 4 do {
211 ctrarcr(Orig,85,atan2(D[i].y,D[i].x)-10*dtor_,atan2(D[i].y,D[i].x)+10*dtor_)
212 }
213 ctrarcr(Orig,85,atan2(D[4].y,D[4].x)+10*dtor_,atan2(D[4].y,D[4].x)+25*dtor_)
214 ctrline(up 30 at D[3])
215 ctrline(up 30 at D[4])
216 r_dimen(from D[3]+(0,-14) right 35,0,35)
217 r_dimen(from (0,D[3].y-14) right 35,0,35)
218
219 command "}%"
220 .PE