% this is means as a form of toolkit for drawing topological % illustrations. % % Copyright (C) Lars Madsen 2007, daleif@imf.au.dk % % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3 or later is part of all distributions of LaTeX % version 2005/12/01 or later. % % This work has the LPPL maintenance status `maintained'. % % The Current Maintainer of this work is Lars Madsen, daleif@imf.au.dk % % This work consists of the file dlf_topo.mp path TOPOHoleHalfCircle,TOPOHoleTopHalfCircle; numeric _TOPOshc_diameter,_TOPO_shc_yscale; _TOPOshc_diameter := 4cm; _TOPO_shc_yscale := 0.6; TOPOHoleHalfCircle := (halfcircle scaled _TOPOshc_diameter yscaled _TOPO_shc_yscale) rotated 180; TOPOHoleTopHalfCircle := TOPOHoleHalfCircle rotated 180 shifted (0,- _TOPO_shc_yscale*_TOPOshc_diameter*0.6) cutafter TOPOHoleHalfCircle cutbefore TOPOHoleHalfCircle; vardef drawHole(expr pkt,ang,scale)= % pkt is where we want to draw this hole % ang % scale draw TOPOHoleHalfCircle scaled scale rotated ang shifted pkt; draw TOPOHoleTopHalfCircle scaled scale rotated ang shifted pkt; enddef; vardef drawWhiteHole(expr pkt,ang,scale)= % same as drawHole, but unfills the 'hole' in the middle unfill buildcycle( TOPOHoleHalfCircle scaled scale rotated ang shifted pkt, TOPOHoleTopHalfCircle scaled scale rotated ang shifted pkt ); drawHole(pkt,ang,scale); enddef; numeric TOPOVulcanoHeight; TOPOVulcanoHeight := 1cm; vardef vulcano(expr p,tstart,tstop,type)= % p = path % tstart = start time on path p % tstop = end time on path p % type = true/false % if true this is a open vulcano and we will return a path that % covers the edge of the vulcano and the lower edge of the top % if false the top is hidden and drawn as a dashed circle % % return the edge of the vulcano save k,vinkel,T,q; pair k[]; numeric T,vinkel; path q[]; k0 := point tstart of p; k1 := point tstop of p; vinkel := angle(k1-k0); k3 := ( (TOPOVulcanoHeight,0) rotated (vinkel+90) ) shifted 0.2[k0,k1]; k4 := ( (TOPOVulcanoHeight,0) rotated (vinkel+90) ) shifted 0.8[k0,k1]; q0 := k0 {dir angle(direction tstart of p)} .. {dir (vinkel +90) } k3; q1 := k4 {dir (vinkel - 90) } .. {dir angle(direction tstop of p)} k1; q2 := k3 {dir (vinkel-80)} .. tension 2 .. {dir (vinkel+80)}k4; q3 := q2 reflectedabout(k3,k4); if type: % open draw q3; q0..q2..q1 else: % closed draw q2 dashed evenly; q0..q3..q1 fi enddef; vardef tuborg(expr a,b,ten,height)= % a,b = the start and end points of the brace % ten = tension in the paths % height = height og the point o the brace over the line through a,b save vinkel; numeric vinkel; vinkel := angle(b-a); a{dir (90+vinkel)} .. tension ten .. {dir (80+vinkel)} ( (a+b)/2 + ( (0,height) rotated vinkel) ) { dir (vinkel-80)} .. tension ten .. {dir (-90+vinkel)} b enddef; numeric TOPOHandleHeight,TOPOHandleHoleScale;; TOPOHandleHeight := 1.8cm; TOPOHandleHoleScale := 0.15; vardef handleWithHole(expr p,tstart,tstop,draw_hole)= % p = path % tstart = start time on path % tstop = sop time on path % draw_hole = true/false, to draw hole or not save start_p,stop_p,mid_p,vinkel,edge,T; pair start_p,stop_p,mid_p; numeric vinkel,T; path edge; T := 1; start_p := point tstart of p; stop_p := point tstop of p; vinkel := angle(stop_p-start_p); mid_p := ( (TOPOHandleHeight,0) rotated (vinkel+90) ) shifted 0.5[start_p,stop_p]; edge := start_p {dir angle(direction tstart of p)} .. % tension T % .. {dir vinkel } mid_p {dir vinkel } .. % tension T % .. {dir angle(direction tstop of p)} stop_p; if draw_hole: drawWhiteHole(0.6[(0.5[start_p,stop_p]),mid_p],vinkel-90,TOPOHandleHoleScale); fi; edge enddef; vardef rotatedPathPoint(expr p,width,time,ang)= % p = path % width = 'height' above the path % time = time on path % ang = angle, usually 90 or -90, corresponding to above or below the path % return a point which is a vector of length 'width' rotated 'ang' % in relation to the direction of 'p' at the given time width*unitvector( direction time of p) rotated ang shifted point time of p enddef; vardef tubeEdge(expr p,width,points,ang)= % p = path % width = distance from p % points = number of points to use to create the tubeEdge % ang = angle, should be 90 or -90 % returns a path constructed from p by taking vectors of length % 'width' in the direction of 'p' and then rotating them 'ang' save pp; path pp; pp := rotatedPathPoint(p,width,0,ang) for i:=1 upto points: .. rotatedPathPoint(p,width,(i/points)*length(p),ang) endfor ; pp enddef; numeric TODORoundEdgeAng; TODORoundEdgeAng := 80; vardef roundTubeHalf(expr p,q,tens,LR)= % p,q = points % tens = curve tension % LR = 1 or -1 corresponding to upper or lower (in the direction of q-p) % returns one half of a curve that might be used to illustrate a % section through a tube, the user will have to draw it them selfs. save pp,vinkel; path pp; numeric vinkel; vinkel := angle(q-p); if LR > 0: p {dir (TODORoundEdgeAng + vinkel)} .. tension tens .. {dir (-TODORoundEdgeAng + vinkel)} q else: p {dir (-TODORoundEdgeAng + vinkel)} .. tension tens .. {dir (TODORoundEdgeAng + vinkel)} q fi enddef; vardef leadsTo(expr p,q,h)= save pp; path pp; pp := p--q; p {dir angle(q-p) } .. rotatedPathPoint(pp,h,8/50,90) .. rotatedPathPoint(pp,h,16/50,-90) .. rotatedPathPoint(pp,h,24/50,90) .. rotatedPathPoint(pp,h,32/50,-90) .. {dir angle(q-p)} point (8/10) of pp -- q enddef;