Re: Il disegno programmato nell’Arte di scrivere con LaTeX

#72816
OldClaudio
Partecipante
    Up
    0
    Down
    ::


    Iterando sui numeri interi con questo codice:
    `
    % !TEX TS-program = LuaLaTeX

    \documentclass{standalone}

    \usepackage{pgfplots}
    \usepackage{luacode}

    \begin{luacode*}

    function Liss(val,t)
    return math.sin(val*t)
    end

    function stampa_pgf(a,b,s)

    tex.sprint(“\\addplot[mark=, red, smooth] coordinates{“)
    — 2pi_greco/500=0.0125663 — valore con 500 campioni
    — ansys suggerisce di usare per il calcolo di step la formula
    — step=string.format(“\%.50f”,2*math.pi/s)
    — step=2*math.pi/s
    step=string.format(“\%.50f”,2*math.pi/s)
    — for i=0,2*math.pi,step do
    for i=0,s,1 do
    u= i*step
    x=Liss(a,u)
    y=Liss(b,u)
    tex.sprint(“(“..x..”,”..y..”)”)
    end

    tex.sprint(“};”)
    end

    \end{luacode*}

    \newcommand\myaddplot[3]{\directlua{stampa_pgf(#1,#2,#3)}}

    \begin{document}
    \begin{tikzpicture}
    \begin{axis}
    \myaddplot{7}{2}{100}
    \end{axis}
    \end{tikzpicture}
    \end{document}

    %%% Local Variables:
    %%% mode: latex
    %%% TeX-engine: luatex
    %%% TeX-master: t
    %%% End:
    `
    che itera sui numeri interi la curva si chiude sempre. Con 30 campioni viene uno schifo; con 100 campioni è leggermente deformata, ma difficile da notarlo ad occhio nudo; con 200 campioni viene benissimo.

    Occupazione di memoria: dal file log con 100 campioni si legge
    `
    Here is how much of LuaTeX's memory you used:
    17683 strings out of 494981
    100000,552014 words of node,token memory allocated
    3419 words of node memory still in use:
    77 hlist, 1 vlist, 1 rule, 20 math, 310 glue, 22 glyph, 56 glue_spec, 1 writ
    e, 311 pdf_literal, 10 pdf_colorstack nodes
    avail lists: 1:1,2:34,3:313,4:362,5:1,6:30,7:1,9:83
    20513 multiletter control sequences out of 65536+200000
    25 fonts using 994935 bytes
    63i,10n,82p,653b,1495s stack positions out of 5000i,500n,10000p,200000b,50000s
    `

    Con 200 campioni si legge invece:
    `
    Here is how much of LuaTeX's memory you used:
    17715 strings out of 494981
    100000,662416 words of node,token memory allocated
    4119 words of node memory still in use:
    77 hlist, 1 vlist, 1 rule, 20 math, 410 glue, 22 glyph, 56 glue_spec, 1 writ
    e, 411 pdf_literal, 10 pdf_colorstack nodes
    avail lists: 1:1,2:34,3:413,4:462,5:1,6:30,7:1,9:83
    20545 multiletter control sequences out of 65536+200000
    25 fonts using 994935 bytes
    63i,10n,82p,653b,1495s stack positions out of 5000i,500n,10000p,200000b,50000s
    `

    A quanto pare sono aumentati di 100 unità soltanto i glue nodes. Ma non sono in grado di dire quanti ce ne fossero disponibili.

    Go to top