Debian Codegraph @

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

raw
1 .PS
2 # Orbits.m4
3 threeD_init
4 NeedDpicTools
5
6 crad = 1.0
7 g = 0.65
8
9 # `orbitpos(long,lat,rad,ang)'
10 define(`orbitpos',
11 `rot3Dx((`$2')*dtor_,rot3Dz((`$1')*dtor_,rot3Dy(-(`$4')*dtor_,`$3',0,0)))')
12
13 define(`PO',`B.C+(Project(orbitpos(orbitlong,orbitlat,orbitrad,`$1')))')
14
15 define vis { X: PO($1)
16 if (distance(X,B.C)>crad) || \
17 (dot3D(View3D,orbitpos(orbitlong,orbitlat,orbitrad,$1))>0) \
18 then {$2 = 1} else {$2 = -1} }
19
20 # `orbit(long,lat,rad)'
21 define(`orbit',
22 `[da = 3
23 orbitlong = `$1'
24 orbitlat = `$2'
25 orbitrad = `$3'
26 define(`decorated',`ifelse(`$4',,,`outlined `$4'')')
27 arrow from PO(0) to PO(da*3) decorated
28 n=0
29 P[n]: PO(0)
30 vis(0,v)
31 for d=da to 360 by da do {
32 vis(d,x)
33 if x*v < 0 then {
34 findroot(vis,d-da,d,1e-6,x)
35 n+=1; P[n]: PO(x)
36 if v < 0 then { fitcurve(P,n,dashed decorated) } \
37 else { fitcurve(P,n,decorated) }
38 P[0]: P[n]
39 n = 0; v = -v }
40 n +=1; P[n]: PO(d)
41 }
42 if v < 0 then { fitcurve(P,n,dashed decorated) } \
43 else { fitcurve(P,n,decorated) }
44 ] with .c at B.C')
45
46 # ball(rad,highlight rad,highlight degrees)
47 define(`ball',`[
48 lt = linethick bp__
49 C: circle invis rad `$1' at (0,0)
50 D: C+(Rect_(`$2',`$3'))
51 rm = `$1'+distance(C,D)
52 a = 1 # fade rate parameter
53 for r=lt to rm by lt do {
54 u = 1-(r/rm*(a*r/rm+(1-a)))
55 if r < (1-g)*`$1' then { circle outlined rgbstring(u,u,u) rad r at D } \
56 else { arc cw outlined rgbstring(u,u,u) from Cintersect(D,r,C,`$1') \
57 to Cintersect(D,r,C,`$1',R) with .c at D
58 }
59 }
60 circle rad C.rad at C
61 ]')
62
63 linethick = 0.8
64 B: ball(crad,crad*g,110)
65
66 azimuth = 0
67 elevation = 0
68 setview(azimuth,elevation)
69
70 orbit(10, 30,crad*1.3,"red")
71 orbit(10,-30,crad*1.3,"blue")
72 orbit(10,-90,crad*1.3,"cyan")
73
74 .PE