texlive[51398] Master/texmf-dist: bezierplot (18jun19)
commits+karl at tug.org
commits+karl at tug.org
Wed Jun 19 00:29:39 CEST 2019
Revision: 51398
http://tug.org/svn/texlive?view=revision&revision=51398
Author: karl
Date: 2019-06-19 00:29:39 +0200 (Wed, 19 Jun 2019)
Log Message:
-----------
bezierplot (18jun19)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/lualatex/bezierplot/README
trunk/Master/texmf-dist/doc/lualatex/bezierplot/bezierplot-doc.pdf
trunk/Master/texmf-dist/doc/lualatex/bezierplot/bezierplot-doc.tex
trunk/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.lua
trunk/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.sty
Modified: trunk/Master/texmf-dist/doc/lualatex/bezierplot/README
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/bezierplot/README 2019-06-18 22:29:20 UTC (rev 51397)
+++ trunk/Master/texmf-dist/doc/lualatex/bezierplot/README 2019-06-18 22:29:39 UTC (rev 51398)
@@ -8,7 +8,7 @@
number of used points.
VERSION:
-1.3 2018-09-03
+1.4 2019-06-18
LICENSE:
The package and the program are distributed on CTAN under the terms of
Modified: trunk/Master/texmf-dist/doc/lualatex/bezierplot/bezierplot-doc.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/lualatex/bezierplot/bezierplot-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/bezierplot/bezierplot-doc.tex 2019-06-18 22:29:20 UTC (rev 51397)
+++ trunk/Master/texmf-dist/doc/lualatex/bezierplot/bezierplot-doc.tex 2019-06-18 22:29:39 UTC (rev 51398)
@@ -23,7 +23,7 @@
\section{Introduction}
\texttt{bezierplot} is a Lua program as well as a (Lua)\LaTeX{} package. This document describes both.
-Given a smooth function, \texttt{bezierplot} returns a smooth bezier path written in Ti\emph{k}Z notation (which also matches \MP{}) that approximates the graph of the function. For polynomial functions of degree $\leq 3$ and inverses of them, the approximation is exact. \texttt{bezierplot} finds special graph points such as extreme points and inflection points and reduces the number of used points.
+Given a smooth function, \texttt{bezierplot} returns a smooth bezier path written in Ti\emph{k}Z notation (which also matches \MP{}) that approximates the graph of the function. For polynomial functions of degree $\leq 3$ and inverses of them, the approximation is exact (up to numeric precision). \texttt{bezierplot} finds special graph points such as extreme points and inflection points and reduces the number of used points.
The following example will show a comparison of \textsc{gnuplot} with \verb|bezierplot| for the function $y=\sqrt{x}$ for $0\leq x \leq 5$:
\begin{center}
@@ -39,7 +39,7 @@
\end{scope}
\end{tikzpicture}
\end{center}
-\textsc{gnuplot} used 51 samples (no smoothing) and is still quite inexact at the beginning, whereas \verb|bezierplot| uses 4 points only and is exact!
+\textsc{gnuplot} used 51 samples (no smoothing) and is still quite inexact at the beginning, whereas \verb|bezierplot| uses 4 points only and is exact (up to numeric precision)!
\section{Installation}
As \texttt{bezierplot} is written in Lua, the installation depends whether you are using Lua\LaTeX{} or another \LaTeX{} engine.
\subsection{Installation For Lua\LaTeX{}}
@@ -179,7 +179,7 @@
\newpage
%
\section{Examples of \texttt{bezierplot} in Comparison with \textsc{gnuplot}}
-The following graphs are drawn with \texttt{bezierplot} (black) and \textsc{gnuplot} (red). \textsc{gnuplot} used 1000 samples per example. The functions are given below the pictures (left: bezierplot, right: \textsc{gnuplot}).
+The following graphs are drawn with \texttt{bezierplot} (black) and \textsc{gnuplot} (red). You may not recognize the red behind the black unless you zoom in. \textsc{gnuplot} used 1000 samples per example. The functions are given below the pictures (left: bezierplot, right: \textsc{gnuplot}).
\begin{multicols}{3}
\graphcomparison{0.32*x-0.7}{0.32*x-0.7}
\graphcomparison{-x^2+4}{-x**2+4}
Modified: trunk/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.lua 2019-06-18 22:29:20 UTC (rev 51397)
+++ trunk/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.lua 2019-06-18 22:29:39 UTC (rev 51398)
@@ -1,6 +1,6 @@
#!/usr/bin/env lua
-- Linus Romer, published 2018 under LPPL Version 1.3c
--- version 1.3 2018-09-03
+-- version 1.4 2019-06-18
abs = math.abs
acos = math.acos
asin = math.asin
@@ -15,6 +15,24 @@
tan = math.tan
huge = math.huge
+-- just a helper for debugging:
+local function printdifftable(t)
+ for i = 1,#t do
+ for j = 1, 6 do
+ if j < 5 then
+ io.write(t[i][j].." ")
+ else
+ if t[i][j] then
+ io.write("true ")
+ else
+ io.write("false ")
+ end
+ end
+ end
+ io.write("\n")
+ end
+end
+
-- cube root defined for all real numbers x
function cbrt(x)
if x < 0 then
@@ -66,7 +84,7 @@
local l = #graph
if l < 4 then -- this is not worth the pain...
for i = 1, l do
- table.insert(dgraph,{graph[i][1],graph[i][2],0,0,0,0})
+ table.insert(dgraph,{graph[i][1],graph[i][2],0,0,false,false})
end
else
local yh = func(graph[1][1]-h)
@@ -540,7 +558,12 @@
err = abs(ya-f(xa))
end
end
- if err <= maxerror then
+ if (err <= maxerror)
+ and qx > -math.huge and qx < math.huge
+ and qy > -math.huge and qy < math.huge
+ and rx > -math.huge and ry < math.huge
+ and sx > -math.huge and sy < math.huge
+ then
return {qx,qy,rx,ry,sx,sy}
else
-- search for an intermediate point where the graph has the same
@@ -561,7 +584,11 @@
end
return left
end
- else
+ elseif qx > -math.huge and qx < math.huge
+ and qy > -math.huge and qy < math.huge
+ and rx > -math.huge and ry < math.huge
+ and sx > -math.huge and sy < math.huge
+ then
return {qx,qy,rx,ry,sx,sy}
end
end
@@ -586,16 +613,6 @@
end
end
--- just for debugging:
-local function printtable(t)
- for i = 1,#t do
- for j = 1, #t[i] do
- io.write(t[i][j].." ")
- end
- io.write("\n")
- end
-end
-
-- main function
function bezierplot(functionstring,xminstring,xmaxstring,yminstring,ymaxstring,samplesstring,notation)
local fstringreplaced = string.gsub(functionstring, "%*%*", "^")
@@ -840,6 +857,7 @@
-- go through the connected parts
for part = 1, #graphs do
local dg = diffgraph(f,graphs[part],xstep)
+ --printdifftable(dg) -- for debugging
bezierpoints[#bezierpoints+1] = {dg[1][1],dg[1][2]}
local startindex = 1
for k = 2, #dg do
Modified: trunk/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.sty 2019-06-18 22:29:20 UTC (rev 51397)
+++ trunk/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.sty 2019-06-18 22:29:39 UTC (rev 51398)
@@ -1,5 +1,5 @@
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{bezierplot}[2018/09/03 bezierplot]
+\ProvidesPackage{bezierplot}[2019/06/18 bezierplot]
\RequirePackage{xparse}
\RequirePackage{iftex}
\ifLuaTeX
More information about the tex-live-commits
mailing list