%% small_rhombi.lmc %% Created by Laurence D. Finston (LDF) Sun 03 Oct 2021 07:27:54 PM CEST %% * (1) Copyright and License. %%%% This file is part of GNU 3DLDF, a package for three-dimensional drawing. %%%% Copyright (C) 2021, 2022, 2023 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 % * (1) Beginning of 3DLDF code. %% ** (2) Global variables. numeric top_pos; numeric bot_pos; numeric lft_pos; numeric rt_pos; numeric ulft_pos; numeric urt_pos; numeric llft_pos; numeric lrt_pos; top_pos := 0; bot_pos := 1; lft_pos := 2; rt_pos := 3; ulft_pos := 4; urt_pos := 5; llft_pos := 6; lrt_pos := 7; string rt_str; string lft_str; string top_str; string bot_str; string urt_str; string lrt_str; string ulft_str; string llft_str; top_str := "\\thinspace t"; bot_str := "\\thinspace b"; rt_str := "\\thinspace r"; lft_str := "\\thinspace l"; urt_str := "\\thinspace ur"; ulft_str := "\\thinspace ul"; lrt_str := "\\thinspace lr"; llft_str := "\\thinspace ll"; %% ** (2) Macro tab macro tab; def tab {numeric pp, numeric qq, numeric offset, boolean ddo_labels, numeric width, numeric tab_path_ctr, boolean suppress_draw, numeric sewing_val, boolean inner_tab} = point P[]; numeric n; color tab_color; if inner_tab: tab_color := dark_gray; else: tab_color := black; fi; P0 := mediate(p[pp], p[qq], offset); P1 := mediate(p[qq], p[pp], offset); % if ddo_labels: % dotlabel.top("$P_0$", P0) with_text_color red; % dotlabel.top("$P_1$", P1) with_text_color red; % fi; P2 := P0 shifted (0, 1); P3 := (width * unit_vector(p[pp] - P0)) shifted by P0; rotate_around P3 (P0, P2) -112.5; P4 := (width * unit_vector(p[qq] - P1)) shifted by P1; P5 := P1 shifted (0, 1); rotate_around P4 (P1, P5) 112.5; % if ddo_labels: % dotlabel.top("$P_3$", P3) with_text_color red; % dotlabel.top("$P_4$", P4) with_text_color red; % fi; tab_path[tab_path_ctr] := P0 -- P3 -- P4 -- P1; if not suppress_draw: draw tab_path[tab_path_ctr] with_color tab_color; fi; P6 := mediate(mediate(P0, P1, .5), mediate(P3, P4, .5), .5); if ddo_labels: label(decimal tab_path_ctr, P6) with_text_color red; fi; P7 := mediate(P0, P3, .5); P8 := mediate(P1, P4, .5); if ddo_labels: dotlabel.lft("$P_7$", P7) with_text_color blue; dotlabel.rt("$P_8$", P8) with_text_color blue; fi; sewing_val += 1; n := 1 / sewing_val; forever: drawdot mediate(P7, P8, n) with_pen pencircle scaled (2pt, 2pt, 2pt) on_picture dot_picture[tab_path_ctr]; n += (1 / sewing_val); exitif n >= 1; endfor; current_picture += dot_picture[tab_path_ctr]; %message "Exiting tab."; enddef; %% ** (2) macro label_side macro label_side; def label_side {numeric pp, numeric qq, numeric nnumber, string s, boolean rrotate, boolean ddo_labels, numeric position} = message "Entering `label_side'."; point P[]; numeric ang[]; P0 := p[pp]; P1 := p[qq]; P3 := mediate(P0, P1); P4 := P0 shifted (1, 0); ang0 := (P1 - P0) angle (P4 - P0); if rrotate: ang0 *= -1; fi; message "ang0:"; show ang0; if position == top_pos: label.top(decimal nnumber & s, P3) rotated (0, 0, ang0) on_picture v1; elseif position == bot_pos: label.bot(decimal nnumber & s, P3) rotated (0, 0, ang0) on_picture v1; elseif position == lft_pos: label.lft(decimal nnumber & s, P3) rotated (0, 0, ang0) on_picture v1; elseif position == rt_pos: label.rt(decimal nnumber & s, P3) rotated (0, 0, ang0) on_picture v1; elseif position == ulft_pos: label.ulft(decimal nnumber & s, P3) rotated (0, 0, ang0) on_picture v1; elseif position == urt_pos: label.urt(decimal nnumber & s, P3) rotated (0, 0, ang0) on_picture v1; elseif position == llft_pos: label.llft(decimal nnumber & s, P3) rotated (0, 0, ang0) on_picture v1; elseif position == lrt_pos: label.lrt(decimal nnumber & s, P3) rotated (0, 0, ang0) on_picture v1; fi; message "Exiting `label_side'."; enddef; %% ** (2) endinput; %% ** (2) End of 3DLDF code. %% * (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 (metapost-mode) (outline-minor-mode t) (setq fill-column 80) (setq outline-regexp "%% [*\f]+")) %% * (1) Local variables for Emacs. %% Local Variables: %% mode:Metapost %% eval:(outline-minor-mode t) %% eval:(read-abbrev-file abbrev-file-name) %% abbrev-mode:t %% outline-regexp:"%% [*\f]+" %% End: