summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/bezierplot
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-06-18 22:29:39 +0000
committerKarl Berry <karl@freefriends.org>2019-06-18 22:29:39 +0000
commitaf40071956ab22eae0d446cced49296afc407c1e (patch)
treedb15bb063d306b19a6b790cbd1f1212d8f9fce8d /Master/texmf-dist/tex/lualatex/bezierplot
parent691106177d00ff3ef1e88a1bbe1a914140c86d85 (diff)
bezierplot (18jun19)
git-svn-id: svn://tug.org/texlive/trunk@51398 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/bezierplot')
-rwxr-xr-xMaster/texmf-dist/tex/lualatex/bezierplot/bezierplot.lua46
-rw-r--r--Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.sty2
2 files changed, 33 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.lua b/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.lua
index af7dd887b85..382da2d74ea 100755
--- a/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.lua
+++ b/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.lua
@@ -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 @@ sqrt = math.sqrt
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 function diffgraph(func,graph,h)
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 @@ local function graphtobezierapprox(f,g,starti,endi,maxerror)
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 @@ local function graphtobezierapprox(f,g,starti,endi,maxerror)
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 @@ local function graphtobezier(g,starti,endi,isinverse)
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 @@ function bezierplot(functionstring,xminstring,xmaxstring,yminstring,ymaxstring,s
-- 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
diff --git a/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.sty b/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.sty
index 4584777e476..94be30b4dce 100644
--- a/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.sty
+++ b/Master/texmf-dist/tex/lualatex/bezierplot/bezierplot.sty
@@ -1,5 +1,5 @@
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{bezierplot}[2018/09/03 bezierplot]
+\ProvidesPackage{bezierplot}[2019/06/18 bezierplot]
\RequirePackage{xparse}
\RequirePackage{iftex}
\ifLuaTeX