Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
metapost [2019/12/24 14:23]
tarquinwj typo
metapost [2020/02/19 17:54] (current)
tarquinwj Better magnetism symbol
Line 572: Line 572:
 ===Magnetic effects=== ===Magnetic effects===
  
-[[user:​tarquinwj|Tarquin 2019]]+[[user:​tarquinwj|Tarquin 2019-2020]]
  
 Certain rocks can cause a compass to give the wrong reading. This icon can be used to show areas where this happens (ie. where the survey may be unreliable as a result); a spinning compass: Certain rocks can cause a compass to give the wrong reading. This icon can be used to show areas where this happens (ie. where the survey may be unreliable as a result); a spinning compass:
Line 580: Line 580:
   % a spinning compass   % a spinning compass
   def p_u_magnetism (expr P,R,S,A)=   def p_u_magnetism (expr P,R,S,A)=
-    scale:​=0.5u;​ +    ​begingroup;​ 
-    ​halfline:=(0.5u/20S); %half thickness of PenC - pen thicknesses do not scale with S +      save scale, cthick, pointheight,​ pointwidth, cutheight, cutwidth; 
-    pointheight:​=scale*.9;​ +      ​scale:​=0.5u;​ 
-    pointwidth:​=scale*.4;​ +      ​cthick:=(xpart (lrcorner ​PenC)) (xpart (llcorner PenC)); 
-    U:​=(scale,​scale);​ +      pointheight:​=scale*.9;​ 
-    T:=identity aligned A rotated (R-20) scaled S shifted P; +      pointwidth:​=scale*.4;​ 
-    % a circle +      ​cutheight:​=pointheight - (cthick / sind(angle(pointheight,​pointwidth)));​ 
-    thdraw fullcircle scaled 2scale withpen PenC withcolor black+      cutwidth:​=pointwidth - (cthick / sind(angle(pointwidth,​pointheight)));​ 
-    % filled triangle +      ​U:​=(scale,​scale);​ 
-    thfill (0,​pointheight)--(pointwidth,​0)--(-pointwidth,​0)--cycle ​withcolor black+      T:=identity aligned A rotated (R-20) scaled S shifted P; 
-    % black triangle outline +      % a circle 
-    ​thdraw ​(0,​-pointheight+halfline)--(pointwidth-halfline,0) withpen PenC withcolor black; +      thdraw fullcircle scaled 2scale withpen PenC; 
-    thdraw ​(0,​-pointheight+halfline)--(-pointwidth+halfline,0) withpen PenC withcolor black+      % filled triangle 
-    % spin arcs, a full circle is path 0-8, anticlockwise,​ starting from the right +      thfill (0,​pointheight)--(pointwidth,​0)--(-pointwidth,​0)--cycle;​ 
-    thdraw subpath (2.4,3.5) of fullcircle scaled 1.5scale withpen PenC withcolor black+      % black triangle outline 
-    thdraw subpath (6.4,7.5) of fullcircle scaled 1.5scale withpen PenC withcolor black;+      % this can be drawn with mitred pens, but it still ends up needing calculations to get the centre position of the pen thickness 
 +      % therefore it is easier to just use a filled path 
 +      % pointheight/​2 is used to stop the thin unpainted gap between shapes 
 +      thfill ​(0,​-pointheight)--(pointwidth,0)--(0,​pointheight/​2)--(cutwidth,0)--(0,-cutheight)--(-cutwidth,​0)--(0,​pointheight/2)--(-pointwidth,​0)--cycle
 +      % spin arcs, a full circle is path 0-8, anticlockwise,​ starting from the right 
 +      thdraw subpath (2.4,3.5) of fullcircle scaled 1.5scale withpen PenC; 
 +      thdraw subpath (6.4,7.5) of fullcircle scaled 1.5scale withpen PenC
 +    endgroup;
   enddef;   enddef;
   initsymbol("​p_u_magnetism"​);​   initsymbol("​p_u_magnetism"​);​
  • metapost.1577193827.txt.gz
  • Last modified: 8 weeks ago
  • by tarquinwj