%%%% sphrmd01.ldf %%%% Created by Laurence D. Finston (LDF) Thu Jan 22 17:09:19 CET 2009 %%%% $Id: sphrmd01.ldf,v 1.8 2010/12/17 14:47:41 lfinsto1 Exp $ %% * (1) Copyright and License. %%%% This file is part of GNU 3DLDF, a package for three-dimensional drawing. %%%% Copyright (C) 2009, 2010, 2011 The Free Software Foundation %%%% GNU 3DLDF is free software; you can redistribute it and/or modify %%%% it under the terms of the GNU General Public License as published by %%%% the Free Software Foundation; either version 3 of the License, or %%%% (at your option) any later version. %%%% GNU 3DLDF is distributed in the hope that it will be useful, %%%% but WITHOUT ANY WARRANTY; without even the implied warranty of %%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %%%% GNU General Public License for more details. %%%% You should have received a copy of the GNU General Public License %%%% along with GNU 3DLDF; if not, write to the Free Software %%%% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA %%%% GNU 3DLDF is a GNU package. %%%% It is part of the GNU Project of the %%%% Free Software Foundation %%%% and is published under the GNU General Public License. %%%% See the website http://www.gnu.org %%%% for more information. %%%% GNU 3DLDF is available for downloading from %%%% http://www.gnu.org/software/3dldf/LDF.html. %%%% Please send bug reports to Laurence.Finston@gmx.de %%%% The mailing list help-3dldf@gnu.org is available for people to %%%% ask other users for help. %%%% The mailing list info-3dldf@gnu.org is for sending %%%% announcements to users. To subscribe to these mailing lists, send an %%%% email with ``subscribe '' as the subject. %%%% The author can be contacted at: %%%% Laurence D. Finston %%%% c/o Free Software Foundation, Inc. %%%% 51 Franklin St, Fifth Floor %%%% Boston, MA 02110-1301 %%%% USA %%%% Laurence.Finston@gmx.de %% Last updated: June 4, 2010 %% Run like this: %% 3dldf sphrmd01.ldf %% mpost sphrmd01.mp %% tex sphrmd01.txt %% dvips -o sphrmd01.ps sphrmd01.dvi %% ps2pdf sphrmd01.ps %% All on one line: if false: 3dldf sphrmd01.ldf && mpost sphrmd01.mp && tex sphrmd01.txt && \ dvips -o sphrmd01.ps sphrmd01.dvi \ && ps2pdf sphrmd01.ps fi; %% View the PostScript file using Ghostview like this: %% gv sphrmd01.ps & %% or with GNU Ghostview like this: %% ggv sphrmd01.ps & %% View the PDF file with Acrobat Reader like this: %% acroread sphrmd01.pdf & %% * (1) Beginning of 3DLDF code. %% ** (2) Plans for a paper (not cardboard!) model of a sphere (Sphere Development 1) %% LOG %% LDF 2010.06.02. %% Replaced dots with crosshairs. %% ENDLOG verbatim_metapost "verbatimtex \font\large=cmr17 etex;"; %% *** (3) Macros def crosshair {point aa, numeric offset} = draw aa -- (aa shifted (offset, 0)) with_pen pencircle scaled (.25mm, .25mm, .25mm); draw aa -- (aa shifted (-offset, 0)) with_pen pencircle scaled (.25mm, .25mm, .25mm); draw aa -- (aa shifted (0, offset)) with_pen pencircle scaled (.25mm, .25mm, .25mm); draw aa -- (aa shifted (0, -offset)) with_pen pencircle scaled (.25mm, .25mm, .25mm); enddef; %% Use negative length for tick mark on the left of aa, positive for one on the right. %% LDF 2010.06.02. def tick {point aa, numeric offset} = draw aa -- (aa shifted (offset, 0)) with_pen pencircle scaled (.25mm, .25mm, .25mm); enddef; %% *** (3) Declarations and initializations PI := 3.141592653589793; focus f[]; set f0 with_position (0, 10, -30) with_direction (0, 10, 10) with_distance 20; circle c[]; point p[]; path q[]; transform t[]; pen thin_pen; pen line_pen; pen dot_pen; thin_pen := pencircle scaled (.25mm, .25mm, .25mm); line_pen := pencircle scaled (.333mm, .333mm, .333mm); dot_pen := pencircle scaled (1mm, 1mm, 1mm); pickup line_pen; color_vector cv; cv += blue; cv += red; cv += green; cv += cyan; cv += magenta; cv += yellow; cv += violet; cv += orange; cv += black; picture v[]; bool_point_vector bpv; numeric r[]; %% Radii numeric d[][]; %% Lengths of the horizontals. string s; %% *** (3) Figure 0 beginfig(0); k := 5; m[0] := 45; %% Main curves m[1] := 30; %% Inner curve for stitches m[2] := 60; %% Outer curve for stitches m[3] := 70; %% Even further out curve for offset beyond the stitches r0 := 5; set c0 with_diameter 2*r0 with_point_count 64; d[0][0] := 2 * PI * r0 * m[0] / 360; d[1][0] := 2 * PI * r0 * m[1] / 360; d[2][0] := 2 * PI * r0 * m[2] / 360; d[3][0] := 2 * PI * r0 * m[3] / 360; %for i = 0 upto 2: % s := "d[" & decimal i & "][0]:"; % message s; % show d[i][0]; %endfor; p0 := get_center c0; dotlabel.rt("$p_0$", p0); rotate c0 (90, 0); draw c0; p1 := p0 shifted (0, -r0); dotlabel.lrt("$p_1$", p1); %draw p0 -- p1; %% Not really necessary. j := 2; for i := k step k until (180 - k): % message "i:"; % show i; p[j] := p1 rotated (0, 0, i); % s := "$p_{" & decimal j & "}$"; % dotlabel.lrt(s, p[j]); draw p0 -- p[j]; %% Not really necessary. j += 1; p[j] := (0, ypart p[j - 1]); r[i] := magnitude (p[j] - p[j - 1]); % s := "r[" & decimal i & "]:"; % message s; % show r[i]; % s := "$p_{" & decimal j & "}$"; % dotlabel.ulft(s, p[j]); draw p[j - 1] -- p[j]; %% Not really necessary. j += 1; d[0][i] := (2 * PI * r[i] * m[0]) / 360; d[1][i] := (2 * PI * r[i] * m[1]) / 360; d[2][i] := (2 * PI * r[i] * m[2]) / 360; d[3][i] := (2 * PI * r[i] * m[3]) / 360; % s := "d[0][" & decimal i & "]:"; % % message s; % show d[0][i]; endfor; endfig with_projection parallel_x_y no_sort; %% *** (3) Figure 1 e := PI * r0; f := e * k / 180; beginfig(1); p2 := (0, e); draw origin -- p2 with_pen thin_pen; j := 1; q0 += origin; q1 += origin; q2 += origin; q3 += origin; q4 += origin; q5 += origin; q6 += origin; q0 += ..; q1 += ..; q2 += ..; q3 += ..; q4 += ..; q5 += ..; q6 += ..; n := 17; for i := k step k until (180 - k): % message "i:"; % show i; p3 := (-d[0][i]/2, j * f); %% Points on main curves p4 := (d[0][i]/2, j * f); p5 := (-d[1][i]/2, j * f); %% Points on inner curves p6 := (d[1][i]/2, j * f); p7 := (-d[2][i]/2, j * f); %% Points on outer curves p8 := (d[2][i]/2, j * f); p9 := (d[3][i]/2, j * f); %% Point on even further out curve draw p3 -- p9 with_color gray; %% Horizontals q0 += p3; %% Main curves q1 += p4; q2 += p5; %% Inner curves q3 += p6; if magnitude n == 15: %% Added. LDF 2010.06.04. crosshair{(mediate(p4, p5, .25)), .1cm}; crosshair{(mediate(p5, p4, .25)), .1cm}; fi; if magnitude n < 15: crosshair{p5, .1cm}; fi; %drawdot p5 with_pen dot_pen; p32 := p5 shifted (-.333cm, 0); p34 := p32 shifted (-.333cm, 0); tick{p32, -.25cm}; p33 := p8 shifted (.333cm, 0); p35 := p33 shifted (.333cm, 0); tick{p33, .25cm}; if n >= 0: s := decimal n; else: s := decimal -n; fi; if is_even n: label.lft(s, p34); fi; if is_even n: label.rt(s, p35); fi; q4 += p7; %% Outer curves q5 += p8; q6 += p9; %% Even futher out curve if magnitude n < 15: crosshair{p8, .1cm}; fi; %drawdot p8 with_pen dot_pen; n -= 1; j += 1; endfor; q0 += p2; q1 += p2; q2 += p2; q3 += p2; q4 += p2; q5 += p2; q6 += p2; draw q0; draw q1 dashed evenly; draw q2 dashed evenly withpen thin_pen; %draw q3; %draw q4; draw q5 dashed evenly withpen thin_pen; draw q6; v0 := currentpicture; v1 := v0; p30 := (0, .5e); p31 := p30; a := 6.5; t0 := identity shifted (a, 0); for i = 1 upto 4: s := "{\large " & decimal i & "}"; label.rt(s, p31); label("{\large R}", p31 shifted (.75cm, 1.5cm)); label("{\large L}", p31 shifted (-.75cm, 1.5cm)); currentpicture += v1; v1 *= t0; p31 *= t0; endfor; %% Second row v1 := v0; p31 := p30; t1 := identity shifted (0, -19); v1 *= t1; p31 *= t1; for i = 5 upto 8: s := "{\large " & decimal i & "}"; label.rt(s, p31); label("{\large R}", p31 shifted (.75cm, 1.5cm)); label("{\large L}", p31 shifted (-.75cm, 1.5cm)); currentpicture += v1; v1 *= t0; p31 *= t0; endfor; endfig with_projection parallel_x_y no_sort; %% *** (3) %% *** (3) End of 3DLDF code verbatim_metapost "end;"; end; %% ** (2) %% * (1) Emacs-Lisp code for use in indirect buffers when using the %% GNU Emacs editor. The local variable list is not evaluated when an %% indirect buffer is visited, so it's necessary to evaluate the %% following s-expression in order to use the facilities normally %% accessed via the local variables list. %% \initials{LDF 2004.02.12}. %% (progn (metafont-mode) (outline-minor-mode t) (setq fill-column 80) (ignore '( %% )) (setq outline-regexp "%% [*\f]+")) %% * (1) Local variables for Emacs. %% Local Variables: %% mode:Metafont %% eval:(outline-minor-mode t) %% eval:(read-abbrev-file abbrev-file-name) %% outline-regexp:"%% [*\f]+" %% End: