summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-02-08 21:49:28 +0000
committerKarl Berry <karl@freefriends.org>2022-02-08 21:49:28 +0000
commit96b309b802f1939ddecf941f967c15e14324c79e (patch)
tree3bca6bcd3a3e7ccc370631ab7530c4a912ceb445 /Master/texmf-dist/doc/metapost
parenta0246f016e4c9cb618d2a954d6d250a3bc150af2 (diff)
fiziko (8feb22)
git-svn-id: svn://tug.org/texlive/trunk@61944 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/metapost')
-rw-r--r--Master/texmf-dist/doc/metapost/fiziko/README2
-rw-r--r--Master/texmf-dist/doc/metapost/fiziko/fiziko.pdfbin4559755 -> 5338496 bytes
-rw-r--r--Master/texmf-dist/doc/metapost/fiziko/fiziko.tex113
3 files changed, 87 insertions, 28 deletions
diff --git a/Master/texmf-dist/doc/metapost/fiziko/README b/Master/texmf-dist/doc/metapost/fiziko/README
index 8eda66ae7ed..5b7e9ada0eb 100644
--- a/Master/texmf-dist/doc/metapost/fiziko/README
+++ b/Master/texmf-dist/doc/metapost/fiziko/README
@@ -1,5 +1,5 @@
Name: fiziko
-Version: 0.1.3
+Version: 0.2.0
License: GNU GPLv3 or later
Author: Sergey Slyusarev
Repository: https://github.com/jemmybutton/fiziko
diff --git a/Master/texmf-dist/doc/metapost/fiziko/fiziko.pdf b/Master/texmf-dist/doc/metapost/fiziko/fiziko.pdf
index aaf3cfff423..32b5300d220 100644
--- a/Master/texmf-dist/doc/metapost/fiziko/fiziko.pdf
+++ b/Master/texmf-dist/doc/metapost/fiziko/fiziko.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/metapost/fiziko/fiziko.tex b/Master/texmf-dist/doc/metapost/fiziko/fiziko.tex
index 48480550031..3e164278da8 100644
--- a/Master/texmf-dist/doc/metapost/fiziko/fiziko.tex
+++ b/Master/texmf-dist/doc/metapost/fiziko/fiziko.tex
@@ -1,10 +1,9 @@
-\documentclass{article}
+\documentclass{ltxdoc}
-\usepackage{luamplib}
+\usepackage{luamplib, listings, bxtexlogo, ccicons}
\everymplib{verbatimtex \leavevmode etex; input fiziko.mp; beginfig(1);}
\everyendmplib{endfig;}
-\usepackage{listings}
\lstset{
language=MetaPost,
numbers=left,
@@ -12,33 +11,31 @@ numberstyle=\tiny,
basicstyle=\scriptsize
}
-\usepackage{cclicenses}
-
\author{Sergey Slyusarev}
-\title{``fiziko'' v. 0.1.3 package for MetaPost}
+\title{``fiziko'' v. 0.2.0 package for \METAPOST}
\begin{document}
\maketitle
\begin{abstract}
-This document describes a bunch of macros provided by ``fiziko'' library for MetaPost.
+This document describes a bunch of macros provided by ``fiziko'' library for \METAPOST.
\end{abstract}
\begin{centering}
This document is distributed under CC-BY-SA 4.0 license
-\cc\bysa
+\ccbysa
https://github.com/jemmybutton/fiziko
\end{centering}
\section{Introduction}
-This MetaPost library was initially written to automate some elements of black and white illustrations for a physics textbook. First and foremost it provides functions to draw things like lines of variable width, shaded spheres and tubes of different kinds, which can be used to produce images of a variety of objects. The library also contains functions to draw some objects constructed from these primitives.
+This \METAPOST\ library was initially written to automate some elements of black and white illustrations for a physics textbook. First and foremost it provides functions to draw things like lines of variable width, shaded spheres and tubes of different kinds, which can be used to produce images of a variety of objects. The library also contains functions to draw some objects constructed from these primitives.
\section{Usage}
-Simply include this in the beginning of your MetaPost document:
+Simply include this in the beginning of your \METAPOST\ document:
\begin{lstlisting}
input fiziko.mp
@@ -113,19 +110,34 @@ This macro returns a \texttt{picture} of a sphere with specified diameter shaded
endfor;
\end{mplibcode}
-\subsection{sphere.l (\emph{diameter, angle})}
+\subsection{sphere.s (\emph{diameter})}
+This macro returns a \texttt{picture} of a sphere with specified diameter shaded with stipples.
+
+\begin{lstlisting}
+ for i := 1 step 1 until 6:
+ draw sphere.s(i*1/4cm) shifted (1/2cm*(i*(i+1))/2, 0);
+ endfor;
+\end{lstlisting}
+
+\begin{mplibcode}
+ for i := 1 step 1 until 6:
+ draw sphere.s(i*1/4cm) shifted (1/2cm*(i*(i+1))/2, 0);
+ endfor;
+\end{mplibcode}
+
+\subsection{sphereLat (\emph{diameter, angle})}
This macro returns a \texttt{picture} of a shaded sphere with specified diameter. Unlike \texttt{sphere.c} macro, this one draws latitudinal strokes around axis rotated at specified \texttt{angle}.
\begin{lstlisting}
for i := 1 step 1 until 6:
- draw sphere.l(i*1/4cm, -90 + i*30)
+ draw sphereLat(i*1/4cm, -90 + i*30)
shifted (1/2cm*(i*(i+1))/2, 0);
endfor;
\end{lstlisting}
\begin{mplibcode}
for i := 1 step 1 until 6:
- draw sphere.l(i*1/4cm, -90 + i*30)
+ draw sphereLat(i*1/4cm, -90 + i*30)
shifted (1/2cm*(i*(i+1))/2, 0);
endfor;
\end{mplibcode}
@@ -160,6 +172,21 @@ This macro returns a \texttt{picture} of a shaded ``tube'' of variable width alo
draw tube.t (p)(1/2cm*sin(offsetPathLength*pi));
\end{mplibcode}
+\subsection{tube.s (\emph{path})(\emph{offset function})}
+This macro returns a \texttt{picture} of a shaded ``tube'' of variable width along given path, which is controlled by some arbitrary function, analogous to \texttt{offsetPath}. ``Tube'' drawn by this macro is shaded with stipples. Once tube is generated, you can call \texttt{tubeOutline} path global variable, if you need one.
+
+\begin{lstlisting}
+ path p;
+ p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
+ draw tube.s (p)(1/2cm*sin(offsetPathLength*pi));
+\end{lstlisting}
+
+\begin{mplibcode}
+ path p;
+ p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
+ draw tube.s (p)(1/2cm*sin(offsetPathLength*pi));
+\end{mplibcode}
+
\subsection{tube.e (\emph{path})(\emph{offset function})}
This macro returns the outline of a tube as a path.
@@ -200,7 +227,7 @@ This macro returns a \texttt{picture} of a pulley with specified \texttt{diamete
endfor;
\end{lstlisting}
-\begin{mplibcode}
+\noindent\begin{mplibcode}
draw (-1/8cm, 0)--(12cm, 0);
for i := 1 step 1 until 6:
r := 1/7cm*i;
@@ -248,7 +275,8 @@ This macro returns a \texttt{picture} of a wheel with specified \texttt{diameter
endfor;
\end{lstlisting}
-\begin{mplibcode}
+
+\noindent\begin{mplibcode}
draw (-1/8cm, 0)--(12cm, 0);
for i := 1 step 1 until 6:
r := 1/7cm*i;
@@ -267,7 +295,7 @@ This macro returns a \texttt{picture} of a weight of a specific \texttt{height}
draw (-1/8cm, 0)--(12cm, 0);
\end{lstlisting}
-\begin{mplibcode}
+\noindent\begin{mplibcode}
for i := 1 step 1 until 6:
draw weight.s(1/4cm + i*1/4cm) shifted (1/2cm*(i*(i+1))/2, 0);
endfor;
@@ -284,7 +312,7 @@ This macro returns a \texttt{picture} of a weight of a specific \texttt{height}
draw (12cm, 0)--(-1/8cm, 0);
\end{lstlisting}
-\begin{mplibcode}
+\noindent\begin{mplibcode}
for i := 1 step 1 until 6:
draw weight.h(1/4cm + i*1/4cm) shifted (1/2cm*(i*(i+1))/2, 0);
endfor;
@@ -333,6 +361,22 @@ This macro returns a \texttt{picture} of a solid surface on the right side of a
\subsection{solid (\emph{path, angle, type})}
Fills given \texttt{path} with strokes of specific type at a given \texttt{angle}. \texttt{type} can be 0 (``solid'' strokes) and 1 (``glass'' strokes).
+\begin{lstlisting}
+ path p[];
+ p1 := unitsquare scaled 2cm;
+ p2 := p1 shifted (4cm, 0);
+ draw solid(p1, 45, 0);
+ draw solid(p2, -45, 1);
+\end{lstlisting}
+
+\begin{mplibcode}
+ path p[];
+ p1 := unitsquare scaled 2cm;
+ p2 := p1 shifted (4cm, 0);
+ draw solid(p1, 45, 0);
+ draw solid(p2, -45, 1);
+\end{mplibcode}
+
\subsection{woodBlock (\emph{width, height})}
Returns a \texttt{picture} of a rectangular block of wood with its bottom-left corner in the origin.
@@ -383,7 +427,7 @@ This macro returns a \texttt{picture} of the globe of specified \texttt{radius}
\end{mplibcode}
\subsection{Knots}
-There are two macros to handle knot drawing: \texttt{addStrandToKnot} and \texttt{knotFromStrands}. Currently the algorithm is not especially stable.
+There are two macros to handle knot drawing: \texttt{addStrandToKnot} and \texttt{knot\-From\-Strands}. Currently the algorithm is not especially stable.
\subsubsection{addStrandToKnot (\emph{knotName}) (\emph{path, ropeWidth, ropeType, intersectionOrder})}
This macro adds a strand to knot named \texttt{knotName} and returns nothing. Strand follows the given \texttt{path} and has a given \texttt{ropeWidth}. \texttt{ropeType} can be \texttt{"l"}, \texttt{"t"} (as in \texttt{tube.l} and \texttt{tube.t}) or \texttt{"e"} (for an unshaded strand). \texttt{intersectionOrder} is a string of comma separated numbers which represent a ``layer'' to which intersections along the strand go.
@@ -401,15 +445,15 @@ This macro returns a picture of a knot with a given \texttt{knotName}.
p3 := (fullcircle scaled 4cm);
addStrandToKnot (theknot) (p1 shifted (4cm, -4cm), 1/5cm, "l",
"-1,1,-1,1,-1,1,-1,1,-1");
- addStrandToKnot (theknot) (p2 shifted (4cm, -4cm), 1/6cm, "l",
+ addStrandToKnot (theknot) (p2 shifted (4cm, -4cm), 1/6cm, "s",
"");
- addStrandToKnot (theknot) (p3 shifted (4cm, -4cm), 1/7cm, "l",
+ addStrandToKnot (theknot) (p3 shifted (4cm, -4cm), 1/7cm, "e",
"-1,1");
draw knotFromStrands (theknot);
\end{lstlisting}
\begin{mplibcode}
- path p[]; path p[];
+ path p[];
p1 := (dir(90)*4/3cm) {dir(0)} .. tension 3/2
.. (dir(90 + 120)*4/3cm){dir(90 + 30)} .. tension 3/2
.. (dir(90 - 120)*4/3cm){dir(-90 - 30)} .. tension 3/2
@@ -418,13 +462,28 @@ This macro returns a picture of a knot with a given \texttt{knotName}.
p3 := (fullcircle scaled 4cm);
addStrandToKnot (theknot) (p1 shifted (4cm, -4cm), 1/5cm, "l",
"-1,1,-1,1,-1,1,-1,1,-1");
- addStrandToKnot (theknot) (p2 shifted (4cm, -4cm), 1/6cm, "l",
+ addStrandToKnot (theknot) (p2 shifted (4cm, -4cm), 1/6cm, "s",
"");
- addStrandToKnot (theknot) (p3 shifted (4cm, -4cm), 1/7cm, "l",
+ addStrandToKnot (theknot) (p3 shifted (4cm, -4cm), 1/7cm, "e",
"-1,1");
draw knotFromStrands (theknot);
\end{mplibcode}
+\subsection{Other 3D contraptions}
+Some macros can be used to shade 3D polygons. Currently only flat surfaces re supported
+
+\subsubsection{flatSurface\emph{\#@}(\emph{surface outline path, normal vector, hatch angle})}
+This macro returns a \texttt{picture} of a flat surface with the specified \texttt{surface outline path} with the given \texttt{normal vector}, illuminated from the direction determined by \texttt{lightDirection} and with hatches aligned at the andle \texttt{hatch angle}. If \texttt{\#@} is \texttt{".hatches"} then the surface is shaded with hatches, if it's \texttt{".stipples"}, then the surface is shaded with stipples.
+
+\begin{mplibcode}
+ path p[];
+ p1 := unitsquare xscaled 1cm yscaled 2cm;
+ p2 := p1 shifted (1cm, 0);
+ draw flatSurface.hatches(p1, (-1,0,1), 45);
+ draw flatSurface.hatches(p2, (1,0,1), 45);
+draw p1; draw p2;
+\end{mplibcode}
+
\section{Other macros}
Some macros that are not directly related to drawing are listed below
@@ -473,10 +532,10 @@ This macro returns a \texttt{path} that represent a section of a lens with given
Some macros that not related to physical problems at all are listed below.
\subsection{\emph{picture} maskedWith \emph{path}}
-This macro masks a part of a \texttt{picture} with closed \texttt{path}. In fact this is inversion of metapost's built-in \texttt{clip} but, in contrast to the latter, it does not modify original image. Note that it requires that counter-clockwise \texttt{path} to work properly.
+This macro masks a part of a \texttt{picture} with closed \texttt{path}. In fact this is inversion of \METAPOST's built-in \texttt{clip} but, in contrast to the latter, it does not modify original image. Note that it requires that counter-clockwise \texttt{path} to work properly.
\subsection{\emph{path} firstIntersectionTimes \emph{path}}
-This macro is similar to metapost's \texttt{intersectiontimes} but it returns intersection times with smallest time on first path.
+This macro is similar to \METAPOST's \texttt{intersectiontimes} but it returns intersection times with smallest time on first path.
\subsection{pathSubdivide \emph{path, n}}
This macro returns original \texttt{path} with \texttt{n}-times more points.
@@ -824,7 +883,7 @@ Line 3 describe initial setup. Line 4 is problem's solution. Lines 8--11 set all
.. (-4/3cm, 0) .. (-1/2cm, -2/3cm) .. (1/2cm, 0)
.. (-1/2cm, 3/2cm) .. cycle;
p2 := p2 scaled 6/5;
- addStrandToKnot (primeTwo) (p2, 1/4cm, "l", "1, -1, 1, -1, 1");
+ addStrandToKnot (primeTwo) (p2, 1/4cm, "s", "1, -1, 1, -1, 1");
draw knotFromStrands (primeTwo) shifted (4cm, -2cm);
p3 := (dir(0)*3/2cm) .. (dir(1*72)*2/3cm)
.. (dir(2*72)*3/2cm) .. (dir(3*72)*2/3cm)
@@ -833,7 +892,7 @@ Line 3 describe initial setup. Line 4 is problem's solution. Lines 8--11 set all
.. (dir(3*72)*3/2cm) .. (dir(4*72)*2/3cm)
.. cycle;
p3 := (p3 rotated (72/4)) scaled 6/5;
- addStrandToKnot (primeThree) (p3, 1/4cm, "l", "-1, 1, -1, 1, -1");
+ addStrandToKnot (primeThree) (p3, 1/4cm, "e", "-1, 1, -1, 1, -1");
draw knotFromStrands (primeThree) shifted (8cm, 0);
\end{mplibcode}