<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%%
%% This is file `interactiveplot.sty',
%% Copyright (C) 2014 by Roberto Bock, Javier Toro, Pedro Linares
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.2 of this license or (at your option) any later
%% version. The latest version of this license is in:
%% http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of
%% LaTeX version 1999/12/01 or later.
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{interactiveplot}
 [ 2014/09/20 v1.2]
\RequirePackage{datetime}
\RequirePackage{xstring}
\RequirePackage{stack}
\RequirePackage{ifthen}
\RequirePackage{forloop}
\RequirePackage{calc}
\RequirePackage{etoolbox}
\ifdef{\StrCut}{}
{%
\long\def\@xs@ifempty#1{%
\expandafter\ifx\expandafter\relax\detokenize{#1}\relax
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\@xs@newmacro*3\StrCut{1}{2}{0}{%
\@xs@ifempty{#3}%
{\global\let\groupID\@empty
\let\@xs@reserved@C\@empty
\let\@xs@reserved@E\@empty
}
{\ifnum#1&lt;\@ne\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
{\@xs@StrCut@ii{#2}{#3}1}
{\@xs@StrCut@ii{#2}{#3}{#1}}%
}%
\@xs@StrCut@iii
}
\long\def\@xs@StrCut@ii#1#2#3{%
\def\@xs@reserved@D{#1}%
\let\@xs@reserved@C\@empty
\def\@xs@reserved@E{#2}%
\decimalpart\z@\integerpart\z@
\gdef\groupID{0}%
\let\@xs@nestlevel\z@
\def\@xs@atendofgroup{%
\expandafter\endgroup
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}%
\@xs@read@reserved@D
}%
\def\@xs@atoccurfound{%
\ifnum\decimalpart=\numexpr(#3)\relax
\global\let\@xs@reserved@D\@xs@reserved@D
\global\let\@xs@reserved@C\@xs@reserved@C
\@xs@exitallgroups
\let\@xs@next\relax
\else
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@E}%
\let\@xs@next\@xs@read@reserved@D
\fi
}%
\@xs@read@reserved@D
\def\@xs@argument@A{#2}%
\let\@xs@reserved@E\@xs@reserved@D
\expandafter\expandafter\expandafter
\def
\expandafter\expandafter\expandafter
\@xs@reserved@D
\expandafter\expandafter\expandafter
{\expandafter\@xs@reserved@C\@xs@argument@A}%
}

\long\def\@xs@StrCut@iii#1#2{\let#1\@xs@reserved@C\let#2\@xs@reserved@E}
}
%% This macro includes an object inside a PDF
\newcommand{\interactiveplot@insertobj}[2]{
\immediate\pdfobj{#2}%
\expandafter\edef
\csname #1\endcsname
{\the\pdflastobj}
}
%% This macro makes a reference to an object by its name
\newcommand{\interactiveplot@oref}[1]{
\csname #1\endcsname\space 0 R
}
%% this macro define a Button, this button is used to
\newcommand{\interactiveplot@plotbuttoncaption}[2]{
\newdimen\textw
\newdimen\texth
\settowidth{\textw}{#2}
\settoheight{\texth}{#2}
\hbox{\pdfstartlink width \textw height \texth  user{ %% pdfstartlink defines an annotation
/Subtype /Widget /FT /Btn /F  2 %%this line defines the annotation of type Widget, /FT means the kind of widget is /Btn (i.e pushButton), /F is especially important because it defines that this annotation is hidden
/Ff 65537 /T (Button#1)%% /Ff defienes the type of button this property means that button is non-interactive, /T defines its tittle
/BS &lt;&lt; /W 0 /S /S &gt;&gt; %% /BS is a dictionary that defines the border Style of this annotation, /W defines the border width in points, /S defines the border Style and the subsecuent /S means solid i.e the border Style is Solid
/MK &lt;&lt; /BG [1] /CA (#2)  &gt;&gt; %% /MK defines a appareance characteristics, /BG defines the widget background, and /CA defines the caption text of the button
/H  /P  %% /H is the annotation Higlighting mode, the visual effect to be used when the mouse button is pressed, /P in this case the value of /H is /P that the means the Hightlighting visual effect aspect is like a down push button appareance
}\hfil\strut\pdfendlink}\vskip-\baselineskip}
%% This macro defines a button, this button is not interactive for the user, it display a button without background but it has caption and shows to user the function that is plotted
\newcommand{\interactiveplot@functionbutton}[2]{
\newdimen\textw
\newdimen\texth
\settowidth{\textw}{#2}
\settoheight{\texth}{#2}
\hbox{\pdfstartlink width \textw height \texth  user{
/Subtype /Widget /FT /Btn /F  2
/Ff 65537 /T (buttonFunctionCaption#1)
/BS &lt;&lt; /W 0 /S /S &gt;&gt;
/MK &lt;&lt; /BG [1] /CA (#2)  &gt;&gt;
/H  /P
}\hfil\strut\pdfendlink}\vskip-\baselineskip}
%% This macro insert in a PDF an annotation of kind textfield in where the actual value of a parameter is shown
\newcommand{\interactiveplot@fieldparamvalue}[1]{
\newdimen\textw
\newdimen\texth
\settowidth{\textw}{#1}
\settoheight{\texth}{#1}
\hbox{\pdfstartlink width \textw height \texth  user{
/Subtype /Widget /FT /Tx
/T (Field#1)
/BS &lt;&lt; /W 1 /S /B &gt;&gt;%% /W 1 defines the border width in 1, and /S  /B defines the border line in Beveled
/MK &lt;&lt; /BG [1]  &gt;&gt;
/H  /P
}\hfil\strut\pdfendlink}\vskip -\baselineskip}
%% This macro insert in a PDF a button with predefined caption in "-" or "+"
\newcommand{\interactiveplot@plotbutton}[2]{
\ifthenelse{\equal{#2}{minus}}{\xdef\simbolaction{-}}{\xdef\simbolaction{+}}
\hbox to .5cm{\pdfstartlink height 10pt user{
/Subtype /Widget /FT /Btn /F  2
/Ff 65536 /T (Button#1#2)
/BS &lt;&lt; /W 1 /S /B &gt;&gt;
/MK &lt;&lt; /BG [0.8] /CA (\simbolaction) &gt;&gt;
/H  /P
}\hfil\strut\pdfendlink}\vskip-\baselineskip}
%%This macro insert in a PDF a Button, this button is used to be upside all other annotations (axis, graphic, etc) and get all the clicks envenoms on it prevent the other annotations get the events on their
\newcommand{\interactiveplot@square}[1]{
\hbox to 1cm{\pdfstartlink user{
/Subtype /Widget /FT /Btn %/F  6
/Ff 65537 /T (squareUbication#1)
/BS  &lt;&lt; /W 0 /S /B  &gt;&gt;
/MK  &lt;&lt; /BG  [1]  /CA  () &gt;&gt;
/H  /N
}\hfil\strut\pdfendlink }
\hbox {\pdfstartlink user{
/Subtype /Widget /FT /Btn %/F 6
/Ff 65537 /T (square#1)
/BS  &lt;&lt; /W 0 /S /B  &gt;&gt;
/MK  &lt;&lt; /BG  [1]  /CA  () &gt;&gt;
/H  /N
}\hfil\strut\pdfendlink }
}
%%this macro inserts in a PDF the AcroForm object who allows us use interactive properties of PDF
\interactiveplot@insertobj{Helv}{
&lt;&lt; /Type /Font /Subtype /Type1
/Name /Helv
/BaseFont /Helvetica &gt;&gt; }
\interactiveplot@insertobj{AcroForm}{
&lt;&lt; /DR &lt;&lt; /Font &lt;&lt;
/Helv \interactiveplot@oref{Helv} &gt;&gt; &gt;&gt;
/DA (/Helv 9 Tf 0 g )
/NeedAppearances true &gt;&gt; }
\pdfcatalog{/AcroForm \interactiveplot@oref{AcroForm}}


%%the counters are initialized, in this package all the functions are managed by index

\newcount\interactiveplot@functions\interactiveplot@functions=0
\newlength{\interactiveplot@CompletenaturalIplotHeight}
\xdef\interactiveplot@ecuationJS{}%In this macro is stored all the javascript code builded in all the procces of do an interactive plot
\xdef\interactiveplot@buttonsmanage{}%In this macro are stored all the Buttons Data (the buttons who change the parameters values)
\def\interactiveplot@isOperator#1[#2]{%This macro compare if an input is an operator
\xdef\interactiveplot@val{#1}
\ifthenelse{\equal{\interactiveplot@val}{+}\OR\equal{\interactiveplot@val}{(}\OR\equal{\interactiveplot@val}{)}\OR\equal{\interactiveplot@val}{/}\OR\equal{\interactiveplot@val}{\string^}\OR\equal{\interactiveplot@val}{*}\OR\equal{\interactiveplot@val}{-}\OR\equal{\interactiveplot@val}{ sin}\OR\equal{\interactiveplot@val}{ cos}\OR\equal{\interactiveplot@val}{ tan}\OR\equal{\interactiveplot@val}{ sec}\OR\equal{\interactiveplot@val}{ csc}\OR\equal{\interactiveplot@val}{ cot}\OR\equal{\interactiveplot@val}{ asin}\OR\equal{\interactiveplot@val}{ acos}\OR\equal{\interactiveplot@val}{ atan}\OR\equal{\interactiveplot@val}{ asec}\OR\equal{\interactiveplot@val}{ acsc}\OR\equal{\interactiveplot@val}{ acot}\OR\equal{\interactiveplot@val}{ sinh}\OR\equal{\interactiveplot@val}{ cosh}\OR\equal{\interactiveplot@val}{ tanh}\OR\equal{\interactiveplot@val}{ sech}\OR\equal{\interactiveplot@val}{ csch}\OR\equal{\interactiveplot@val}{ coth}\OR\equal{\interactiveplot@val}{ asinh}\OR\equal{\interactiveplot@val}{ acosh}\OR\equal{\interactiveplot@val}{ atanh}\OR\equal{\interactiveplot@val}{ asech}\OR\equal{\interactiveplot@val}{ acsch}\OR\equal{\interactiveplot@val}{ acoth}\OR\equal{\interactiveplot@val}{ ln}\OR\equal{\interactiveplot@val}{ exp}\OR\equal{\interactiveplot@val}{ log}}
{
\expandafter\xdef\csname #2\endcsname{1}
}{
\expandafter\xdef\csname #2\endcsname{0}
}
}
%%this macro validate the precedences of the operators, i.e. when you write 2+2*8 it will do 2*8 first and them (2*8)+2 that is 18, the operator * is first and precedes the operator +
%%Now precedence in stack is used because when you are using stacks to parse the function the precedence will be a little bit different than if an operator is out of the stack
\def\interactiveplot@PrecedenceInStack#1[#2]{
\xdef\interactiveplot@out{0}
\xdef\interactiveplot@val{#1}
\ifthenelse{\equal{\interactiveplot@val}{(}\OR\equal{\interactiveplot@val}{)}}{
\xdef\interactiveplot@out{0}
}{}
\ifthenelse{\equal{\interactiveplot@val}{*}\OR\equal{\interactiveplot@val}{/}}{
\xdef\interactiveplot@out{2}
}{}
\ifthenelse{\equal{\interactiveplot@val}{\string^}\OR\equal{\interactiveplot@val}{ sqrt}}{
\xdef\interactiveplot@out{3}
}{}
\ifthenelse{\equal{\interactiveplot@val}{+}\OR\equal{\interactiveplot@val}{-}}{
\xdef\interactiveplot@out{1}
}{}
\ifthenelse{\equal{\interactiveplot@val}{ sin}\OR\equal{\interactiveplot@val}{ cos}\OR\equal{\interactiveplot@val}{ tan}\OR\equal{\interactiveplot@val}{ sec}\OR\equal{\interactiveplot@val}{ csc}\OR\equal{\interactiveplot@val}{ cot}\OR\equal{\interactiveplot@val}{ asin}\OR\equal{\interactiveplot@val}{ acos}\OR\equal{\interactiveplot@val}{ atan}\OR\equal{\interactiveplot@val}{ asec}\OR\equal{\interactiveplot@val}{ acsc}\OR\equal{\interactiveplot@val}{ acot}\OR\equal{\interactiveplot@val}{ sinh}\OR\equal{\interactiveplot@val}{ cosh}\OR\equal{\interactiveplot@val}{ tanh}\OR\equal{\interactiveplot@val}{ sech}\OR\equal{\interactiveplot@val}{ csch}\OR\equal{\interactiveplot@val}{ coth}\OR\equal{\interactiveplot@val}{ asinh}\OR\equal{\interactiveplot@val}{ acosh}\OR\equal{\interactiveplot@val}{ atanh}\OR\equal{\interactiveplot@val}{ asech}\OR\equal{\interactiveplot@val}{ acsch}\OR\equal{\interactiveplot@val}{ acoth}\OR\equal{\interactiveplot@val}{ ln}\OR\equal{\interactiveplot@val}{ exp}\OR\equal{\interactiveplot@val}{ log}}{
\xdef\interactiveplot@out{4}
}{}
\expandafter\xdef\csname #2\endcsname{\interactiveplot@out}
}
%%this macro validate the precedence of operators, you can obtain information about this info in wikipedia
\def\interactiveplot@Precedence#1[#2]{
\xdef\interactiveplot@out{0}
\xdef\val{#1}
\ifthenelse{\equal{\val}{(}\OR\equal{\val}{)}}{
\xdef\interactiveplot@out{5}
}{}
\ifthenelse{\equal{\val}{*}\OR\equal{\val}{/}}{
\xdef\interactiveplot@out{2}
}{}
\ifthenelse{\equal{\val}{\string^}\OR\equal{\val}{ sqrt}}{
\xdef\interactiveplot@out{3}
}{}
\ifthenelse{\equal{\val}{+}\OR\equal{\val}{-}}{
\xdef\interactiveplot@out{1}
}{}
\ifthenelse{\equal{\val}{ sin}\OR\equal{\val}{ cos}\OR\equal{\val}{ tan}\OR\equal{\val}{ sec}\OR\equal{\val}{ csc}\OR\equal{\val}{ cot}\OR\equal{\val}{ asin}\OR\equal{\val}{ acos}\OR\equal{\val}{ atan}\OR\equal{\val}{ asec}\OR\equal{\val}{ acsc}\OR\equal{\val}{ acot}\OR\equal{\val}{ sinh}\OR\equal{\val}{ cosh}\OR\equal{\val}{ tanh}\OR\equal{\val}{ sech}\OR\equal{\val}{ csch}\OR\equal{\val}{ coth}\OR\equal{\val}{ asinh}\OR\equal{\val}{ acosh}\OR\equal{\val}{ atanh}\OR\equal{\val}{ asech}\OR\equal{\val}{ acsch}\OR\equal{\val}{ acoth}\OR\equal{\val}{ ln}\OR\equal{\val}{ exp}\OR\equal{\val}{ log}}{
\xdef\interactiveplot@out{4}
}{}
\expandafter\xdef\csname #2\endcsname{\interactiveplot@out}
}
%%this verify if an operator is unary (look at wikipedia unary operators!)
\def\interactiveplot@isUnary#1[#2]{
\xdef\val{#1}
\ifthenelse{\equal{\val}{ sin}\OR\equal{\val}{ cos}\OR\equal{\val}{ tan}\OR\equal{\val}{ sec}\OR\equal{\val}{ csc}\OR\equal{\val}{ cot}\OR\equal{\val}{ asin}\OR\equal{\val}{ acos}\OR\equal{\val}{ atan}\OR\equal{\val}{ asec}\OR\equal{\val}{ acsc}\OR\equal{\val}{ acot}\OR\equal{\val}{ sinh}\OR\equal{\val}{ cosh}\OR\equal{\val}{ tanh}\OR\equal{\val}{ sech}\OR\equal{\val}{ csch}\OR\equal{\val}{ coth}\OR\equal{\val}{ asinh}\OR\equal{\val}{ acosh}\OR\equal{\val}{ atanh}\OR\equal{\val}{ asech}\OR\equal{\val}{ acsch}\OR\equal{\val}{ acoth}\OR\equal{\val}{ ln}\OR\equal{\val}{ exp}\OR\equal{\val}{ log}}
{
\expandafter\xdef\csname #2\endcsname{1}
}{
\expandafter\xdef\csname #2\endcsname{0}
}
}
%%this macro convert the functions operators from the natural language to javascript language
\def\interactiveplot@FJS#1[#2]{
\xdef\val{#1}
\xdef\interactiveplot@out{}
 \ifthenelse{\equal{\val}{ sin}}{ \edef\interactiveplot@out{Math.sin}}{}
    \ifthenelse{\equal{\val}{ asin}}{ \edef\interactiveplot@out{Math.asin}}{}
    \ifthenelse{\equal{\val}{ cos}}{ \edef\interactiveplot@out{Math.cos}}{}
    \ifthenelse{\equal{\val}{ acos}}{ \edef\interactiveplot@out{Math.acos}}{}
    \ifthenelse{\equal{\val}{ tan}}{ \edef\interactiveplot@out{Math.tan}}{}
    \ifthenelse{\equal{\val}{ atan}}{ \edef\interactiveplot@out{Math.atan}}{}
    \ifthenelse{\equal{\val}{ csc}}{ \edef\interactiveplot@out{1/Math.sin}}{}
    \ifthenelse{\equal{\val}{ acsc}}{ \edef\interactiveplot@out{acsc}}{}
\ifthenelse{\equal{\val}{ sec}}{ \edef\interactiveplot@out{1/Math.cos}}{}
\ifthenelse{\equal{\val}{ asec}}{ \edef\interactiveplot@out{asec}}{}
    \ifthenelse{\equal{\val}{ cot}}{ \edef\interactiveplot@out{1/Math.tan}}{}
\ifthenelse{\equal{\val}{ acot}}{ \edef\interactiveplot@out{acot}}{}
    \ifthenelse{\equal{\val}{ sinh}}{ \edef\interactiveplot@out{sinh}}{}
    \ifthenelse{\equal{\val}{ asinh}}{ \edef\interactiveplot@out{asinh}}{}
    \ifthenelse{\equal{\val}{ cosh}}{ \edef\interactiveplot@out{cosh}}{}
    \ifthenelse{\equal{\val}{ acosh}}{ \edef\interactiveplot@out{acosh}}{}
    \ifthenelse{\equal{\val}{ coth}}{ \edef\interactiveplot@out{coth}}{}
    \ifthenelse{\equal{\val}{ acoth}}{ \edef\interactiveplot@out{acoth}}{}
    \ifthenelse{\equal{\val}{ tanh}}{ \edef\interactiveplot@out{tanh}}{}
    \ifthenelse{\equal{\val}{ atanh}}{ \edef\interactiveplot@out{atanh}}{}
    \ifthenelse{\equal{\val}{ csch}}{ \edef\interactiveplot@out{csch}}{}
    \ifthenelse{\equal{\val}{ acsch}}{ \edef\interactiveplot@out{acsch}}{}
\ifthenelse{\equal{\val}{ sech}}{ \edef\interactiveplot@out{sech}}{}
\ifthenelse{\equal{\val}{ asech}}{ \edef\interactiveplot@out{asech}}{}
    \ifthenelse{\equal{\val}{ exp}}{ \edef\interactiveplot@out{Math.exp}}{}
    \ifthenelse{\equal{\val}{ sqrt}}{ \edef\interactiveplot@out{Math.sqrt}}{}
    \ifthenelse{\equal{\val}{ ln}}{ \edef\interactiveplot@out{Math.ln}}{}
    \ifthenelse{\equal{\val}{ log}}{ \edef\interactiveplot@out{Math.log}}{}
    \ifthenelse{\equal{\val}{ frac}}{ \edef\interactiveplot@out{/}}{}
    \ifthenelse{\equal{\val}{\string^}}{ \edef\interactiveplot@out{Math.pow}}{}
    \expandafter\xdef\csname #2\endcsname{\interactiveplot@out}
}
%%this macro verify if an input is a decimal number
\def\interactiveplot@isDecimal#1[#2]{
\IfDecimal{#1}{\edef\decimalaux{1}}{\edef\decimalaux{0}}
\expandafter\xdef\csname #2\endcsname{\decimalaux}
}
%%this macro verify if an input is a variable
\def\interactiveplot@isVariable#1[#2]{
\ifx\interactiveplot@variablelist\undefined
\xdef\interactiveplot@parameterlist{}
\fi
\IfSubStr{\interactiveplot@variablelist}{#1}{\edef\interactiveplot@variableaux{1}}{\edef\interactiveplot@variableaux{0}}
\expandafter\xdef\csname #2\endcsname{\interactiveplot@variableaux}
}
%%this macro verify if an input is a parameter
\def\interactiveplot@isParameter#1[#2]{
\ifx\interactiveplot@parameterlist\undefined
\xdef\interactiveplot@parameterlist{}
\fi
\IfSubStr{\interactiveplot@parameterlist}{#1}{\edef\interactiveplot@parameteraux{1}}{\edef\interactiveplot@parameteraux{0}}
\expandafter\xdef\csname #2\endcsname{\interactiveplot@parameteraux}
}
%%this macro verify if the unary operator is different to a trigonometric function operator
\def\Special#1[#2]{
\xdef\val{#1}
\ifthenelse{\equal{\val}{ sqrt}\OR\equal{\val}{ exp}\OR\equal{\val}{\string^}}
{
\expandafter\xdef\csname #2\endcsname{1}
}{
\expandafter\xdef\csname #2\endcsname{0}
}
}
\newcounter{auxverifunari}
%%This macro compare if an input is an operator, if it is a unary parameter it appends a whitespace at the beginning, i do this because in first instance the function could be disordered and them it will be ordered
\def\interactiveplot@verifUnariFunc#1[#2]{
\edef\interactiveplot@output{#1}
\IfSubStr{\interactiveplot@output}{sin(}{\StrPosition{\interactiveplot@output}{sin(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{sin(}{ sin(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{sin(}{ sin(}[\interactiveplot@output]}}}{}
\IfSubStr{\interactiveplot@output}{cos(}{\StrPosition{\interactiveplot@output}{cos(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{cos(}{ cos(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{cos(}{ cos(}[\interactiveplot@output]}}}{}
\IfSubStr{\interactiveplot@output}{tan(}{\StrPosition{\interactiveplot@output}{tan(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{tan(}{ tan(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{tan(}{ tan(}[\interactiveplot@output]}}}{}
\IfSubStr{\interactiveplot@output}{cot(}{\StrPosition{\interactiveplot@output}{cot(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{cot(}{ cot(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{cot(}{ cot(}[\interactiveplot@output]}}}{}
\IfSubStr{\interactiveplot@output}{csc(}{\StrPosition{\interactiveplot@output}{csc(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{csc(}{ csc(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{csc(}{ csc(}[\interactiveplot@output]}}}{}
\IfSubStr{\interactiveplot@output}{sec(}{\StrPosition{\interactiveplot@output}{sec(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{sec(}{ sec(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{sec(}{ sec(}[\interactiveplot@output]}}}{}
\StrSubstitute{\interactiveplot@output}{asin(}{ asin(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{acos(}{ acos(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{atan(}{ atan(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{acot(}{ acot(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{asec(}{ asec(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{acsc(}{ acsc(}[\interactiveplot@output]
\IfSubStr{\interactiveplot@output}{sinh(}{\StrPosition{\interactiveplot@output}{sinh(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{sinh(}{ sinh(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{sinh(}{ sinh(}[\interactiveplot@output]}}}{}
\IfSubStr{\interactiveplot@output}{cosh(}{\StrPosition{\interactiveplot@output}{cosh(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{cosh(}{ cosh(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{cosh(}{ cosh(}[\interactiveplot@output]}}}{}
\IfSubStr{\interactiveplot@output}{tanh(}{\StrPosition{\interactiveplot@output}{tanh(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{tanh(}{ tanh(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{tanh(}{ tanh(}[\interactiveplot@output]}}}{}
\IfSubStr{\interactiveplot@output}{coth(}{\StrPosition{\interactiveplot@output}{coth(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{coth(}{ coth(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{coth(}{ coth(}[\interactiveplot@output]}}}{}
\IfSubStr{\interactiveplot@output}{csch(}{\StrPosition{\interactiveplot@output}{csch(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{csch(}{ csch(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{csch(}{ csch(}[\interactiveplot@output]}}}{}
\IfSubStr{\interactiveplot@output}{sech(}{\StrPosition{\interactiveplot@output}{sech(}[\interactiveplot@position]\ifthenelse{\interactiveplot@position=0}{\StrSubstitute{\interactiveplot@output}{sech(}{ sech(}[\interactiveplot@output]}{\StrPosition{\interactiveplot@output}{a}[\arcposition]\setcounter{auxverifunari}{\interactiveplot@position}\addtocounter{auxverifunari}{-1}\ifthenelse{\value{auxverifunari}&gt;0\AND\value{auxverifunari}=\arcposition}{}{\StrSubstitute{\interactiveplot@output}{sech(}{ sech(}[\interactiveplot@output]}}}{}
\StrSubstitute{\interactiveplot@output}{asinh(}{ asinh(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{acosh(}{ acosh(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{atanh(}{ atanh(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{acoth(}{ acoth(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{asech(}{ asech(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{acsch(}{ acsch(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{exp(}{ exp(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{ln(}{ ln(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{log(}{ log(}[\interactiveplot@output]
\expandafter\xdef\csname #2\endcsname{\interactiveplot@output}
}
%%this macro verify if exist an '[' or ']' in the function and change it for '(' or ')'
\def\validateS#1[#2]{
\StrSubstitute{#1}{[}{(}[\interactiveplot@output]
\StrSubstitute{\interactiveplot@output}{]}{)}[\interactiveplot@output]
\expandafter\xdef\csname #2\endcsname{\interactiveplot@output}
}
%%this counters are used to validate some things in the code, for example if you define a 2d function, the max number of variables have to be 1, no more, no less, and if you want to define a 3d function the max number of variables have to be 2, no more, no less.
\newcount\interactiveplot@maxNumOfVar\interactiveplot@maxNumOfVar=0
\newcount\interactiveplot@actualNumOfVar\interactiveplot@actualNumOfVar=0
\newcount\interactiveplot@actualNumOfF\interactiveplot@actualNumOfF=0
\newcount\interactiveplot@paramCount\interactiveplot@paramCount=0
\newcount\interactiveplot@varCount\interactiveplot@varCount=0
\newcount\interactiveplot@pos\interactiveplot@pos=0
%%here is managed the option "var" in the iplot macro
\define@key{iplot}{var}{
\global\advance\interactiveplot@actualNumOfVar by 1
\StrCount{#1}{,}[\interactiveplot@numComma]
\ifthenelse{ \the\interactiveplot@actualNumOfVar &gt; \the\interactiveplot@maxNumOfVar}{
\ifthenelse{\the\interactiveplot@maxNumOfVar=1}
{
\PackageError{\interactiveplot}{Invalid num of variables}{this is a 2D interactive plotter, you have to declare one variable!}
}
{
\PackageError{\interactiveplot}{Invalid num of variables}{this is a 3D interactive plotter, you have to declare two variables!}
}
}
{}
\ifthenelse{\interactiveplot@numComma&gt;2\OR\interactiveplot@numComma=1}{
\PackageError{\interactiveplot}{Invalid num of parameters in option var}{it can be only 1 or 3 parameters!}
}
{
\newcount\interactiveplot@index\interactiveplot@index=0
\@for\interactiveplot@varItem:=#1\do{
\ifthenelse{\interactiveplot@index=0}
{
\ifx\interactiveplot@variablelist\undefined
\xdef\interactiveplot@variablelist{\interactiveplot@varItem}
\else
\xdef\interactiveplot@variablelist{\interactiveplot@variablelist,\interactiveplot@varItem}
\fi
\IfSubStr{\interactiveplot@nplot}{\interactiveplot@varItem}{}{\PackageError{\interactiveplot}{variable doesnt exist}{VARIABLE doesnt exist in mathematical expression}}
\xdef\interactiveplot@var{\interactiveplot@var var variable\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@varCount= new varClass(); }
\edef\interactiveplot@varname{\interactiveplot@varItem}
\xdef\interactiveplot@var{\interactiveplot@var variable\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@varCount.setName('\interactiveplot@varItem'); }
\ifdef{\interactiveplot@varsOfExpression}{\xdef\interactiveplot@varsOfExpression{\interactiveplot@varsOfExpression var \interactiveplot@varItem = variables[\the\interactiveplot@varCount];}}{\xdef\interactiveplot@varsOfExpression{var \interactiveplot@varItem = variables[\the\interactiveplot@varCount];}}
}
{
\ifthenelse{\interactiveplot@index=1}
{
\xdef\interactiveplot@var{\interactiveplot@var variable\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@varCount.setIni(\interactiveplot@varItem); }
}
{
\ifthenelse{\interactiveplot@index=2}
{
\xdef\interactiveplot@var{\interactiveplot@var  variable\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@varCount.setEnd(\interactiveplot@varItem); }
}
{
}
}
}
\advance\interactiveplot@index by 1
}
\xdef\interactiveplot@var{\interactiveplot@var func\the\interactiveplot@render\the\interactiveplot@functions.addVar( variable\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@varCount);}
}
\advance\interactiveplot@varCount by 1
}
%%here is managed the option "frange" in the iplot macro
\define@key{iplot}{frange}[functionRange,-1,1]{
\global\advance\interactiveplot@actualNumOfF by 1
\StrCount{#1}{,}[\interactiveplot@numComma]
\ifthenelse{ \the\interactiveplot@actualNumOfVar &gt; 2 }{
\PackageError{\interactiveplot}{Invalid num of parameters}{this is a 3D interactive plotter, you have to declare one function range!}
}
{}
\ifthenelse{\interactiveplot@numComma&gt;2\OR\interactiveplot@numComma=1}{
\PackageError{\interactiveplot}{Invalid num of parameters in option var}{it can be only 1 or 3 parameters!}
}
{
\newcount\interactiveplot@index\interactiveplot@index=0
\@for\interactiveplot@varItem:=#1\do{
\ifthenelse{\interactiveplot@index=0}
{
\xdef\interactiveplot@frange{\interactiveplot@frange var frange\the\interactiveplot@render\the\interactiveplot@functions= new frangeClass(); }
\xdef\interactiveplot@frange{\interactiveplot@frange frange\the\interactiveplot@render\the\interactiveplot@functions.setName('\interactiveplot@varItem'); }
}
{
\ifthenelse{\interactiveplot@index=1}
{
\xdef\interactiveplot@frange{\interactiveplot@frange frange\the\interactiveplot@render\the\interactiveplot@functions.setIni(\interactiveplot@varItem); }
}
{
\ifthenelse{\interactiveplot@index=2}
{
\xdef\interactiveplot@frange{\interactiveplot@frange  frange\the\interactiveplot@render\the\interactiveplot@functions.setEnd(\interactiveplot@varItem); }
}
{
}
}
}
\advance\interactiveplot@index by 1
}
\xdef\interactiveplot@frange{\interactiveplot@frange func\the\interactiveplot@render\the\interactiveplot@functions.setFrange( frange\the\interactiveplot@render\the\interactiveplot@functions);}
}
}
%%here is managed the option "param" in the iplot macro
\define@key{iplot}{param}{
\StrCount{#1}{,}[\interactiveplot@numComma]
\ifthenelse{\interactiveplot@numComma&gt;4\OR\interactiveplot@numComma=0\OR\interactiveplot@numComma=1\OR\interactiveplot@numComma=3}{
\PackageError{\interactiveplot}{Invalid num of parameters in option param}{it can be only 3 or 5 arguments!}
}
{
\xdef\interactiveplot@param{\interactiveplot@param var param\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@paramCount = new paramClass(); }
\newcount\interactiveplot@index\interactiveplot@index=0
\@for\interactiveplot@varItem:=#1\do{
\ifthenelse{\interactiveplot@index=0}
{
\IfSubStr{\interactiveplot@nplot}{\interactiveplot@varItem}{}{\typeout{\interactiveplot@nplot  / \interactiveplot@varItem}\PackageError{\interactiveplot}{param doesnt exist}{PARAM doesnt exist in mathematical expression}}
\edef\interactiveplot@paramname{\interactiveplot@varItem}
\ifx\interactiveplot@parameterlist\undefined
\xdef\interactiveplot@parameterlist{~\interactiveplot@varItem~}
\else
\xdef\interactiveplot@parameterlist{\interactiveplot@parameterlist,~\interactiveplot@varItem~}
\fi
\xdef\interactiveplot@param{\interactiveplot@param  param\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@paramCount.setName('\interactiveplot@varItem'); }
\ifdef{\interactiveplot@paramsOfExpression}{\xdef\interactiveplot@paramsOfExpression{\interactiveplot@paramsOfExpression var \interactiveplot@varItem=parameters[\the\interactiveplot@paramCount]; }}{\xdef\interactiveplot@paramsOfExpression{var \interactiveplot@varItem=parameters[\the\interactiveplot@paramCount];}}
}
{
\ifthenelse{\interactiveplot@index=1}
{
\xdef\interactiveplot@param{\interactiveplot@param param\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@paramCount.setValue(\interactiveplot@varItem); }
\ifx\interactiveplot@parameterlistvalues\undefined
\xdef\interactiveplot@parameterlistvalues{\interactiveplot@varItem}
\else
\xdef\interactiveplot@parameterlistvalues{\interactiveplot@parameterlistvalues,\interactiveplot@varItem}
\fi
\xdef\interactiveplot@valueaux{\interactiveplot@varItem}
}
{
\ifthenelse{\interactiveplot@index=2}
{
\xdef\interactiveplot@param{\interactiveplot@param param\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@paramCount.setIncrement(\interactiveplot@varItem); }
}
{
\ifthenelse{\interactiveplot@index=3}
{
\ifthenelse{\interactiveplot@valueaux&lt;\interactiveplot@varItem}{\PackageError{\interactiveplot}{Value is less than minimal value}{use another initial value}}{}
\xdef\interactiveplot@param{\interactiveplot@param param\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@paramCount.setIni(\interactiveplot@varItem); }
}
{
\ifthenelse{\interactiveplot@index=4}
{
\xdef\interactiveplot@param{\interactiveplot@param param\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@paramCount.setEnd(\interactiveplot@varItem); }
\ifthenelse{\interactiveplot@valueaux&gt;\interactiveplot@varItem}{\PackageError{\interactiveplot}{Value is greater than maximal value}{use another initial value}}{}
}
{}
}
}
}
}
\advance\interactiveplot@index by 1
}
\xdef\interactiveplot@param{\interactiveplot@param func\the\interactiveplot@render\the\interactiveplot@functions.addParam( param\the\interactiveplot@render\the\interactiveplot@functions\the\interactiveplot@paramCount); }
}
\advance\interactiveplot@paramCount by 1
}
%%here is managed the option "border" in the iplot macro
\define@key{iplot}{border}[1]{
\xdef\border{#1}
}
%%here is managed the option "color" in the iplot macro
\define@key{iplot}{color}[notcolor]{
\edef\interactiveplot@input{#1}
\IfStrEqCase{\interactiveplot@input}{
{notcolor}{
\xdef\interactiveplot@color{ func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.black);}
}
{black}{
\xdef\interactiveplot@color{ func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.black);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{black}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,black}}
}
{white}{
\xdef\interactiveplot@color{ func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.white);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{white}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,white}}
}
{red}{
\xdef\interactiveplot@color{func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.red);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{red}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,red}}
}
{green}{
\xdef\interactiveplot@color{func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.green);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{green}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,green}}
}
{blue}{
\xdef\interactiveplot@color{func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.blue);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{blue}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,blue}}
}
{cyan}{
\xdef\interactiveplot@color{func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.cyan);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{cyan}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,cyan}}
}
{magenta}{
\xdef\interactiveplot@color{func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.magenta);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{magenta}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,magenta}}
}
{yellow}{
\xdef\interactiveplot@color{func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.yellow);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{yellow}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,yellow}}
}
{dark-gray}{
\xdef\interactiveplot@color{func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.dkGray);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{dark-gray}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,dark-gray}}
}
{gray}{
\xdef\interactiveplot@color{func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.gray);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{gray}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,gray}}
}
{light gray}{
\xdef\interactiveplot@color{func\the\interactiveplot@render\the\interactiveplot@functions.setColor(color.ltGray);}
\ifthenelse{\equal{\interactiveplot@colormanage}{}}
{\xdef\interactiveplot@colormanage{light gray}}
{\xdef\interactiveplot@colormanage{\interactiveplot@colormanage,light gray}}
}
}
\ifx\interactiveplot@color\undefined
\PackageError{\interactiveplot}{Invalid Color}{try one of these color names: White, Red, Green, Blue, Cyan, Magenta, Yellow, Dark Gray, Gray, Light Gray  }
\fi
}
%%here is managed the option "resolution" in the iplot macro
\define@key{iplot}{resolution}[default]{
\edef\interactiveplot@input{#1}
\IfStrEq{\interactiveplot@input}{default}
{
\ifthenelse{\the\interactiveplot@maxNumOfVar=1}
{
\edef\interactiveplot@input{500}
\xdef\interactiveplot@resolution{ func\the\interactiveplot@render\the\interactiveplot@functions.setResolution(\interactiveplot@input);}
}
{
\edef\interactiveplot@input{35}
\xdef\interactiveplot@resolution{ func\the\interactiveplot@render\the\interactiveplot@functions.setResolution(\interactiveplot@input);}
}
}
{
\ifthenelse{\interactiveplot@input&gt;0}
{
\xdef\interactiveplot@resolution{ func\the\interactiveplot@render\the\interactiveplot@functions.setResolution(\interactiveplot@input);}
}
{
\PackageError{\interactiveplot}{Invalid resolution}{it can be only an positive integer value!}
}
}
}
%%here all the options are cleaned
\def\interactiveplot@cleanoptions{
\xdef\interactiveplot@var{}
\xdef\interactiveplot@frange{}
\xdef\interactiveplot@param{}
\xdef\border{}
\xdef\interactiveplot@color{}
\xdef\resolution{}
\xdef\width{}
\xdef\height{}
}
\xdef\interactiveplot@functionsmanage{}
\xdef\interactiveplot@colormanage{}
%%this is the iplot macro definition
\newcommand{\iplot}[2][]{
\StrSubstitute{#2}{ }{}[\interactiveplot@nplot]
\ifthenelse{\equal{\interactiveplot@functionsmanage}{}}
{\xdef\interactiveplot@functionsmanage{\interactiveplot@nplot}}
{\xdef\interactiveplot@functionsmanage{\interactiveplot@functionsmanage,\interactiveplot@nplot}}
\interactiveplot@cleanoptions
\setkeys{iplot}{border,color,resolution,frange,#1}
\interactiveplot@verifUnariFunc{\interactiveplot@nplot}[interactiveplot@nplot]
\validateS{\interactiveplot@nplot}[interactiveplot@nplot]
\StrCount{\interactiveplot@nplot}{(}[\auxopen] \StrCount{\interactiveplot@nplot}{)}[\auxclose]
\ifthenelse{\equal{\auxopen}{\auxclose}}{}{
\PackageError{graficainteractiva}{Unbalanced parentheses!}{Maybe you are using an extra parentheses}}
\StrLen{\interactiveplot@nplot}[\interactiveplot@auxlen]
\ifx\c@ct\undefined
\newcounter{ct}
\else
\setcounter{ct}{0}
\fi
\ifx\c@len\undefined
\newcounter{len}
\else
\setcounter{len}{0}
\fi
\setcounter{len}{\interactiveplot@auxlen+1}
\ifdef{\stack@slist}{\let\stack@slist\undefined}{}
\NewStack{slist}{\relax}
\ifdef{\stack@tokens}{\let\stack@tokens\undefined}{}
\NewStack{tokens}{\relax}
\ifdef{\stack@stack}{\let\stack@stack\undefined}{}
\NewStack{stack}{\relax}
\ifdef{\stack@stackitp}{\let\stack@stackitp\undefined}{}
\NewStack{stackitp}{\relax}
\ifdef{\stack@postfix}{\let\stack@postfix\undefined}{}
\NewStack{postfix}{\relax}
\ifdef{\stack@stackpjs}{\let\stack@stackpjs\undefined}{}
\NewStack{stackpjs}{\relax}
\xdef\interactiveplot@cadenaux{}
%%here begins the process of parse the function using stacks
%%first thing to do is interpret the tokens (elements, numbers operators, parenthesis, etc)
\forloop{ct}{1}{\value{ct} &lt;\value{len} }%
{%
\StrChar{\interactiveplot@nplot}{\value{ct}}[\interactiveplot@salida]
\interactiveplot@isOperator{\interactiveplot@salida}[result]
\ifthenelse{\result=0}
{
\xdef\interactiveplot@cadenaux{\interactiveplot@cadenaux \interactiveplot@salida}
}
{
\ifthenelse{\result=1}
{
\ifthenelse{\equal{\interactiveplot@salida}{-}\AND\equal{\interactiveplot@cadenaux}{}}
{
\ifthenelse{\equal{\Stack{slist}}{\relax}\OR\equal{\Stack{slist}}{(}}
{
\Push{slist}{-1}
\Push{slist}{*}
}{
\Push{slist}{+}
\Push{slist}{-1}
\Push{slist}{*}
}

}
{
\ifthenelse{\NOT\equal{\interactiveplot@cadenaux}{}}
{
\Push{slist}{\interactiveplot@cadenaux}
}
{}
\xdef\interactiveplot@cadenaux{\interactiveplot@salida}
\Push{slist}{\interactiveplot@cadenaux}
\ifthenelse{\NOT\equal{\Stack{slist}}{\relax}\AND\equal{\interactiveplot@cadenaux}{(}}{
\Push{stack}{\interactiveplot@cadenaux}
}{}
\ifthenelse{\NOT\equal{\Stack{slist}}{\relax}\AND\equal{\interactiveplot@cadenaux}{)}}{
\Pop{stack}
\ifthenelse{\equal{\Stack{stack}}{/}\OR\equal{\Stack{stack}}{sqrt}}{
\Push{slist}{\Stack{stack}}
\Pop{stack}
}{}
}{}
\xdef\interactiveplot@cadenaux{}
}
}
{
\ifthenelse{\equal{\interactiveplot@salida}{ }}{
\ifthenelse{\NOT\equal{\interactiveplot@cadenaux}{}}{
\Push{slist}{\interactiveplot@cadenaux}
}{}
\xdef\interactiveplot@cadenaux{}
\forloop{ct}{\value{ct}}{\NOT\equal{\interactiveplot@salida}{(}}%
{%
\StrChar{\interactiveplot@nplot}{\value{ct}}[\interactiveplot@salida]
\xdef\interactiveplot@cadenaux{\interactiveplot@cadenaux \interactiveplot@salida}
}
\ifthenelse{\equal{\interactiveplot@cadenaux}{ sqrt}}{
\Push{stack}{\interactiveplot@cadenaux}
\xdef\interactiveplot@cadenaux{\interactiveplot@salida}
\Push{stack}{\interactiveplot@cadenaux}
\Push{slist}{\interactiveplot@cadenaux}
\xdef\interactiveplot@cadenaux{}
}
{
\Push{slist}{\interactiveplot@cadenaux}
\xdef\interactiveplot@cadenaux{}
}
}{}
}
}
}
\ifthenelse{\NOT\equal{\interactiveplot@cadenaux}{}}{
\Push{slist}{\interactiveplot@cadenaux}
}{}
\whiledo{\NOT\equal{\Stack{slist}}{\relax}}%
{
\Push{tokens}{\Stack{slist}}
\interactiveplot@isOperator{\Stack{slist}}[interactiveplot@isoperator]
\interactiveplot@isDecimal{\Stack{slist}}[interactiveplot@isdecimal]
\interactiveplot@isVariable{\Stack{slist}}[interactiveplot@isvariable]
\interactiveplot@isParameter{\Stack{slist}}[interactiveplot@isparameter]
\ifthenelse{\equal{\interactiveplot@isoperator}{0}\AND\equal{\interactiveplot@isdecimal}{0}\AND\equal{\interactiveplot@isvariable}{0}\AND\equal{\interactiveplot@isparameter}{0}}{
\PackageError{\interactiveplot}{Param is not previously declared}{Declare the param!}
}{}
\Pop{slist}
\let\interactiveplot@isdecimal\undefined
}
%%when all the tokens are identified, them begins the process of parse te function, this process start from here
%% here the hit of this section of code is convert the function in a postfix expression, the reason of this is to obtain a easy way to operate all the functions (investigate about postfix expression in wikipedia!)
\whiledo{\NOT\equal{\Stack{tokens}}{\relax}}{
\interactiveplot@isOperator{\Stack{tokens}}[interactiveplot@isoperator]
\ifthenelse{\NOT\equal{\interactiveplot@isoperator}{1}}{
\Push{postfix}{\Stack{tokens}}
\Pop{tokens}
}{
\interactiveplot@isUnary{\Stack{tokens}}[interactiveplot@isunary]
\ifthenelse{\equal{\Stack{stackitp}}{\relax}\OR\equal{\interactiveplot@isunary}{1}}{
\Push{stackitp}{\Stack{tokens}}
\Pop{tokens}
}{\ifthenelse{\equal{\Stack{tokens}}{)}}{
\whiledo{\NOT\equal{\Stack{stackitp}}{(}\AND\NOT\equal{\Stack{stackitp}}{\relax}}{
\Push{postfix}{\Stack{stackitp}}
\Pop{stackitp}
}
\Pop{stackitp}
\Pop{tokens}
}{
\interactiveplot@Precedence{\Stack{tokens}}[interactiveplot@precedence]
\interactiveplot@PrecedenceInStack{\Stack{stackitp}}[interactiveplot@interactiveplot@precedenceinstack]
\ifthenelse{\interactiveplot@precedence&gt;\interactiveplot@interactiveplot@precedenceinstack}{
\Push{stackitp}{\Stack{tokens}}
\Pop{tokens}
}{
\Push{postfix}{\Stack{stackitp}}
               \Pop{stackitp}
               \interactiveplot@Precedence{\Stack{tokens}}[interactiveplot@precedence]\interactiveplot@PrecedenceInStack{\Stack{stackitp}}[interactiveplot@interactiveplot@precedenceinstack]
               \whiledo{\NOT\equal{\Stack{stackitp}}{\relax}\AND\interactiveplot@precedence&lt;\interactiveplot@interactiveplot@precedenceinstack}{
               \Push{postfix}{\Stack{stackitp}}
                  \Pop{stackitp}
\interactiveplot@Precedence{\Stack{tokens}}[interactiveplot@precedence]
               \interactiveplot@PrecedenceInStack{\Stack{stackitp}}[interactiveplot@interactiveplot@precedenceinstack]
               }
\interactiveplot@Precedence{\Stack{tokens}}[interactiveplot@precedence]\interactiveplot@PrecedenceInStack{\Stack{stackitp}}[interactiveplot@interactiveplot@precedenceinstack]
\ifthenelse{\NOT\equal{\Stack{stackitp}}{\relax}\AND\equal{\interactiveplot@precedence}{\interactiveplot@interactiveplot@precedenceinstack}}{
\Push{postfix}{\Stack{stackitp}}
                 \Pop{stackitp}
\interactiveplot@Precedence{\Stack{tokens}}[interactiveplot@precedence]
              \interactiveplot@PrecedenceInStack{\Stack{stackitp}}[interactiveplot@interactiveplot@precedenceinstack]
}{}
               \Push{stackitp}{\Stack{tokens}}
            \Pop{tokens}
}
}
}
}
}
%%and from now the hit is to convert again the postfix expression in a prefix expression, but now the result of all this, is an expression in language JavaScript
\ifthenelse{\NOT\equal{\Stack{stackitp}}{\relax}}{
\Push{postfix}{\Stack{stackitp}}
\Pop{stackitp}
\whiledo{\NOT\equal{\Stack{stackitp}}{\relax}}{
\Push{postfix}{\Stack{stackitp}}
\Pop{stackitp}
}
}{}
\whiledo{\NOT\equal{\Stack{postfix}}{\relax}}{
\Push{tokens}{\Stack{postfix}}
\Pop{postfix}
}
\whiledo{\NOT\equal{\Stack{tokens}}{\relax}}{
\interactiveplot@isOperator{\Stack{tokens}}[interactiveplot@isoperator]
\ifthenelse{\NOT\equal{\interactiveplot@isoperator}{1}}{
\Push{stackpjs}{\Stack{tokens}}
\Pop{tokens}
}
{
\interactiveplot@isUnary{\Stack{tokens}}[interactiveplot@isunary]
\ifthenelse{\NOT\equal{\interactiveplot@isunary}{1}}{
\xdef\interactiveplot@opTwo{\Stack{stackpjs}}
\Pop{stackpjs}
\xdef\interactiveplot@opOne{\Stack{stackpjs}}
\Pop{stackpjs}
\Special{\Stack{tokens}}[special]
\ifthenelse{\NOT\equal{\special}{1}}{
\Push{stackpjs}{(\interactiveplot@opOne\Stack{tokens}\interactiveplot@opTwo)}
\Pop{tokens}
}
{
\interactiveplot@FJS{\Stack{tokens}}[fjs]
\Push{stackpjs}{\fjs(\interactiveplot@opOne,\interactiveplot@opTwo)}
\Pop{tokens}
}
}
{
\xdef\interactiveplot@opu{\Stack{stackpjs}}
\Pop{stackpjs}
\interactiveplot@FJS{\Stack{tokens}}[fjs]
\StrChar{\interactiveplot@opu}{1}[\interactiveplot@opuAtZero]
\ifthenelse{\equal{\interactiveplot@opuAtZero}{(}}{
\Push{stackpjs}{\fjs\interactiveplot@opu}
}
{
\Push{stackpjs}{\fjs(\interactiveplot@opu)}
}
\Pop{tokens}
}
}
}
%%\Stack{stackpjs} have all the function parsed in JavaScript Language
\xdef\interactiveplot@ecuationJS{\Stack{stackpjs}}
%%here is defined the javascript class who manage all the attributes of the function this javascript code is inserted in a pdf.
\xdef\interactiveplot@functionClass{
function functionClass\the\interactiveplot@render\the\interactiveplot@functions(){
this.variables=new Array();
this.param=new Array();
this.frange=new frangeClass();
this.border=null;
this.setBorder=setBorder;
function setBorder(border){
this.border=border;
}
this.color=null;
this.setColor=setColor;
function setColor(color){
this.color=color;
}
this.resolution=null;
this.setResolution=setResolution;
function setResolution(resolution){
this.resolution=resolution;
}
this.varLen=varLen;
function varLen(){
return this.variables.length;
}
this.paramLen=paramLen;
function paramLen(){
return this.param.length;
}
this.addVar=addVar;
function addVar(variable){
this.variables.push(variable);
}
this.setFrange=setFrange;
function setFrange(frange){
this.frange=frange;
}
this.addParam=addParam;
function addParam(param){
this.param.push(param);
}
this.Expression=Expression;
function Expression(variables,parameters){% here is inserted in the javascript code the variables ordered
\ifx\interactiveplot@varsOfExpression\undefinded
\else
\interactiveplot@varsOfExpression
\fi
\ifx\interactiveplot@paramsOfExpression\undefinded
\else
\interactiveplot@paramsOfExpression
\fi
return \interactiveplot@ecuationJS; % and here returns the value of the function evaluated for  "variables" and "parameters" values
}
this.clear=clear;
function clear(){
this.variables=new Array();
this.param=new Array();
this.border=null;
this.color=null;
this.dashed=null;
this.varLen=varLen;
}
}
var func\the\interactiveplot@render\the\interactiveplot@functions = new functionClass\the\interactiveplot@render\the\interactiveplot@functions(); %here is defined the variable who store the class, it will look like func00 if in al the pdf exist only one render and one function inside the render! if many renders with many functions it will look like funcNN
\interactiveplot@var
\interactiveplot@frange
\interactiveplot@param
\interactiveplot@color
\interactiveplot@resolution
}
\xdef\interactiveplot@varsOfExpression{}
\xdef\interactiveplot@paramsOfExpression{}
\let\interactiveplot@varsOfExpression\undefined
\let\interactiveplot@paramsOfExpression\undefined
\xdef\interactiveplot@JScode{\interactiveplot@JScode \interactiveplot@functionClass render\the\interactiveplot@render.functions[\the\interactiveplot@functions] = func\the\interactiveplot@render\the\interactiveplot@functions ; }
\advance\interactiveplot@functions by 1
 \global\interactiveplot@actualNumOfVar=0
\global\interactiveplot@actualNumOfF=0
\interactiveplot@paramCount=0
\interactiveplot@varCount=0
}
%% in this macro are stored some functions that will be used by the principal classes
\xdef\interactiveplot@classesJS{
function varClass(){
this.name=null;
this.ini=null;
this.end=null;
this.setName=setName;
function setName(name){
this.name=name;
}
this.setIni=setIni;
function setIni(ini){
this.ini=ini;
}
this.setEnd=setEnd;
function setEnd(end){
this.end=end;
}
this.clear=clear;
function clear(){
this.name=null;
this.ini=null;
this.end=null;
}
}
function frangeClass(){
this.name=null;
this.ini=null;
this.end=null;
this.setName=setName;
function setName(name){
this.name=name;
}
this.setIni=setIni;
function setIni(ini){
this.ini=ini;
}
this.setEnd=setEnd;
function setEnd(end){
this.end=end;
}
this.clear=clear;
function clear(){
this.name=null;
this.ini=null;
this.end=null;
}
}
function paramClass(){
this.name=null;
this.ini=null;
this.end=null;
this.value=null;
this.increment=null;
this.setName=setName;
function setName(name){
this.name=name;
}
this.setIni=setIni;
function setIni(ini){
this.ini=ini;
}
this.setEnd=setEnd;
function setEnd(end){
this.end=end;
}
  this.setValue=setValue;
  function setValue(value){
  this.value=value;
  }
this.setIncrement=setIncrement;
function setIncrement(increment){
this.increment=increment;
}
this.clear=clear;
function clear(){
this.name=null;
this.ini=null;
this.end=null;
this.value=null;
this.increment=null;
}
}
}
\newlength{\interactiveplot@actualTextHeight}
\define@key{naturaliplot}{width}[default]{
\ifthenelse{\equal{#1}{default}}
{
\StrGobbleRight{\the\textwidth}{2}[\gobblerightOut]
\xdef\interactiveplot@naturalIplotWidth{\gobblerightOut}
}
{
\xdef\interactiveplot@naturalIplotWidth{#1}
}

}
\define@key{naturaliplot}{height}[default]{
\ifthenelse{\equal{#1}{default}}
{
\xdef\interactiveplot@factorWidescreen{1.7777777}
\setlength{\interactiveplot@actualTextHeight}{\textwidth / \real{\interactiveplot@factorWidescreen}}
\StrGobbleRight{\the\interactiveplot@actualTextHeight}{2}[\gobblerightOut]
\xdef\interactiveplot@naturalIplotHeight{\gobblerightOut}
}
{
\xdef\interactiveplot@naturalIplotHeight{#1}
}
}
%%here is defined the piloted environment
\newenvironment{iplotdd}[1][]{
\global\interactiveplot@maxNumOfVar=1
\ifdef{\interactiveplot@render}{\global\advance\interactiveplot@render by 1}{\newcount\interactiveplot@render\interactiveplot@render=0 }
\setkeys{naturaliplot}{width,height,#1}
\ifthenelse{\the\interactiveplot@render=0}{
\xdef\interactiveplot@JScode{\interactiveplot@classesJS}
}
{}
\xdef\interactiveplot@JScode{\interactiveplot@JScode var render\the\interactiveplot@render = new Object(); render\the\interactiveplot@render .functions = new Array(); }
\catcode`\^=12
\catcode`\~=12
}
%%in this space is incerte the pilot macro
{
\xdef\interactiveplot@JScode{
\interactiveplot@JScode
var ubication\the\interactiveplot@render = this.getField("squareUbication\the\interactiveplot@render");%this is very importan, in this variable is stored the pdf ubication of the the actual plot
ubication\the\interactiveplot@render.hidden=true;
var i;
var j;
var BasicRangeIniVar=-25;
var BasicRangeEndVar=25;
var rangini\the\interactiveplot@render;
var rangend\the\interactiveplot@render;
var frangeini\the\interactiveplot@render;
var frangeend\the\interactiveplot@render;
var curv= new Array();
%% This cycle checks if any of the functions has a larger limits in the x axis that has already been provided
for(i=0;i&lt;render\the\interactiveplot@render.functions.length;i++){
for(j=0;j&lt;render\the\interactiveplot@render.functions[i].variables.length;j++){
if(render\the\interactiveplot@render.functions[i].variables[j].ini==undefined&amp;&amp;render\the\interactiveplot@render.functions[i].variables[j].end==undefined){
if(rangini\the\interactiveplot@render==undefined&amp;&amp;rangend\the\interactiveplot@render==undefined){
rangini\the\interactiveplot@render = BasicRangeIniVar;
rangend\the\interactiveplot@render = BasicRangeEndVar;
}
else{
if(rangini\the\interactiveplot@render&gt;BasicRangeIniVar){rangini\the\interactiveplot@render = BasicRangeIniVar;}
if(rangend\the\interactiveplot@render&lt;BasicRangeEndVar){rangend\the\interactiveplot@render = BasicRangeEndVar;}
}
}
else{
if(rangini\the\interactiveplot@render==undefined&amp;&amp;rangend\the\interactiveplot@render==undefined){
rangini\the\interactiveplot@render = render\the\interactiveplot@render.functions[i].variables[j].ini;
rangend\the\interactiveplot@render = render\the\interactiveplot@render.functions[i].variables[j].end;
}
else{
if(rangini\the\interactiveplot@render&gt;render\the\interactiveplot@render.functions[i].variables[j].ini){rangini\the\interactiveplot@render = render\the\interactiveplot@render.functions[i].variables[j].ini;}
if(rangend\the\interactiveplot@render&lt;render\the\interactiveplot@render.functions[i].variables[j].end){rangend\the\interactiveplot@render = render\the\interactiveplot@render.functions[i].variables[j].end;}
}
}
}
if(frangeini\the\interactiveplot@render==undefined&amp;&amp;frangeend\the\interactiveplot@render==undefined){
frangeini\the\interactiveplot@render = render\the\interactiveplot@render.functions[i].frange.ini;
frangeend\the\interactiveplot@render = render\the\interactiveplot@render.functions[i].frange.end;
}
else{
if(frangeini\the\interactiveplot@render&gt;render\the\interactiveplot@render.functions[i].frange.ini){frangeini\the\interactiveplot@render = render\the\interactiveplot@render.functions[i].frange.ini;}
if(frangeend\the\interactiveplot@render&lt;render\the\interactiveplot@render.functions[i].frange.end){frangeend\the\interactiveplot@render = render\the\interactiveplot@render.functions[i].frange.end;}
}
}
var  pointx\the\interactiveplot@render = ubication\the\interactiveplot@render.rect[0];
var pointy\the\interactiveplot@render = ubication\the\interactiveplot@render.rect[1];
var x  = 30;
var y = 30;
var sumax = true;
var sumay = true;
var proportionx\the\interactiveplot@render = \interactiveplot@naturalIplotWidth/Math.abs( rangend\the\interactiveplot@render-rangini\the\interactiveplot@render );
var proportiony\the\interactiveplot@render = \interactiveplot@naturalIplotHeight/Math.abs( frangeend\the\interactiveplot@render-frangeini\the\interactiveplot@render );
var  TranslationConstantX\the\interactiveplot@render= proportionx\the\interactiveplot@render*(rangend\the\interactiveplot@render+rangini\the\interactiveplot@render)/2;
var  TranslationConstantY\the\interactiveplot@render= proportiony\the\interactiveplot@render*(frangeend\the\interactiveplot@render+frangeini\the\interactiveplot@render)/2;
var  centro\the\interactiveplot@render = [pointx\the\interactiveplot@render+\interactiveplot@naturalIplotWidth/2,pointy\the\interactiveplot@render-\interactiveplot@naturalIplotHeight/2]; % here is calculated the center point between the width and height defined by te user when use the environment iplotdd
var recta_ejex = [[centro\the\interactiveplot@render[0]+rangini\the\interactiveplot@render*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]-TranslationConstantY\the\interactiveplot@render],[centro\the\interactiveplot@render[0]+rangend\the\interactiveplot@render*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render, centro\the\interactiveplot@render[1]-TranslationConstantY\the\interactiveplot@render]]; %here is defined the X axis
var recta_ejey = [[centro\the\interactiveplot@render[0]-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]+frangeend\the\interactiveplot@render*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render],[centro\the\interactiveplot@render[0]-TranslationConstantX\the\interactiveplot@render, centro\the\interactiveplot@render[1]+frangeini\the\interactiveplot@render*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render]];%here is defined the Y axis
var mod_ejex = recta_ejex[1][0]-recta_ejex[0][0];
var mod_ejey = recta_ejey[0][1]-recta_ejey[1][1];
var tam_unid\the\interactiveplot@render = mod_ejex/(Math.abs(rangend\the\interactiveplot@render)+Math.abs(rangini\the\interactiveplot@render));
var del_unid = new Array();
var ldel_unid = 6;
var delimitadores =  new Array();
var labelLimite1\the\interactiveplot@render = this.addAnnot({ %and here is inserted a value of the X axis limit
page: ubication\the\interactiveplot@render.page,
type: "FreeText",
rect: [
centro\the\interactiveplot@render[0]+proportionx\the\interactiveplot@render*rangini\the\interactiveplot@render+3-TranslationConstantX\the\interactiveplot@render,
centro\the\interactiveplot@render[1]-4-TranslationConstantY\the\interactiveplot@render,
centro\the\interactiveplot@render[0]+proportionx\the\interactiveplot@render*rangini\the\interactiveplot@render+31-TranslationConstantX\the\interactiveplot@render,
centro\the\interactiveplot@render[1]-10-TranslationConstantY\the\interactiveplot@render],
lock: true,
style: "D",
width:0.05
});
labelLimite1\the\interactiveplot@render.textSize=5;
labelLimite1\the\interactiveplot@render.alignment=0;
labelLimite1\the\interactiveplot@render.strokeColor = color.black;
labelLimite1\the\interactiveplot@render.contents = rangini\the\interactiveplot@render.toFixed(2); % the minimal limit in X axis
labelLimite1\the\interactiveplot@render.width= 0;
var labelLimite2\the\interactiveplot@render = this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "FreeText",
rect: [
centro\the\interactiveplot@render[0]+proportionx\the\interactiveplot@render*rangend\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render-14,
centro\the\interactiveplot@render[1]-4,
centro\the\interactiveplot@render[0]+proportionx\the\interactiveplot@render*rangend\the\interactiveplot@render+14-TranslationConstantX\the\interactiveplot@render,
centro\the\interactiveplot@render[1]-10],
lock: true,
style: "D",
readOnly: true,
});
labelLimite2\the\interactiveplot@render.textSize=5;
labelLimite2\the\interactiveplot@render.alignment=2;
labelLimite2\the\interactiveplot@render.strokeColor = color.black;
labelLimite2\the\interactiveplot@render.contents = rangend\the\interactiveplot@render.toFixed(2);% the maximal limit in X axis
labelLimite2\the\interactiveplot@render.width= 0;
var labelLimite3\the\interactiveplot@render = this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "FreeText",
rect: [
centro\the\interactiveplot@render[0]-TranslationConstantX\the\interactiveplot@render+4,
centro\the\interactiveplot@render[1]+8-TranslationConstantY\the\interactiveplot@render+proportiony\the\interactiveplot@render*frangeini\the\interactiveplot@render,% the minimal limit in Y axis
centro\the\interactiveplot@render[0]+32-TranslationConstantX\the\interactiveplot@render,
centro\the\interactiveplot@render[1]-2-TranslationConstantY\the\interactiveplot@render+proportiony\the\interactiveplot@render*frangeini\the\interactiveplot@render],
lock: true,
style: "D",
width:0.05
});
labelLimite3\the\interactiveplot@render.textSize=5;
labelLimite3\the\interactiveplot@render.alignment=0;
labelLimite3\the\interactiveplot@render.strokeColor = color.black;
labelLimite3\the\interactiveplot@render.contents = frangeini\the\interactiveplot@render.toFixed(2);% the minimal limit in Y axis
labelLimite3\the\interactiveplot@render.width= 0;
var labelLimite4\the\interactiveplot@render = this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "FreeText",
rect: [
centro\the\interactiveplot@render[0]-TranslationConstantX\the\interactiveplot@render+4,
centro\the\interactiveplot@render[1]-4-TranslationConstantY\the\interactiveplot@render+proportiony\the\interactiveplot@render*frangeend\the\interactiveplot@render,
centro\the\interactiveplot@render[0]+32-TranslationConstantX\the\interactiveplot@render,
centro\the\interactiveplot@render[1]-10-TranslationConstantY\the\interactiveplot@render+proportiony\the\interactiveplot@render*frangeend\the\interactiveplot@render],
lock: true,
style: "D",
width:0.05
});
labelLimite4\the\interactiveplot@render.textSize=5;
labelLimite4\the\interactiveplot@render.alignment=0;
labelLimite4\the\interactiveplot@render.strokeColor = color.black;
labelLimite4\the\interactiveplot@render.contents = frangeend\the\interactiveplot@render.toFixed(2);% the maximal limit in Y axis
labelLimite4\the\interactiveplot@render.width= 0;
for(i = Math.floor(rangini\the\interactiveplot@render); i&lt;= Math.floor(rangend\the\interactiveplot@render) ; i++){%the del imitators are calculated, the lines that defines the units in the x axis
delimitadores.push([centro\the\interactiveplot@render[0]+i*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]+i*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]+ldel_unid/2-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]+i*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]-ldel_unid/2-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]+i*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]-TranslationConstantY\the\interactiveplot@render]);
}
this.addAnnot({%delimitators inserted
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
vertices: delimitadores,
lock: true,
style: "D",
readOnly: true,
strokeColor:color.black,
width:0.5
});
var delimitadores =  new Array();
for(i = Math.floor(rangini\the\interactiveplot@render); i&lt;= Math.floor(rangend\the\interactiveplot@render) ; i+=0.1){%the delimitators in the Y axis
delimitadores.push([centro\the\interactiveplot@render[0]+i*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]+i*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]+ldel_unid/6-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]+i*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]-ldel_unid/6-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]+i*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]-TranslationConstantY\the\interactiveplot@render]);
}
this.addAnnot({%delimitators inserted
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
vertices: delimitadores,
lock: true,
style: "D",
readOnly: true,
strokeColor:color.black,
width:0.05
});
delimitadores =  new Array();
for(i = Math.floor(frangeini\the\interactiveplot@render); i&lt;= Math.floor(frangeend\the\interactiveplot@render) ; i++){
delimitadores.push([centro\the\interactiveplot@render[0]-TranslationConstantX\the\interactiveplot@render , centro\the\interactiveplot@render[1]+i*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]+ldel_unid/2-TranslationConstantX\the\interactiveplot@render, centro\the\interactiveplot@render[1]+i*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]-ldel_unid/2 -TranslationConstantX\the\interactiveplot@render, centro\the\interactiveplot@render[1]+i*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]-TranslationConstantX\the\interactiveplot@render , centro\the\interactiveplot@render[1]+i*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render]);
}
this.addAnnot({ %delimitators inserted
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
vertices: delimitadores,
lock: true,
style: "D",
readOnly: true,
strokeColor:color.black,
width:0.5
});
delimitadores =  new Array();
for(i = Math.floor(frangeini\the\interactiveplot@render); i&lt;= Math.floor(frangeend\the\interactiveplot@render) ; i+=0.1){
delimitadores.push([centro\the\interactiveplot@render[0]-TranslationConstantX\the\interactiveplot@render , centro\the\interactiveplot@render[1]+i*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]+ldel_unid/6-TranslationConstantX\the\interactiveplot@render, centro\the\interactiveplot@render[1]+i*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]-ldel_unid/6-TranslationConstantX\the\interactiveplot@render , centro\the\interactiveplot@render[1]+i*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render]);
delimitadores.push([centro\the\interactiveplot@render[0]-TranslationConstantX\the\interactiveplot@render , centro\the\interactiveplot@render[1]+i*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render]);
}
this.addAnnot({ %delimitators inserted
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
vertices: delimitadores,
lock: true,
style: "D",
readOnly: true,
strokeColor:color.black,
width:0.05
});
var ejey = this.addAnnot({ %Y axis inserted
page: ubication\the\interactiveplot@render.page,
type: "Line",
points: recta_ejey,
lock: true,
readOnly: true,
arrowBegin: "OpenArrow",
arrowEnd: "OpenArrow",
strokeColor:color.black,
width:0.5
});
var ejex = this.addAnnot({ %X axis inserted
page: ubication\the\interactiveplot@render.page,
type: "Line",
points: recta_ejex,
lock: true,
readOnly: true,
arrowBegin: "OpenArrow",
arrowEnd: "OpenArrow",
strokeColor:color.black,
width:0.5
});
var cap\the\interactiveplot@render  =   this.getField("square\the\interactiveplot@render");
cap\the\interactiveplot@render.rect = [pointx\the\interactiveplot@render-4,pointy\the\interactiveplot@render+4,pointx\the\interactiveplot@render+\interactiveplot@naturalIplotWidth+4,pointy\the\interactiveplot@render-\interactiveplot@naturalIplotHeight-4]; %the button who
var curves\the\interactiveplot@render=new Array();
for(i=0;i&lt;render\the\interactiveplot@render.functions.length;i++){
curves\the\interactiveplot@render[i]= this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
vertices: curve2d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i],frangeini\the\interactiveplot@render,frangeend\the\interactiveplot@render),
lock: true,
width: 0.5,
readOnly: true,
strokeColor:render\the\interactiveplot@render.functions[i].color
});
}
function fieldChange\the\interactiveplot@render(param,field){%in this function is managed when the user change the value of a textfield using the keyboard
var i ;
var j ;
if(event.value!=""&amp;&amp;(event.commitKey==2||event.commitKey==3)){
for(i=render\the\interactiveplot@render.functions.length-1;i&gt;=0;i--){
for( j = 0 ; j &lt;render\the\interactiveplot@render.functions[i].param.length ; j ++ ){
if( param == render\the\interactiveplot@render.functions[i].param[j].name ){
if(!existIn(param,managed\the\interactiveplot@render)){
if(!(event.value&lt;render\the\interactiveplot@render.functions[i].param[j].ini)&amp;&amp;!(event.value&gt;render\the\interactiveplot@render.functions[i].param[j].end)){
render\the\interactiveplot@render.functions[i].param[j].value=parseFloat(event.value);
curves\the\interactiveplot@render[i].setProps({vertices:curve2d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i],frangeini\the\interactiveplot@render,frangeend\the\interactiveplot@render)});
managed\the\interactiveplot@render[managedcount\the\interactiveplot@render]=[param,render\the\interactiveplot@render.functions[i].param[j].increment,render\the\interactiveplot@render.functions[i].param[j].ini,render\the\interactiveplot@render.functions[i].param[j].end];
managedcount\the\interactiveplot@render++;
}
else{
app.alert("Value is out of range!. The correct range is between ["+render\the\interactiveplot@render.functions[i].param[j].ini+","+render\the\interactiveplot@render.functions[i].param[j].end+"]");
}
}
else if(existIn(param,managed\the\interactiveplot@render)){
if(!(event.value&lt;managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][2])&amp;&amp;!(event.value&gt;managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][3])){
render\the\interactiveplot@render.functions[i].param[j].value=parseFloat(event.value);
curves\the\interactiveplot@render[i].setProps({vertices:curve2d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i],frangeini\the\interactiveplot@render,frangeend\the\interactiveplot@render)});
}
else{
app.alert("Value is out of range!. The correct range is between ["+managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][2]+","+managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][3]+"]");
}
}
}
}
j = 0 ;
}
}
}
function existIn(value,array){
for(i=0;i&lt;array.length;i++){
if(value==array[i][0]){
return true;
}
}
return false;
}
function existInPos(value,array){
for(i=0;i&lt;array.length;i++){
if(value=array[i][0]){
return i;
}
}
return -1;
}
var managed\the\interactiveplot@render= new Array();
var managedcount\the\interactiveplot@render = 0;
function minus\the\interactiveplot@render(param,field){%this function is called she a user click the "minus" button of a parameter
var i ;
var j ;
for(i=render\the\interactiveplot@render.functions.length-1;i&gt;=0;i--){
for( j = 0 ; j &lt;render\the\interactiveplot@render.functions[i].param.length ; j ++ ){
if( param == render\the\interactiveplot@render.functions[i].param[j].name ){
if(!existIn(param,managed\the\interactiveplot@render)){
if(render\the\interactiveplot@render.functions[i].param[j].value&gt;render\the\interactiveplot@render.functions[i].param[j].ini){
render\the\interactiveplot@render.functions[i].param[j].value=render\the\interactiveplot@render.functions[i].param[j].value-render\the\interactiveplot@render.functions[i].param[j].increment;
curves\the\interactiveplot@render[i].setProps({vertices:curve2d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i],frangeini\the\interactiveplot@render,frangeend\the\interactiveplot@render)});
managed\the\interactiveplot@render[managedcount\the\interactiveplot@render]=[param,render\the\interactiveplot@render.functions[i].param[j].increment,render\the\interactiveplot@render.functions[i].param[j].ini,render\the\interactiveplot@render.functions[i].param[j].end];
managedcount\the\interactiveplot@render++;
field.value=render\the\interactiveplot@render.functions[i].param[j].value;
}
}
else if(existIn(param,managed\the\interactiveplot@render)){
if(render\the\interactiveplot@render.functions[i].param[j].value&gt;managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][2]){
render\the\interactiveplot@render.functions[i].param[j].value=render\the\interactiveplot@render.functions[i].param[j].value-managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][1];
curves\the\interactiveplot@render[i].setProps({vertices:curve2d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i],frangeini\the\interactiveplot@render,frangeend\the\interactiveplot@render)});
field.value=render\the\interactiveplot@render.functions[i].param[j].value;
}
}
}
}
j = 0 ;
}
managed\the\interactiveplot@render= new Array();
managedcount\the\interactiveplot@render = 0;
}
function plus\the\interactiveplot@render(param,field){%this function is called she a user click the "plus" button of a parameter
var i ;
var j ;
for(i=render\the\interactiveplot@render.functions.length-1;i&gt;=0;i--){
for( j = 0 ; j &lt;render\the\interactiveplot@render.functions[i].param.length ; j ++ ){
if( param == render\the\interactiveplot@render.functions[i].param[j].name ){
if(!existIn(param,managed\the\interactiveplot@render)){
if(render\the\interactiveplot@render.functions[i].param[j].value&lt;render\the\interactiveplot@render.functions[i].param[j].end){
render\the\interactiveplot@render.functions[i].param[j].value=render\the\interactiveplot@render.functions[i].param[j].value+render\the\interactiveplot@render.functions[i].param[j].increment;
curves\the\interactiveplot@render[i].setProps({vertices:curve2d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i],frangeini\the\interactiveplot@render,frangeend\the\interactiveplot@render)});
managed\the\interactiveplot@render[managedcount\the\interactiveplot@render]=[param,render\the\interactiveplot@render.functions[i].param[j].increment,render\the\interactiveplot@render.functions[i].param[j].ini,render\the\interactiveplot@render.functions[i].param[j].end];
managedcount\the\interactiveplot@render++;
field.value=render\the\interactiveplot@render.functions[i].param[j].value;
}
}
else if(existIn(param,managed\the\interactiveplot@render)){
if(render\the\interactiveplot@render.functions[i].param[j].value&lt;managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][3]){
render\the\interactiveplot@render.functions[i].param[j].value=render\the\interactiveplot@render.functions[i].param[j].value+managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][1];
curves\the\interactiveplot@render[i].setProps({vertices:curve2d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i],frangeini\the\interactiveplot@render,frangeend\the\interactiveplot@render)});
field.value=render\the\interactiveplot@render.functions[i].param[j].value;
}
}
}
}
j = 0 ;
}
managed\the\interactiveplot@render= new Array();
managedcount\the\interactiveplot@render = 0;
}
function curve2d\the\interactiveplot@render(func,min,tope) {%this function calculates all the points who defines a 2d Function graph
var y;
var x;
var sector = true;
var guarda = false;
var resolucion = Math.abs(rangini\the\interactiveplot@render-rangend\the\interactiveplot@render)/func.resolution;
var resultado = new Array();
var cont=0;
var ytope = tope;
var ymin = min;
var paramArray = new Array();
var varArray = new Array();
var arrayValues= new Array();
for(j=0;j&lt;func.param.length;j++){paramArray[j]=func.param[j].value}
for(var i = rangini\the\interactiveplot@render; i&lt;rangend\the\interactiveplot@render;i+=resolucion){
varArray[0]=i;
x=i;
y = func.Expression(varArray,paramArray) ;
var parArray = new Array();
if(!isNaN(y)){
parArray = [x,y];
arrayValues.push(parArray);
}
}
for(var i =0; i&lt;arrayValues.length;i++){
if(arrayValues[i][1]!=ytope&amp;&amp;arrayValues[i][1]!=ymin){
if(isGraphicable2d(arrayValues[i],ytope,ymin)){
if(arrayValues[i+1]!=undefined&amp;&amp;!isGraphicable2d(arrayValues[i+1],ytope,ymin)){
xaux = arrayValues[i+1][0];
yaux = arrayValues[i+1][1];
x=arrayValues[i][0];
y=arrayValues[i][1];
var modxgrande = xaux-x;
var modygrande = yaux-y;
var border;
if(yaux&gt;ytope){
var modypequena = Math.abs(ytope-y);
border=ytope;
}
else{
var modypequena = Math.abs(ymin-y);
border=ymin;
}
var porcentaje = modypequena/modygrande;
var xresult = porcentaje*modxgrande+x;
arrayValues.splice(i+1,0,[xresult,border]);
}
else if(arrayValues[i-1]!=undefined&amp;&amp;!isGraphicable2d(arrayValues[i-1],ytope,ymin)){
xaux = arrayValues[i-1][0];
yaux = arrayValues[i-1][1];
x=arrayValues[i][0];
y=arrayValues[i][1];
var modxgrande = xaux-x;
var modygrande = yaux-y;
var border;
if(yaux&gt;ytope){
var modypequena = Math.abs(ytope-y);
border=ytope;
}
else{
var modypequena = Math.abs(ymin-y);
border=ymin;
}
var porcentaje = modypequena/modygrande;
var xresult = porcentaje*modxgrande+x;
arrayValues.splice(i-1,0,[xresult,border]);
}
}
else if(!isGraphicable2d(arrayValues[i],ytope,ymin)){
if(arrayValues[i][1]&gt;ytope){
arrayValues[i]=[arrayValues[i][0],ytope];
}
else if(arrayValues[i][1]&lt;ymin){
arrayValues[i]=[arrayValues[i][0],ymin];
}
verifyRoute(arrayValues,i,ymin,ytope,rangend\the\interactiveplot@render);
}
}
}
for(var i =0; i&lt;arrayValues.length;i++){
resultado.push([centro\the\interactiveplot@render[0]+arrayValues[i][0]*proportionx\the\interactiveplot@render-TranslationConstantX\the\interactiveplot@render,centro\the\interactiveplot@render[1]+arrayValues[i][1]*proportiony\the\interactiveplot@render-TranslationConstantY\the\interactiveplot@render]);
}
return resultado;
}
this.addAnnot({ %here is inserted the box who limits all the paintable points
page: ubication\the\interactiveplot@render.page,
type: "Square",
borderEffectStyle: "C",
borderEffectIntensity: 0,
lock: true,
readOnly: true,
rect: [ubication\the\interactiveplot@render.rect[0],ubication\the\interactiveplot@render.rect[1],ubication\the\interactiveplot@render.rect[0]+\interactiveplot@naturalIplotWidth,ubication\the\interactiveplot@render.rect[1]-\interactiveplot@naturalIplotHeight],
strokeColor: color.black,
width:1.2
});
}
%%from now are managed all the buttons, labels and textfield of alls the parameters defined by te user
\setlength{\interactiveplot@CompletenaturalIplotHeight}{\interactiveplot@naturalIplotHeight pt+\baselineskip*4}
\hbox to \interactiveplot@naturalIplotWidth pt{ }
\ifx\interactiveplot@parameterlist\undefined
\xdef\interactiveplot@parameterlist{}
\fi
\vbox to \interactiveplot@CompletenaturalIplotHeight {
\xdef\interactiveplot@parameterlistcpy{\interactiveplot@parameterlist}
\@for\interactiveplot@paritem:=\interactiveplot@parameterlist\do{
\StrCount{\interactiveplot@parameterlistcpy}{\interactiveplot@paritem}[\parcount]
\ifthenelse{\parcount&gt;1}
{
\StrDel[1]{\interactiveplot@parameterlistcpy}{,\interactiveplot@paritem}[\interactiveplot@parlistaux]
\xdef\interactiveplot@parameterlistcpy{\interactiveplot@parlistaux}
}{}
}
\StrDel{\interactiveplot@parameterlistcpy}{~}[\interactiveplot@parlistaux]
\xdef\interactiveplot@parameterlist{\interactiveplot@parlistaux}
\newcount\interactiveplot@ycounter\interactiveplot@ycounter=11
\@for\interactiveplot@paritem:=\interactiveplot@parameterlist\do{
\interactiveplot@plotbuttoncaption{\interactiveplot@paritem\the\interactiveplot@render}{\interactiveplot@paritem}
\interactiveplot@plotbutton{\interactiveplot@paritem\the\interactiveplot@render}{plus}
\interactiveplot@plotbutton{\interactiveplot@paritem\the\interactiveplot@render}{minus}
\interactiveplot@fieldparamvalue{\interactiveplot@paritem\the\interactiveplot@render}
\StrCut{\interactiveplot@parameterlistvalues}{,}\interactiveplot@paritemvalue\interactiveplot@parameterlistvalues
\xdef\interactiveplot@buttonsmanage{
\interactiveplot@buttonsmanage
var   button\interactiveplot@paritem\the\interactiveplot@render = this.getField("Button\interactiveplot@paritem\the\interactiveplot@render");
var button\interactiveplot@paritem\the\interactiveplot@render plus = this.getField("Button\interactiveplot@paritem\the\interactiveplot@render plus");
var button\interactiveplot@paritem\the\interactiveplot@render minus = this.getField("Button\interactiveplot@paritem\the\interactiveplot@render minus");
var field\interactiveplot@paritem\the\interactiveplot@render = this.getField("Field\interactiveplot@paritem\the\interactiveplot@render");
var buttontextw=button\interactiveplot@paritem\the\interactiveplot@render.rect[2]-button\interactiveplot@paritem\the\interactiveplot@render.rect[0];
var buttontexth=button\interactiveplot@paritem\the\interactiveplot@render.rect[1]-button\interactiveplot@paritem\the\interactiveplot@render.rect[3];
button\interactiveplot@paritem\the\interactiveplot@render.hidden=false;
button\interactiveplot@paritem\the\interactiveplot@render minus.hidden=false;
button\interactiveplot@paritem\the\interactiveplot@render plus.hidden=false;
field\interactiveplot@paritem\the\interactiveplot@render.rect = [ubication\the\interactiveplot@render.rect[0]-25,ubication\the\interactiveplot@render.rect[1]-\the\interactiveplot@ycounter,ubication\the\interactiveplot@render.rect[0]-2,ubication\the\interactiveplot@render.rect[1]+10-\the\interactiveplot@ycounter];
button\interactiveplot@paritem\the\interactiveplot@render minus.rect=[field\interactiveplot@paritem\the\interactiveplot@render .rect[0]-12,field\interactiveplot@paritem\the\interactiveplot@render.rect[1],field\interactiveplot@paritem\the\interactiveplot@render.rect[0]-2,field\interactiveplot@paritem\the\interactiveplot@render.rect[3]];
button\interactiveplot@paritem\the\interactiveplot@render plus.rect=[button\interactiveplot@paritem\the\interactiveplot@render minus.rect[0]-11,button\interactiveplot@paritem\the\interactiveplot@render minus.rect[1],button\interactiveplot@paritem\the\interactiveplot@render minus.rect[0]-1,button\interactiveplot@paritem\the\interactiveplot@render minus.rect[3]];
button\interactiveplot@paritem\the\interactiveplot@render.rect=[button\interactiveplot@paritem\the\interactiveplot@render plus.rect[0]-buttontextw-1,button\interactiveplot@paritem\the\interactiveplot@render plus.rect[3]+buttontexth,button\interactiveplot@paritem\the\interactiveplot@render plus.rect[0]-1,button\interactiveplot@paritem\the\interactiveplot@render plus.rect[3]];
button\interactiveplot@paritem\the\interactiveplot@render minus.setAction("MouseDown","minus\the\interactiveplot@render('\interactiveplot@paritem',field\interactiveplot@paritem\the\interactiveplot@render);");
button\interactiveplot@paritem\the\interactiveplot@render plus.setAction("MouseDown","plus\the\interactiveplot@render('\interactiveplot@paritem',field\interactiveplot@paritem\the\interactiveplot@render);");
field\interactiveplot@paritem\the\interactiveplot@render.value = \interactiveplot@paritemvalue ;
field\interactiveplot@paritem\the\interactiveplot@render.textSize=6;
field\interactiveplot@paritem\the\interactiveplot@render.setAction("Keystroke","fieldChange\the\interactiveplot@render('\interactiveplot@paritem',field\interactiveplot@paritem\the\interactiveplot@render);");
button\interactiveplot@paritem\the\interactiveplot@render.delay=true;
button\interactiveplot@paritem\the\interactiveplot@render plus.delay=true;
button\interactiveplot@paritem\the\interactiveplot@render minus.delay=true;
}
\advance\interactiveplot@ycounter by 11
}
\interactiveplot@ycounter=15
\interactiveplot@pos=0
\@for\functionitem:=\interactiveplot@functionsmanage\do{
\interactiveplot@functionbutton{\the\interactiveplot@render\the\interactiveplot@pos}{\functionitem}
\xdef\interactiveplot@buttonsmanage{
\interactiveplot@buttonsmanage
var  functionButton\the\interactiveplot@render\the\interactiveplot@pos = this.getField("buttonFunctionCaption\the\interactiveplot@render\the\interactiveplot@pos");
var buttontextw\the\interactiveplot@render\the\interactiveplot@pos=functionButton\the\interactiveplot@render\the\interactiveplot@pos.rect[2]-functionButton\the\interactiveplot@render\the\interactiveplot@pos.rect[0];
var buttontexth\the\interactiveplot@render\the\interactiveplot@pos=functionButton\the\interactiveplot@render\the\interactiveplot@pos.rect[1]-functionButton\the\interactiveplot@render\the\interactiveplot@pos.rect[3];
var tabulation=(\interactiveplot@naturalIplotWidth-buttontextw\the\interactiveplot@render\the\interactiveplot@pos)/2;
functionButton\the\interactiveplot@render\the\interactiveplot@pos.hidden=false;
functionButton\the\interactiveplot@render\the\interactiveplot@pos.fillColor= color.transparent;%%%%
functionButton\the\interactiveplot@render\the\interactiveplot@pos.rect=[tabulation+ ubication\the\interactiveplot@render.rect[0],ubication\the\interactiveplot@render.rect[1]-\interactiveplot@naturalIplotHeight-\the\interactiveplot@ycounter,tabulation+ubication\the\interactiveplot@render.rect[0]+buttontextw\the\interactiveplot@render\the\interactiveplot@pos,ubication\the\interactiveplot@render.rect[3]+buttontexth\the\interactiveplot@render\the\interactiveplot@pos*2.1-\interactiveplot@naturalIplotHeight-\the\interactiveplot@ycounter];
var functionColor\the\interactiveplot@render\the\interactiveplot@pos = this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "Square",
borderEffectStyle: "C",
borderEffectIntensity: 0,
lock: true,
readOnly: true,
rect:[tabulation+ ubication\the\interactiveplot@render.rect[0]-buttontexth\the\interactiveplot@render\the\interactiveplot@pos*1.5+8,
ubication\the\interactiveplot@render.rect[1]-\interactiveplot@naturalIplotHeight-\the\interactiveplot@ycounter+2,
tabulation+ubication\the\interactiveplot@render.rect[0]-0.2,
ubication\the\interactiveplot@render.rect[3]+buttontexth\the\interactiveplot@render\the\interactiveplot@pos*2.1-\interactiveplot@naturalIplotHeight-\the\interactiveplot@ycounter-2],
strokeColor: color.black,
fillColor: color.black,
width:1.2
});
}
\advance\interactiveplot@pos by 1
\advance\interactiveplot@ycounter by 11
}
\interactiveplot@pos=0
\@for\interactiveplot@coloritem:=\interactiveplot@colormanage\do{
\xdef\interactiveplot@buttonsmanage{
\interactiveplot@buttonsmanage
functionColor\the\interactiveplot@render\the\interactiveplot@pos.setProps({
strokeColor: color.\interactiveplot@coloritem,
fillColor: color.\interactiveplot@coloritem
});
}
\advance\interactiveplot@pos by 1
}
\xdef\interactiveplot@colormanage{}
\xdef\interactiveplot@functionsmanage{}
\global\interactiveplot@pos=0
\global\interactiveplot@functions=0
\global\let\interactiveplot@parameterlist\undefined
\interactiveplot@square{\the\interactiveplot@render}
}
\catcode`\^=7
\catcode`~=13
}
%%This is the definition of environment iplotddd
\newenvironment{iplotddd}[1][]{
\global\interactiveplot@maxNumOfVar=3
\ifdef{\interactiveplot@render}{\global\advance\interactiveplot@render by 1}{\newcount\interactiveplot@render\interactiveplot@render=0 }
\setkeys{naturaliplot}{width,height,#1}
\ifthenelse{\the\interactiveplot@render=0}{
\xdef\interactiveplot@JScode{\interactiveplot@classesJS}
}
{}
\xdef\interactiveplot@JScode{\interactiveplot@JScode var render\the\interactiveplot@render = new Object(); render\the\interactiveplot@render .functions = new Array(); }

\catcode`\^=12
\catcode`\~=12
}
{
\xdef\interactiveplot@JScode{
\interactiveplot@JScode
var ubication\the\interactiveplot@render = this.getField("squareUbication\the\interactiveplot@render");
ubication\the\interactiveplot@render.hidden=true;
var i;
var j;
var BasicRangeIniVar= new Array();
var BasicRangeEndVar= new Array();
var rangini\the\interactiveplot@render;
var rangend\the\interactiveplot@render;
var curv= new Array();
for(i=0;i&lt;render\the\interactiveplot@render.functions.length;i++){
for(j=0;j&lt;render\the\interactiveplot@render.functions[i].variables.length;j++){
if(render\the\interactiveplot@render.functions[i].variables[j].ini!=undefined&amp;&amp;BasicRangeIniVar.length==0){
BasicRangeIniVar[j]=render\the\interactiveplot@render.functions[i].variables[j].ini;
}
else if(render\the\interactiveplot@render.functions[i].variables[j].ini!=undefined&amp;&amp;BasicRangeIniVar[j]==undefined){
BasicRangeIniVar[j]=render\the\interactiveplot@render.functions[i].variables[j].ini
}
else if(render\the\interactiveplot@render.functions[i].variables[j].ini!=undefined&amp;&amp;BasicRangeIniVar.length!=0&amp;&amp;render\the\interactiveplot@render.functions[i].variables[j].ini&lt;BasicRangeIniVar[j]){
BasicRangeIniVar[j]=render\the\interactiveplot@render.functions[i].variables[j].ini
}
if(render\the\interactiveplot@render.functions[i].variables[j].end!=undefined&amp;&amp;BasicRangeEndVar.length==0){
BasicRangeEndVar[j]=render\the\interactiveplot@render.functions[i].variables[j].end;
}
else if(render\the\interactiveplot@render.functions[i].variables[j].end!=undefined&amp;&amp;BasicRangeEndVar[j]==undefined){
BasicRangeEndVar[j]=render\the\interactiveplot@render.functions[i].variables[j].end;
}
else if(render\the\interactiveplot@render.functions[i].variables[j].end!=undefined&amp;&amp;BasicRangeEndVar.length!=0&amp;&amp;render\the\interactiveplot@render.functions[i].variables[j].end&gt;BasicRangeEndVar[j]){
BasicRangeEndVar[j]=render\the\interactiveplot@render.functions[i].variables[j].end;
}
}
}
for(i=0;i&lt;2;i++){
if(BasicRangeIniVar[i]==null){
BasicRangeIniVar[i]=-5;
}
if(BasicRangeEndVar[i]==null){
BasicRangeEndVar[i]=5;
}
}
for(i=0;i&lt;render\the\interactiveplot@render.functions.length;i++){
for(j=0;j&lt;render\the\interactiveplot@render.functions[i].variables.length;j++){
render\the\interactiveplot@render.functions[i].variables[j].ini=BasicRangeIniVar[j];
render\the\interactiveplot@render.functions[i].variables[j].end=BasicRangeEndVar[j];
}
}
for(i=0;i&lt;render\the\interactiveplot@render.functions.length;i++){
if(rangini\the\interactiveplot@render==undefined){
rangini\the\interactiveplot@render=render\the\interactiveplot@render.functions[i].frange.ini;
}
else if(render\the\interactiveplot@render.functions[i].frange.ini&lt;rangini\the\interactiveplot@render){
rangini\the\interactiveplot@render=render\the\interactiveplot@render.functions[i].frange.ini;
}
if(rangend\the\interactiveplot@render==undefined){
rangend\the\interactiveplot@render=render\the\interactiveplot@render.functions[i].frange.end;
}
else if(render\the\interactiveplot@render.functions[i].frange.end&gt;rangend\the\interactiveplot@render){
rangend\the\interactiveplot@render=render\the\interactiveplot@render.functions[i].frange.end;
}
}
for(i=0;i&lt;render\the\interactiveplot@render.functions.length;i++){
render\the\interactiveplot@render.functions[i].frange.ini=rangini\the\interactiveplot@render;
render\the\interactiveplot@render.functions[i].frange.end=rangend\the\interactiveplot@render;
}
var  pointx\the\interactiveplot@render = ubication\the\interactiveplot@render.rect[0];
var pointy\the\interactiveplot@render = ubication\the\interactiveplot@render.rect[1];
var  centro\the\interactiveplot@render = [pointx\the\interactiveplot@render+\interactiveplot@naturalIplotWidth/2,pointy\the\interactiveplot@render-\interactiveplot@naturalIplotHeight/2];
var cap\the\interactiveplot@render  =   this.getField("square\the\interactiveplot@render");
cap\the\interactiveplot@render.rect = [pointx\the\interactiveplot@render-4,pointy\the\interactiveplot@render+4,pointx\the\interactiveplot@render+\interactiveplot@naturalIplotWidth+4,pointy\the\interactiveplot@render-\interactiveplot@naturalIplotHeight-4];
var curves\the\interactiveplot@render=new Array();
for(i=0;i&lt;render\the\interactiveplot@render.functions.length;i++){
paintBox\the\interactiveplot@render(render\the\interactiveplot@render.functions[i]);
var annots_per_function=curve3d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i] , 0);
curves\the\interactiveplot@render[i]=new Array();
for(j=0;j&lt;annots_per_function.length;j++){
curves\the\interactiveplot@render[i][j]= this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
strokeColor: render\the\interactiveplot@render.functions[i].color,
vertices: annots_per_function[j],
lock: true,
width: 0.5,
readOnly: true
});
}
}
function fieldChange\the\interactiveplot@render(param,field){% manage the field text change
var i ;
var j ;
if(event.value!=""&amp;&amp;(event.commitKey==2||event.commitKey==3)){
for(i=render\the\interactiveplot@render.functions.length-1;i&gt;=0;i--){
for( j = 0 ; j &lt;render\the\interactiveplot@render.functions[i].param.length ; j ++ ){
if( param == render\the\interactiveplot@render.functions[i].param[j].name ){
if(!existIn(param,managed\the\interactiveplot@render)){
if(!(event.value&lt;render\the\interactiveplot@render.functions[i].param[j].ini)&amp;&amp;!(event.value&gt;render\the\interactiveplot@render.functions[i].param[j].end)){
render\the\interactiveplot@render.functions[i].param[j].value=parseFloat(event.value);
curves\the\interactiveplot@render[i].setProps({vertices:curve2d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i])});
managed\the\interactiveplot@render[managedcount\the\interactiveplot@render]=[param,render\the\interactiveplot@render.functions[i].param[j].increment,render\the\interactiveplot@render.functions[i].param[j].ini,render\the\interactiveplot@render.functions[i].param[j].end];
managedcount\the\interactiveplot@render++;
}
else{
app.alert("Value is out of range!. The correct range is between ["+render\the\interactiveplot@render.functions[i].param[j].ini+","+render\the\interactiveplot@render.functions[i].param[j].end+"]");
}
}
else if(existIn(param,managed\the\interactiveplot@render)){
if(!(event.value&lt;managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][2])&amp;&amp;!(event.value&gt;managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][3])){
render\the\interactiveplot@render.functions[i].param[j].value=parseFloat(event.value);
curves\the\interactiveplot@render[i].setProps({vertices:curve2d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i])});
}
else{
app.alert("Value is out of range!. The correct range is between ["+managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][2]+","+managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][3]+"]");
}
}
}
}
j = 0 ;
}
}
}
function existIn(value,array){
for(i=0;i&lt;array.length;i++){
if(value==array[i][0]){
return true;
}
}
return false;
}
function existInPos(value,array){
for(i=0;i&lt;array.length;i++){
if(value=array[i][0]){
return i;
}
}
return -1;
}
var managed\the\interactiveplot@render= new Array();
var managedcount\the\interactiveplot@render = 0;
function minus\the\interactiveplot@render(param,field){%manage the minus button assigned to a parameter
var i ;
var j ;
for(i=render\the\interactiveplot@render.functions.length-1;i&gt;=0;i--){
for( j = 0 ; j &lt;render\the\interactiveplot@render.functions[i].param.length ; j ++ ){
if( param == render\the\interactiveplot@render.functions[i].param[j].name ){
if(!existIn(param,managed\the\interactiveplot@render)){
if(render\the\interactiveplot@render.functions[i].param[j].value&gt;render\the\interactiveplot@render.functions[i].param[j].ini){
render\the\interactiveplot@render.functions[i].param[j].value=render\the\interactiveplot@render.functions[i].param[j].value-render\the\interactiveplot@render.functions[i].param[j].increment;
var numFunctions=render\the\interactiveplot@render.functions.length;
annots_per_function=curve3d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i], render\the\interactiveplot@render.functions[i].param[j].value);
for(jj=0;jj&lt;curves\the\interactiveplot@render[i].length;jj++){
if(typeof curves\the\interactiveplot@render[i][jj].setProps == "function"&amp;&amp;curves\the\interactiveplot@render[i][jj].hidden==false){
curves\the\interactiveplot@render[i][jj].setProps({
hidden : true,
vertices: [[0,0],[0,0]]
});
}
}
for(jj=0;jj&lt;annots_per_function.length;jj++){
if(jj&lt;curves\the\interactiveplot@render[i].length){
curves\the\interactiveplot@render[i][jj].setProps({
vertices: annots_per_function[jj],
hidden : false
});
}
else{
curves\the\interactiveplot@render[i][jj]= this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
strokeColor: render\the\interactiveplot@render.functions[i].color,
vertices: annots_per_function[jj],
lock: true,
width: 0.5,
readOnly: true
});
}
}
managedcount\the\interactiveplot@render++;
field.value=render\the\interactiveplot@render.functions[i].param[j].value;
}
}
else if(existIn(param,managed\the\interactiveplot@render)){
render\the\interactiveplot@render.functions[i].param[j].value=render\the\interactiveplot@render.functions[i].param[j].value-managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][1];
curves\the\interactiveplot@render[i].setProps({vertices:curve3d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i],-1)});
field.value=render\the\interactiveplot@render.functions[i].param[j].value;
}
}
}
j = 0 ;
}
}
function plus\the\interactiveplot@render(param,field){% here is managed the plus button assigned to a parameter
var i ;
var j ;
for(i=render\the\interactiveplot@render.functions.length-1;i&gt;=0;i--){
for( j = 0 ; j &lt;render\the\interactiveplot@render.functions[i].param.length ; j ++ ){
if( param == render\the\interactiveplot@render.functions[i].param[j].name ){
if(!existIn(param,managed\the\interactiveplot@render)){
if(render\the\interactiveplot@render.functions[i].param[j].value&lt;render\the\interactiveplot@render.functions[i].param[j].end){
render\the\interactiveplot@render.functions[i].param[j].value=render\the\interactiveplot@render.functions[i].param[j].value+render\the\interactiveplot@render.functions[i].param[j].increment;
var numFunctions=render\the\interactiveplot@render.functions.length;
annots_per_function=curve3d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i], render\the\interactiveplot@render.functions[i].param[j].value);
for(jj=0;jj&lt;curves\the\interactiveplot@render[i].length;jj++){
if(typeof curves\the\interactiveplot@render[i][jj].setProps == "function"&amp;&amp;curves\the\interactiveplot@render[i][jj].hidden==false){
curves\the\interactiveplot@render[i][jj].setProps({
hidden : true,
vertices: [[0,0],[0,0]]
});
}
}
for(jj=0;jj&lt;annots_per_function.length;jj++){
if(jj&lt;curves\the\interactiveplot@render[i].length){
curves\the\interactiveplot@render[i][jj].setProps({
vertices: annots_per_function[jj],
hidden : false
});
}
else{
curves\the\interactiveplot@render[i][jj]= this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
strokeColor: render\the\interactiveplot@render.functions[i].color,
vertices: annots_per_function[jj],
lock: true,
width: 0.5,
readOnly: true
});
}
}
managedcount\the\interactiveplot@render++;
field.value=render\the\interactiveplot@render.functions[i].param[j].value;
}
}
else if(existIn(param,managed\the\interactiveplot@render)){
render\the\interactiveplot@render.functions[i].param[j].value=render\the\interactiveplot@render.functions[i].param[j].value-managed\the\interactiveplot@render[existInPos(param,managed\the\interactiveplot@render)][1];
curves\the\interactiveplot@render[i].setProps({vertices:curve3d\the\interactiveplot@render(render\the\interactiveplot@render.functions[i],-1)});
field.value=render\the\interactiveplot@render.functions[i].param[j].value;
}
}
}
j = 0 ;
}
}
function paintBox\the\interactiveplot@render(func){% this function paint the container box of the 3D graph
var ranginix = func.variables[0].ini ;
var rangendx = func.variables[0].end ;
var ranginiy = func.variables[1].ini;
var rangendy = func.variables[1].end;
var visualValues=visualisationValues(func,\interactiveplot@naturalIplotWidth,\interactiveplot@naturalIplotHeight);
var centeringX=visualValues[0];
var centeringY=visualValues[1];
var proportionX=visualValues[2];
var proportionY=visualValues[3];
var pointLabelxini = [ranginix,ranginiy,func.frange.ini];
var pointLabelxend = [rangendx,ranginiy,func.frange.ini];
var pointLabelyini = [rangendx,ranginiy,func.frange.ini];
var pointLabelyend = [rangendx,rangendy,func.frange.ini];
var pointLabelzini = [rangendx,ranginiy,func.frange.ini];
var pointLabelzend = [rangendx,ranginiy,func.frange.end];
for(var i =0 ; i &lt; 6 ; i++ ){
if(i&lt;4){
var point_botton ;
var point_top ;
if(i==0){
var point_botton = [ranginix,ranginiy,func.frange.ini];
var point_top = [ranginix,ranginiy,func.frange.end];
}
else if(i==1){
var point_botton = [rangendx,ranginiy,func.frange.ini];
var point_top = [rangendx,ranginiy,func.frange.end];
}
else if(i==2){
var point_botton = [rangendx,rangendy,func.frange.ini];
var point_top = [rangendx,rangendy,func.frange.end];
}
else if(i==3){
var point_botton = [ranginix,rangendy,func.frange.ini];
var point_top = [ranginix,rangendy,func.frange.end];
}
var botton_rotacion = point_botton;
     botton_rotacion = matrixMultiply(Rx,botton_rotacion);
botton_rotacion = matrixMultiply(Rz,botton_rotacion);
botton_rotacion = matrixMultiply(Ry,botton_rotacion);
var auxiliar_botton = new Array();
auxiliar_botton[0] = botton_rotacion[0];
auxiliar_botton[1] = botton_rotacion[1];
auxiliar_botton[2] = botton_rotacion[2];
auxiliar_botton[3] = 1;
var aux_botton= new Array();
aux_botton=matrixMultiply(P,auxiliar_botton);
var top_rotacion = point_top ;
top_rotacion = matrixMultiply(Rx,top_rotacion);
top_rotacion = matrixMultiply(Rz,top_rotacion);
top_rotacion = matrixMultiply(Ry,top_rotacion);
var auxiliar_top = new Array();
auxiliar_top[0] = top_rotacion[0];
auxiliar_top[1] = top_rotacion[1];
auxiliar_top[2] = top_rotacion[2];
auxiliar_top[3] = 1;
var aux_top= new Array();
aux_top=matrixMultiply(P,auxiliar_top);
this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
strokeColor:color.black,
width:0.5,
vertices:[[centro\the\interactiveplot@render[0]+(aux_botton[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux_botton[1]+centeringY)*proportionY],[centro\the\interactiveplot@render[0]+(aux_top[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux_top[1]+centeringY)*proportionY]]});
if(i==0||i==1||i==2){
if(i==0||i==2){
var labelLimite1\the\interactiveplot@render = this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "FreeText",
lock: true,
style: "D",
rect: [
centro\the\interactiveplot@render[0]+(aux_botton[0]+centeringX)*proportionX+3-10,
centro\the\interactiveplot@render[1]+(aux_botton[1]+centeringY)*proportionY-19,
centro\the\interactiveplot@render[0]+(aux_botton[0]+centeringX)*proportionX+31-10,
centro\the\interactiveplot@render[1]+(aux_botton[1]+centeringY)*proportionY-5]
});
labelLimite1\the\interactiveplot@render.textSize=5;
labelLimite1\the\interactiveplot@render.alignment=0;
labelLimite1\the\interactiveplot@render.strokeColor = color.black;
labelLimite1\the\interactiveplot@render.width= 0;
if(i==0)
labelLimite1\the\interactiveplot@render.contents = ranginix.toFixed(2);
if(i==2){
labelLimite1\the\interactiveplot@render.contents = rangendy.toFixed(2);
var labelLimite2\the\interactiveplot@render = this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "FreeText",
lock: true,
style: "D",
rect: [
centro\the\interactiveplot@render[0]+(aux_botton[0]+centeringX)*proportionX+5,
centro\the\interactiveplot@render[1]+(aux_botton[1]+centeringY)*proportionY-6,
centro\the\interactiveplot@render[0]+(aux_botton[0]+centeringX)*proportionX+33,
centro\the\interactiveplot@render[1]+(aux_botton[1]+centeringY)*proportionY+9]
});
labelLimite2\the\interactiveplot@render.textSize=5;
labelLimite2\the\interactiveplot@render.alignment=0;
labelLimite2\the\interactiveplot@render.strokeColor = color.black;
labelLimite2\the\interactiveplot@render.width= 0;
labelLimite2\the\interactiveplot@render.contents = func.frange.ini.toFixed(2);
var labelLimite3\the\interactiveplot@render = this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "FreeText",
lock: true,
style: "D",
rect: [
centro\the\interactiveplot@render[0]+(aux_top[0]+centeringX)*proportionX+5,
centro\the\interactiveplot@render[1]+(aux_top[1]+centeringY)*proportionY-19,
centro\the\interactiveplot@render[0]+(aux_top[0]+centeringX)*proportionX+33,
centro\the\interactiveplot@render[1]+(aux_top[1]+centeringY)*proportionY-5]
});
labelLimite3\the\interactiveplot@render.textSize=5;
labelLimite3\the\interactiveplot@render.alignment=0;
labelLimite3\the\interactiveplot@render.strokeColor = color.black;
labelLimite3\the\interactiveplot@render.width= 0;
labelLimite3\the\interactiveplot@render.contents = func.frange.end.toFixed(2);
}
}
else if(i==1){
var labelLimite1\the\interactiveplot@render = this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "FreeText",
lock: true,
style: "D",
rect: [
centro\the\interactiveplot@render[0]+(aux_botton[0]+centeringX)*proportionX-16,
centro\the\interactiveplot@render[1]+(aux_botton[1]+centeringY)*proportionY-19,
centro\the\interactiveplot@render[0]+(aux_botton[0]+centeringX)*proportionX-3,
centro\the\interactiveplot@render[1]+(aux_botton[1]+centeringY)*proportionY-5]
});
var labelLimite2\the\interactiveplot@render = this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "FreeText",
lock: true,
style: "D",
rect: [
centro\the\interactiveplot@render[0]+(aux_botton[0]+centeringX)*proportionX+8,
centro\the\interactiveplot@render[1]+(aux_botton[1]+centeringY)*proportionY-17,
centro\the\interactiveplot@render[0]+(aux_botton[0]+centeringX)*proportionX+39,
centro\the\interactiveplot@render[1]+(aux_botton[1]+centeringY)*proportionY-3]
});
labelLimite1\the\interactiveplot@render.textSize=5;
labelLimite1\the\interactiveplot@render.alignment=0;
labelLimite1\the\interactiveplot@render.strokeColor = color.black;
labelLimite1\the\interactiveplot@render.width= 0;
labelLimite1\the\interactiveplot@render.contents = rangendx.toFixed(2);
labelLimite2\the\interactiveplot@render.textSize=5;
labelLimite2\the\interactiveplot@render.alignment=0;
labelLimite2\the\interactiveplot@render.strokeColor = color.black;
labelLimite2\the\interactiveplot@render.width= 0;
labelLimite2\the\interactiveplot@render.contents = ranginiy.toFixed(2);
}
}
}
else if(i==4){
var point0 = [ranginix,ranginiy,func.frange.end];
var point1 = [rangendx,ranginiy,func.frange.end];
var point2 = [rangendx,rangendy,func.frange.end];
var point3 = [ranginix,rangendy,func.frange.end];
var point0_rotacion = point0;
point0_rotacion = matrixMultiply(Rx,point0_rotacion);
point0_rotacion = matrixMultiply(Rz,point0_rotacion);
point0_rotacion = matrixMultiply(Ry,point0_rotacion);
var auxiliar0 = new Array();
auxiliar0[0] = point0_rotacion[0];
auxiliar0[1] = point0_rotacion[1];
auxiliar0[2] = point0_rotacion[2];
auxiliar0[3] = 1;
var aux0= new Array();
aux0=matrixMultiply(P,auxiliar0);
var point1_rotacion = point1;
          point1_rotacion = matrixMultiply(Rx,point1_rotacion);
point1_rotacion = matrixMultiply(Rz,point1_rotacion);
point1_rotacion = matrixMultiply(Ry,point1_rotacion);
var auxiliar1 = new Array();
auxiliar1[0] = point1_rotacion[0];
auxiliar1[1] = point1_rotacion[1];
auxiliar1[2] = point1_rotacion[2];
auxiliar1[3] = 1;
var aux1= new Array();
aux1=matrixMultiply(P,auxiliar1);
var point2_rotacion = point2;
point2_rotacion = matrixMultiply(Rx,point2_rotacion);
point2_rotacion = matrixMultiply(Rz,point2_rotacion);
point2_rotacion = matrixMultiply(Ry,point2_rotacion);
var auxiliar2 = new Array();
auxiliar2[0] = point2_rotacion[0];
auxiliar2[1] = point2_rotacion[1];
auxiliar2[2] = point2_rotacion[2];
auxiliar2[3] = 1;
var aux2= new Array();
aux2=matrixMultiply(P,auxiliar2);
var point3_rotacion = point3;
point3_rotacion = matrixMultiply(Rx,point3_rotacion);
point3_rotacion = matrixMultiply(Rz,point3_rotacion);
point3_rotacion = matrixMultiply(Ry,point3_rotacion);
var auxiliar3 = new Array();
auxiliar3[0] = point3_rotacion[0];
auxiliar3[1] = point3_rotacion[1];
auxiliar3[2] = point3_rotacion[2];
auxiliar3[3] = 1;
var aux3= new Array();
aux3=matrixMultiply(P,auxiliar3);
this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
strokeColor:color.black,
width:0.5,
vertices:[[centro\the\interactiveplot@render[0]+(aux0[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux0[1]+centeringY)*proportionY],[centro\the\interactiveplot@render[0]+(aux1[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux1[1]+centeringY)*proportionY],[centro\the\interactiveplot@render[0]+(aux2[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux2[1]+centeringY)*proportionY],[centro\the\interactiveplot@render[0]+(aux3[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux3[1]+centeringY)*proportionY],[centro\the\interactiveplot@render[0]+(aux0[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux0[1]+centeringY)*proportionY]]});
}
else if(i==5){
var point0 = [ranginix,ranginiy,func.frange.ini];
var point1 = [rangendx,ranginiy,func.frange.ini];
var point2 = [rangendx,rangendy,func.frange.ini];
var point3 = [ranginix,rangendy,func.frange.ini];
var point0_rotacion = point0;
   point0_rotacion = matrixMultiply(Rx,point0_rotacion);
point0_rotacion = matrixMultiply(Rz,point0_rotacion);
point0_rotacion = matrixMultiply(Ry,point0_rotacion);
var auxiliar0 = new Array();
auxiliar0[0] = point0_rotacion[0];
auxiliar0[1] = point0_rotacion[1];
auxiliar0[2] = point0_rotacion[2];
auxiliar0[3] = 1;
var aux0= new Array();
aux0=matrixMultiply(P,auxiliar0);
var point1_rotacion = point1;
   point1_rotacion = matrixMultiply(Rx,point1_rotacion);
point1_rotacion = matrixMultiply(Rz,point1_rotacion);
point1_rotacion = matrixMultiply(Ry,point1_rotacion);
var auxiliar1 = new Array();
auxiliar1[0] = point1_rotacion[0];
auxiliar1[1] = point1_rotacion[1];
auxiliar1[2] = point1_rotacion[2];
auxiliar1[3] = 1;
var aux1= new Array();
aux1=matrixMultiply(P,auxiliar1);
var point2_rotacion = point2;
   point2_rotacion = matrixMultiply(Rx,point2_rotacion);
point2_rotacion = matrixMultiply(Rz,point2_rotacion);
point2_rotacion = matrixMultiply(Ry,point2_rotacion);
var auxiliar2 = new Array();
auxiliar2[0] = point2_rotacion[0];
auxiliar2[1] = point2_rotacion[1];
auxiliar2[2] = point2_rotacion[2];
auxiliar2[3] = 1;
var aux2= new Array();
aux2=matrixMultiply(P,auxiliar2);
var point3_rotacion = point3;
   point3_rotacion = matrixMultiply(Rx,point3_rotacion);
point3_rotacion = matrixMultiply(Rz,point3_rotacion);
point3_rotacion = matrixMultiply(Ry,point3_rotacion);
var auxiliar3 = new Array();
auxiliar3[0] = point3_rotacion[0];
auxiliar3[1] = point3_rotacion[1];
auxiliar3[2] = point3_rotacion[2];
auxiliar3[3] = 1;
var aux3= new Array();
aux3=matrixMultiply(P,auxiliar3);
 this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "PolyLine",
strokeColor:color.black,
width:0.5,
vertices:[[centro\the\interactiveplot@render[0]+(aux0[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux0[1]+centeringY)*proportionY],[centro\the\interactiveplot@render[0]+(aux1[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux1[1]+centeringY)*proportionY],[centro\the\interactiveplot@render[0]+(aux2[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux2[1]+centeringY)*proportionY],[centro\the\interactiveplot@render[0]+(aux3[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux3[1]+centeringY)*proportionY],[centro\the\interactiveplot@render[0]+(aux0[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux0[1]+centeringY)*proportionY]]});
}
}
}
function curve3d\the\interactiveplot@render(func,value){%this function calculate all the graphicable function points inside the container box
var y;
var x;
var z;
var direction = true;
var resolucionx = (Math.abs(func.variables[0].ini)+Math.abs(func.variables[0].end))/func.resolution;
var resoluciony = (Math.abs(func.variables[1].ini)+Math.abs(func.variables[1].end))/func.resolution;
var maxDistance= Math.sqrt(Math.pow(resolucionx,2)+Math.pow(resoluciony,2));
var ranginix = func.variables[0].ini ;
var rangendx = func.variables[0].end ;
var ranginiy = func.variables[1].ini;
var rangendy = func.variables[1].end;
var resultado = new Array();
var paramArray = new Array();
var varArray = new Array();
var matrixValues = new Array();
for(j=0;j&lt;func.param.length;j++){paramArray[j]=func.param[j].value}
var ii=0;
var i = ranginix;
while(i&lt;=rangendx){
var jj=0;
matrixValues[ii]=new Array();
var j = ranginiy;
while( j&lt;=rangendy){
varArray[0]=i;
varArray[1]=j;
x = i ;
y = j ;
z = func.Expression(varArray,paramArray) ;
matrixValues[ii][jj]=[x,y,z];
jj++;
j+=resoluciony;
if(jj==func.resolution&amp;&amp;j&gt;rangendy){
j=rangendy;
varArray[0]=i;
varArray[1]=j;
x = i ;
y = j ;
z = func.Expression(varArray,paramArray) ;
matrixValues[ii][jj]=[x,y,z];
}
}
jj=0;
ii++;
i+=resolucionx;
if(ii==func.resolution&amp;&amp;i&gt;rangendx){
i=rangendx;
}
}
create_specialPoints(matrixValues,func);%the special points are created, they are all the border of box points and the points who have a neighbor point who is outside the box
var border_list = create_BordersLists(matrixValues);%create all the border points using the   points calculated before
var listOfSpecialPoints=new Array();
var lastEvaluatedIndex;
var indexOfLine;
var indexStack = new Array();
for(var i = 0; i&lt;matrixValues.length;i+=2){
if(direction){
var begin=0;
var end=matrixValues.length-1;
var step=1;
}
else{
var begin=matrixValues.length-1;
var end=0;
var step=-1;
}
var direction_aux=direction;
for(var j = begin;  condition(begin,end,j) ;j=j+step){%in this cycle al the points are compared with the border lines and if is the case, are adde to the array of graphic able points some border points avoiding to paint non graphic able points
if(is_Special(matrixValues[i][j])){
if(matrixValues[i][j].hasBorderY()){
if(listOfSpecialPoints[matrixValues[i][j].yId-1]==undefined){
listOfSpecialPoints[matrixValues[i][j].yId-1]=new Array();
}
listOfSpecialPoints[matrixValues[i][j].yId-1].push(matrixValues[i][j].indexYinList);
lastEvaluatedIndex=matrixValues[i][j].yId-1;
indexOfLine=lastEvaluatedIndex;
indexStack.push(lastEvaluatedIndex);
if(indexStack.length&gt;1){
if(indexStack[indexStack.length-1]!=indexStack[indexStack.length-2]){
indexStack.pop();
indexOfLine=indexStack[indexStack.length-1];
}
else{
indexStack.pop();
indexStack.pop();
}
}
if(matrixValues[i][j-1]==undefined||matrixValues[i][j+1]==undefined){
indexStack.pop();
}
if(resultado[indexOfLine]==undefined){
resultado[indexOfLine]=new Array();
}
if(listOfSpecialPoints[lastEvaluatedIndex].length==2){
printBorderList(listOfSpecialPoints,indexOfLine,lastEvaluatedIndex,resultado,border_list);
if(orderOfInsertValToBorder(matrixValues[i][j],step)){
resultado[indexOfLine].push(matrixValues[i][j].value);
resultado[indexOfLine].push(matrixValues[i][j].borderY);
}
else{
resultado[indexOfLine].push(matrixValues[i][j].borderY);
resultado[indexOfLine].push(matrixValues[i][j].value);
}
}
else{
if(orderOfInsertValToBorder(matrixValues[i][j],step)){
resultado[indexOfLine].push(matrixValues[i][j].value);
resultado[indexOfLine].push(matrixValues[i][j].borderY);
}
else{
resultado[indexOfLine].push(matrixValues[i][j].borderY);
resultado[indexOfLine].push(matrixValues[i][j].value);
}
}
}
else if(matrixValues[i][j-1]==undefined||matrixValues[i][j+1]==undefined){
if(listOfSpecialPoints[matrixValues[i][j].valId-1]==undefined){
listOfSpecialPoints[matrixValues[i][j].valId-1]=new Array();
}
listOfSpecialPoints[matrixValues[i][j].valId-1].push(matrixValues[i][j].indexValinList);
lastEvaluatedIndex=matrixValues[i][j].valId-1;
indexOfLine=lastEvaluatedIndex;
indexStack.push(lastEvaluatedIndex);
if(indexStack.length&gt;1){
if(indexStack[indexStack.length-1]!=indexStack[indexStack.length-2]){
indexStack.pop();
indexOfLine=indexStack[indexStack.length-1];
}
else{
indexStack.pop();
indexStack.pop();
}
}
if(resultado[indexOfLine]==undefined){
resultado[indexOfLine]=new Array();
}
if(lastEvaluatedIndex!=undefined&amp;&amp;listOfSpecialPoints[lastEvaluatedIndex].length==2){
printBorderList(listOfSpecialPoints,indexOfLine,lastEvaluatedIndex,resultado,border_list);
}
resultado[indexOfLine].push(matrixValues[i][j].value);
}
else{
if(listOfSpecialPoints[lastEvaluatedIndex].length==1){
listOfSpecialPoints[lastEvaluatedIndex].pop();
}
if(resultado[indexOfLine]==undefined)
resultado[indexOfLine]=new Array();
resultado[indexOfLine].push(matrixValues[i][j].value);
}
}
else if(is_graphicable(matrixValues[i][j],func)){
if(listOfSpecialPoints[lastEvaluatedIndex].length==1){
listOfSpecialPoints[lastEvaluatedIndex].pop();
}
if(resultado[indexOfLine]==undefined)
resultado[indexOfLine]=new Array();
resultado[indexOfLine].push(matrixValues[i][j]);
}
}
direction=!direction;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
resultado[resultado.length]=new Array();
var i = 0;
var j = 0;
for(i=0;i&lt;border_list.length;i++){
for(j=0;j&lt; border_list[i].list.length ; j++){
resultado[resultado.length-1].push(border_list[i].list[j]);
}
resultado[resultado.length-1].push(border_list[i].list[0]);
resultado[resultado.length]=new Array();
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Now the 3d points will be transformed to 2D graphic able points using orthogonal projection
var result2d= new Array();
result2d[0]=new Array();
var visualValues=visualisationValues(func,\interactiveplot@naturalIplotWidth,\interactiveplot@naturalIplotHeight);
var centeringX=visualValues[0];
var centeringY=visualValues[1];
var proportionX=visualValues[2];
var proportionY=visualValues[3];
for(var i=0;i&lt;resultado.length;i++){
if(resultado[i]!=undefined){
result2d[i]=new Array();
for(var j=0;j&lt;resultado[i].length;j++){
rotacion = resultado[i][j];
rotacion = matrixMultiply(Rx,resultado[i][j]);
rotacion = matrixMultiply(Rz,rotacion);
rotacion = matrixMultiply(Ry,rotacion);
var auxiliar = new Array();
auxiliar[0] = rotacion[0];
auxiliar[1] = rotacion[1];
auxiliar[2] = rotacion[2];
auxiliar[3] = 1;
var aux= new Array();
aux=matrixMultiply(P,auxiliar);%sume proportionY -50
          result2d[i].push([centro\the\interactiveplot@render[0]+(aux[0]+centeringX)*proportionX,centro\the\interactiveplot@render[1]+(aux[1]+centeringY)*proportionY]);
         }
}
}
return result2d;
}
}
%%from here are managed all the buttons, labels, textfield an function label
\setlength{\interactiveplot@CompletenaturalIplotHeight}{\interactiveplot@naturalIplotHeight pt+\baselineskip*4}
\hbox to \interactiveplot@naturalIplotWidth pt{ }
\ifx\interactiveplot@parameterlist\undefined
\xdef\interactiveplot@parameterlist{}
\fi
\vbox to \interactiveplot@CompletenaturalIplotHeight {
\xdef\interactiveplot@parameterlistcpy{\interactiveplot@parameterlist}
\@for\interactiveplot@paritem:=\interactiveplot@parameterlist\do{
\StrCount{\interactiveplot@parameterlistcpy}{\interactiveplot@paritem}[\parcount]
\ifthenelse{\parcount&gt;1}
{
\StrDel[1]{\interactiveplot@parameterlistcpy}{,\interactiveplot@paritem}[\interactiveplot@parlistaux]
\xdef\interactiveplot@parameterlistcpy{\interactiveplot@parlistaux}
}{}
}
\StrDel{\interactiveplot@parameterlistcpy}{~}[\interactiveplot@parlistaux]
\xdef\interactiveplot@parameterlist{\interactiveplot@parlistaux}
\newcount\interactiveplot@ycounter\interactiveplot@ycounter=11
\@for\interactiveplot@paritem:=\interactiveplot@parameterlist\do{
\interactiveplot@plotbuttoncaption{\interactiveplot@paritem\the\interactiveplot@render}{\interactiveplot@paritem}
\interactiveplot@plotbutton{\interactiveplot@paritem\the\interactiveplot@render}{plus}
\interactiveplot@plotbutton{\interactiveplot@paritem\the\interactiveplot@render}{minus}
\interactiveplot@fieldparamvalue{\interactiveplot@paritem\the\interactiveplot@render}
\StrCut{\interactiveplot@parameterlistvalues}{,}\interactiveplot@paritemvalue\interactiveplot@parameterlistvalues
\xdef\interactiveplot@buttonsmanage{
\interactiveplot@buttonsmanage
var  button\interactiveplot@paritem\the\interactiveplot@render = this.getField("Button\interactiveplot@paritem\the\interactiveplot@render");
var button\interactiveplot@paritem\the\interactiveplot@render plus = this.getField("Button\interactiveplot@paritem\the\interactiveplot@render plus");
var button\interactiveplot@paritem\the\interactiveplot@render minus = this.getField("Button\interactiveplot@paritem\the\interactiveplot@render minus");
var field\interactiveplot@paritem\the\interactiveplot@render = this.getField("Field\interactiveplot@paritem\the\interactiveplot@render");
var buttontextw=button\interactiveplot@paritem\the\interactiveplot@render.rect[2]-button\interactiveplot@paritem\the\interactiveplot@render.rect[0];
var buttontexth=button\interactiveplot@paritem\the\interactiveplot@render.rect[1]-button\interactiveplot@paritem\the\interactiveplot@render.rect[3];
button\interactiveplot@paritem\the\interactiveplot@render.hidden=false;
button\interactiveplot@paritem\the\interactiveplot@render minus.hidden=false;
button\interactiveplot@paritem\the\interactiveplot@render plus.hidden=false;
field\interactiveplot@paritem\the\interactiveplot@render.rect = [ubication\the\interactiveplot@render.rect[0]-25,ubication\the\interactiveplot@render.rect[1]-\the\interactiveplot@ycounter,ubication\the\interactiveplot@render.rect[0]-2,ubication\the\interactiveplot@render.rect[1]+10-\the\interactiveplot@ycounter];
button\interactiveplot@paritem\the\interactiveplot@render minus.rect=[field\interactiveplot@paritem\the\interactiveplot@render .rect[0]-12,field\interactiveplot@paritem\the\interactiveplot@render.rect[1],field\interactiveplot@paritem\the\interactiveplot@render.rect[0]-2,field\interactiveplot@paritem\the\interactiveplot@render.rect[3]];
button\interactiveplot@paritem\the\interactiveplot@render plus.rect=[button\interactiveplot@paritem\the\interactiveplot@render minus.rect[0]-11,button\interactiveplot@paritem\the\interactiveplot@render minus.rect[1],button\interactiveplot@paritem\the\interactiveplot@render minus.rect[0]-1,button\interactiveplot@paritem\the\interactiveplot@render minus.rect[3]];
button\interactiveplot@paritem\the\interactiveplot@render.rect=[button\interactiveplot@paritem\the\interactiveplot@render plus.rect[0]-buttontextw-1,button\interactiveplot@paritem\the\interactiveplot@render plus.rect[3]+buttontexth,button\interactiveplot@paritem\the\interactiveplot@render plus.rect[0]-1,button\interactiveplot@paritem\the\interactiveplot@render plus.rect[3]];
button\interactiveplot@paritem\the\interactiveplot@render minus.setAction("MouseDown","minus\the\interactiveplot@render('\interactiveplot@paritem',field\interactiveplot@paritem\the\interactiveplot@render);");
button\interactiveplot@paritem\the\interactiveplot@render plus.setAction("MouseDown","plus\the\interactiveplot@render('\interactiveplot@paritem',field\interactiveplot@paritem\the\interactiveplot@render);");
field\interactiveplot@paritem\the\interactiveplot@render.value = \interactiveplot@paritemvalue ;
field\interactiveplot@paritem\the\interactiveplot@render.textSize=6;
field\interactiveplot@paritem\the\interactiveplot@render.setAction("Keystroke","fieldChange\the\interactiveplot@render('\interactiveplot@paritem',field\interactiveplot@paritem\the\interactiveplot@render);");
button\interactiveplot@paritem\the\interactiveplot@render.delay=true;
button\interactiveplot@paritem\the\interactiveplot@render plus.delay=true;
button\interactiveplot@paritem\the\interactiveplot@render minus.delay=true;
}
\advance\interactiveplot@ycounter by 11
}
\interactiveplot@ycounter=14
\interactiveplot@pos=0
\@for\functionitem:=\interactiveplot@functionsmanage\do{
\interactiveplot@functionbutton{\the\interactiveplot@render\the\interactiveplot@pos}{\functionitem}
\xdef\interactiveplot@buttonsmanage{
\interactiveplot@buttonsmanage
var  functionButton\the\interactiveplot@render\the\interactiveplot@pos = this.getField("buttonFunctionCaption\the\interactiveplot@render\the\interactiveplot@pos");
var buttontextw\the\interactiveplot@render\the\interactiveplot@pos=functionButton\the\interactiveplot@render\the\interactiveplot@pos.rect[2]-functionButton\the\interactiveplot@render\the\interactiveplot@pos.rect[0];
var buttontexth\the\interactiveplot@render\the\interactiveplot@pos=functionButton\the\interactiveplot@render\the\interactiveplot@pos.rect[1]-functionButton\the\interactiveplot@render\the\interactiveplot@pos.rect[3];
var tabulation=(\interactiveplot@naturalIplotWidth-buttontextw\the\interactiveplot@render\the\interactiveplot@pos)/2;
functionButton\the\interactiveplot@render\the\interactiveplot@pos.hidden=false;
functionButton\the\interactiveplot@render\the\interactiveplot@pos.fillColor= color.transparent;
functionButton\the\interactiveplot@render\the\interactiveplot@pos.rect=[tabulation+ ubication\the\interactiveplot@render.rect[0],ubication\the\interactiveplot@render.rect[1]-\interactiveplot@naturalIplotHeight-\the\interactiveplot@ycounter,tabulation+ubication\the\interactiveplot@render.rect[0]+buttontextw\the\interactiveplot@render\the\interactiveplot@pos,ubication\the\interactiveplot@render.rect[3]+buttontexth\the\interactiveplot@render\the\interactiveplot@pos*2.1-\interactiveplot@naturalIplotHeight-\the\interactiveplot@ycounter];
functionButton\the\interactiveplot@render\the\interactiveplot@pos.page = ubication\the\interactiveplot@render.page;
functionButton\the\interactiveplot@render\the\interactiveplot@pos.delay=true;
var functionColor\the\interactiveplot@render\the\interactiveplot@pos = this.addAnnot({
page: ubication\the\interactiveplot@render.page,
type: "Square",
borderEffectStyle: "C",
borderEffectIntensity: 0,
lock: true,
readOnly: true,
rect:[tabulation+ ubication\the\interactiveplot@render.rect[0]-buttontexth\the\interactiveplot@render\the\interactiveplot@pos*1.5+8,
ubication\the\interactiveplot@render.rect[1]-\interactiveplot@naturalIplotHeight-\the\interactiveplot@ycounter+2,
tabulation+ubication\the\interactiveplot@render.rect[0]-0.2,
ubication\the\interactiveplot@render.rect[3]+buttontexth\the\interactiveplot@render\the\interactiveplot@pos*2.1-\interactiveplot@naturalIplotHeight-\the\interactiveplot@ycounter-2],
strokeColor: color.black,
fillColor: color.black,
width:1.2
});
}
\advance\interactiveplot@pos by 1
\advance\interactiveplot@ycounter by 11
}
\interactiveplot@pos=0
\@for\interactiveplot@coloritem:=\interactiveplot@colormanage\do{
\xdef\interactiveplot@buttonsmanage{
\interactiveplot@buttonsmanage
functionColor\the\interactiveplot@render\the\interactiveplot@pos.setProps({
strokeColor: color.\interactiveplot@coloritem,
fillColor: color.\interactiveplot@coloritem
});
}
\advance\interactiveplot@pos by 1
}
\xdef\interactiveplot@colormanage{}
\xdef\interactiveplot@functionsmanage{}
\global\interactiveplot@pos=0
\global\interactiveplot@functions=0
\global\let\interactiveplot@parameterlist\undefined
\interactiveplot@square{\the\interactiveplot@render}
}
\catcode`\^=7
\catcode`~=13
}

\xdef\interactiveplot@javascriptMathDefinitions{%this macro has the JavaScript code for most of the functions used to calculate all the grahicable points
app.runtimeHighlight = false;
function verifyRoute(arrayValues,i,ymin,ytope,xend){
if(arrayValues[i][1]==ymin&amp;&amp;arrayValues[i+1]!=undefined&amp;&amp;arrayValues[i+1][1]&gt;=ytope){
arrayValues.splice(i+1,0,[xend,ytope]);
arrayValues.splice(i+1,0,[xend,ymin]);
}
else if(arrayValues[i][1]==ytope&amp;&amp;arrayValues[i+1]!=undefined&amp;&amp;arrayValues[i+1][1]&lt;=ymin){
arrayValues.splice(i+1,0,[xend,ymin]);
arrayValues.splice(i+1,0,[xend,ytope]);
}
}
function isGraphicable2d(pto,ytope,ymin){
if(pto[1]&lt;=ytope&amp;&amp;pto[1]&gt;=ymin){
return true;
}
else{
return false;
}
}
function orderOfInsertValToBorder(pto,step){
if(step&gt;0){
if(pto.value[1]&lt;pto.borderY[1]){
return true;
}
return false;
}
else{
if(pto.value[1]&lt;pto.borderY[1]){
return false;
}
return true;
}
}
function visualisationValues(func,width,height){%this function fix all the calculated points to the proportions defined by the user
var ranginix = func.variables[0].ini ;
var rangendx = func.variables[0].end ;
var ranginiy = func.variables[1].ini;
var rangendy = func.variables[1].end;
var proportionAuxMin=new Array(ranginix,ranginiy,0);
proportionAuxMin = matrixMultiply(Rx,proportionAuxMin);
proportionAuxMin = matrixMultiply(Rz,proportionAuxMin);
proportionAuxMin = matrixMultiply(Ry,proportionAuxMin);
var proportion3dTo2dMin = new Array();
proportion3dTo2dMin[0] = proportionAuxMin[0];
proportion3dTo2dMin[1] = proportionAuxMin[1];
proportion3dTo2dMin[2] = proportionAuxMin[2];
proportion3dTo2dMin[3] = 1;
var proportion2dMin = matrixMultiply(P,proportion3dTo2dMin);
var proportionAuxMax = new Array(rangendx,rangendy,0);
proportionAuxMax = matrixMultiply(Rx,proportionAuxMax);
proportionAuxMax = matrixMultiply(Rz,proportionAuxMax);
proportionAuxMax = matrixMultiply(Ry,proportionAuxMax);
var proportion3dTo2dMax = new Array();
proportion3dTo2dMax[0] = proportionAuxMax[0];
proportion3dTo2dMax[1] = proportionAuxMax[1];
proportion3dTo2dMax[2] = proportionAuxMax[2];
proportion3dTo2dMax[3] = 1;
var proportion2dMax = matrixMultiply(P,proportion3dTo2dMax);
var horizontalModule = Math.abs(proportion2dMin[0]-proportion2dMax[0]);
var proportionX =width/(horizontalModule);
var proportionAuxMinY=new Array(ranginix,ranginiy,func.frange.ini);
proportionAuxMinY = matrixMultiply(Rx,proportionAuxMinY);
proportionAuxMinY = matrixMultiply(Rz,proportionAuxMinY);
proportionAuxMinY = matrixMultiply(Ry,proportionAuxMinY);
var proportion3dTo2dMinY = new Array();
proportion3dTo2dMinY[0] = proportionAuxMinY[0];
proportion3dTo2dMinY[1] = proportionAuxMinY[1];
proportion3dTo2dMinY[2] = proportionAuxMinY[2];
proportion3dTo2dMinY[3] = 1;
var proportion2dMinY = matrixMultiply(P,proportion3dTo2dMinY);
var proportionAuxMaxY = new Array(ranginix,rangendy,func.frange.end);
proportionAuxMaxY = matrixMultiply(Rx,proportionAuxMaxY);
proportionAuxMaxY = matrixMultiply(Rz,proportionAuxMaxY);
proportionAuxMaxY = matrixMultiply(Ry,proportionAuxMaxY);
var proportion3dTo2dMaxY = new Array();
proportion3dTo2dMaxY[0] = proportionAuxMaxY[0];
proportion3dTo2dMaxY[1] = proportionAuxMaxY[1];
proportion3dTo2dMaxY[2] = proportionAuxMaxY[2];
proportion3dTo2dMaxY[3] = 1;
var proportion2dMaxY = matrixMultiply(P,proportion3dTo2dMaxY);
var verticalModule = Math.abs(proportion2dMinY[1]-proportion2dMaxY[1]);
var proportionY =(height&gt;verticalModule*proportionX)? proportionX : height/(verticalModule);
var centeringY= -verticalModule/2-proportion2dMinY[1];
var centeringX=-horizontalModule/2 - proportion2dMin[0];
var result=new Array(centeringX,centeringY,proportionX,proportionY);
return result;
}
function borderListClass(){
this.list=new Array();
this.id;
this.isCrossed=false;
}
function printBorderList(listOfSpecialPoints,indexOfLine,lastEvaluatedIndex,resultado,border_list){%function that print all the border points between two border points
var stepBorder=1;
if( listOfSpecialPoints[lastEvaluatedIndex][0]&gt; listOfSpecialPoints[lastEvaluatedIndex][1])
stepBorder=-1;
if(resultado[indexOfLine]==undefined)
resultado[indexOfLine]=new Array();
for(var k = listOfSpecialPoints[lastEvaluatedIndex][0]; condition( listOfSpecialPoints[lastEvaluatedIndex][0], listOfSpecialPoints[lastEvaluatedIndex][1],k) ;k=k+stepBorder ){
resultado[indexOfLine].push(border_list[lastEvaluatedIndex].list[k]);
}
listOfSpecialPoints[lastEvaluatedIndex].length=0;
}
function isAccesibleByValue(input,i,j){%This function verify if an input has neighbor with the attribute valueId defined
if(is_Special(input[i][j+1])&amp;&amp;input[i][j+1].getValueId()==0){
j++;
}
else if(is_Special(input[i][j-1])&amp;&amp;input[i][j-1].getValueId()==0){
j--;
}
else if(input[i+1]!=undefined&amp;&amp;is_Special(input[i+1][j])&amp;&amp;input[i+1][j].getValueId()==0){
i++;
}
else if(input[i-1]!=undefined&amp;&amp;is_Special(input[i-1][j])&amp;&amp;input[i-1][j].getValueId()==0){
i--;
}
var result=new Array(i,j);
return result;
}
function isAccesibleByBorder(input,i,j){%This function verify if an input has neighbor with the attribute border defined
if(is_Special(input[i][j+1])&amp;&amp;(input[i][j+1].hasBorder())&amp;&amp;!input[i][j+1].wasAccesedByBorder()&amp;&amp;(input[i][j+1].getXId()==0||input[i][j+1].getYId()==0)){
j++;
}
else if(is_Special(input[i][j-1])&amp;&amp;(input[i][j-1].hasBorder())&amp;&amp;!input[i][j-1].wasAccesedByBorder()&amp;&amp;(input[i][j-1].getXId()==0||input[i][j-1].getYId()==0)){
j--;
}
else if(input[i+1]!=undefined&amp;&amp;is_Special(input[i+1][j])&amp;&amp;(input[i+1][j].hasBorder())&amp;&amp;!input[i+1][j].wasAccesedByBorder()&amp;&amp;(input[i+1][j].getXId()==0||input[i+1][j].getYId()==0)){
i++;
}
else if(input[i-1]!=undefined&amp;&amp;(is_Special(input[i-1][j]))&amp;&amp;(input[i-1][j].hasBorder())&amp;&amp;!input[i-1][j].wasAccesedByBorder()&amp;&amp;(input[i-1][j].getXId()==0||input[i-1][j].getYId()==0)){
i--;
}
else if(input[i+1]!=undefined&amp;&amp;(is_Special(input[i+1][j+1]))&amp;&amp;(input[i+1][j+1].hasBorder())&amp;&amp;!input[i+1][j+1].wasAccesedByBorder()&amp;&amp;(input[i+1][j+1].getXId()==0||input[i+1][j+1].getYId()==0)){
i++;j++;
}
else if(input[i+1]!=undefined&amp;&amp;(is_Special(input[i+1][j-1]))&amp;&amp;(input[i+1][j-1].hasBorder())&amp;&amp;!input[i+1][j-1].wasAccesedByBorder()&amp;&amp;(input[i+1][j-1].getXId()==0||input[i+1][j-1].getYId()==0)){
i++;j--;
}
else if(input[i-1]!=undefined&amp;&amp;(is_Special(input[i-1][j-1]))&amp;&amp;(input[i-1][j-1].hasBorder())&amp;&amp;!input[i-1][j-1].wasAccesedByBorder()&amp;&amp;(input[i-1][j-1].getXId()==0||input[i-1][j-1].getYId()==0)){
i--;j--;
}
else if(input[i-1]!=undefined&amp;&amp;(is_Special(input[i-1][j+1]))&amp;&amp;(input[i-1][j+1].hasBorder())&amp;&amp;!input[i-1][j+1].wasAccesedByBorder()&amp;&amp;(input[i-1][j+1].getXId()==0||input[i-1][j+1].getYId()==0)){
i--;j++;
}
var result=new Array(i,j);
return result;
}
function create_BordersLists(input){%this function creates a borderList with the input data
var listOfBorderLists=new Array();
for(var i=0 ; i &lt;input.length ; i++){
for( var j =0 ; j &lt; input[i].length ; j++ ){
if(is_Special(input[i][j])&amp;&amp;input[i][j].wasAccesed()==false){
listOfBorderLists.push(new borderListClass());
listOfBorderLists[listOfBorderLists.length-1].id=listOfBorderLists.length;
look4SpecialNeighbors(input,i,j,listOfBorderLists[listOfBorderLists.length-1]);
}
}
}
return listOfBorderLists;
}
function look4SpecialNeighbors(input,i,j,listObject){%this function looks for special neighbors for input[i][j]
var ended=false;
var SpecialCondition=false;
var ii=0;
var jj=0;
var inOut=0;
while(!ended){
ended=true;
if(input[i][j].hasBorder()==false){
input[i][j].addValuetoList(listObject);
}
if(i==0||i==input.length-1){
if(input[i][j].hasBorderY()==false){
if(input[i][j].wasAccesedByValue()==false){
input[i][j].addValuetoList(listObject);
}
else if(input[i][j].hasBorderX()){
input[i][j].addXtoList(listObject);
}
if(is_Special(input[i][j+1])&amp;&amp;input[i][j+1].wasAccesedByValue()==false){
j++;
ended=false;
}
else if(is_Special(input[i][j+1])&amp;&amp;input[i][j+1].wasAccesedByValue()==true&amp;&amp;input[i][j+1].hasBorderX()&amp;&amp;input[i][j+1].wasAccesedByBorder()==false){
j++;
ended=false;
SpecialCondition=true;
}
else if(is_Special(input[i][j-1])&amp;&amp;input[i][j-1].wasAccesedByValue()==false){
j--;
ended=false;
}
else if(is_Special(input[i][j-1])&amp;&amp;input[i][j-1].wasAccesedByValue()==true&amp;&amp;input[i][j-1].hasBorderX()&amp;&amp;input[i][j-1].wasAccesedByBorder()==false){
j--;
ended=false;
SpecialCondition=true;
}
else if(SpecialCondition==true){
SpecialCondition=false;
var indexBorder=isAccesibleByBorder(input,i,j);
if(indexBorder[0]==i&amp;&amp;indexBorder[1]==j){
ended=true;
}
else{
i=indexBorder[0];
j=indexBorder[1];
ended=false;
}
}
}
else{
if(listObject.list.length==0){
if(input[i][j].hasBorderX())
input[i][j].addXtoList(listObject);
if(input[i][j].hasBorderY())
input[i][j].addYtoList(listObject);
input[i][j].addValuetoList(listObject);
}
else{
if(listObject.list[listObject.list.length-1][0]==input[i][j].value[0]){
input[i][j].addValuetoList(listObject);
if(input[i][j].hasBorderY())
input[i][j].addYtoList(listObject);
if(input[i][j].hasBorderX())
input[i][j].addXtoList(listObject);
}
else{
if(input[i][j].hasBorderX())
input[i][j].addXtoList(listObject);
if(input[i][j].hasBorderY())
input[i][j].addYtoList(listObject);
input[i][j].addValuetoList(listObject);
}
}
var indexBorder=isAccesibleByBorder(input,i,j);
var indexValue = isAccesibleByValue(input,i,j);
if(indexValue[0]==i&amp;&amp;indexValue[1]==j){
ended=true;
if(indexBorder[0]==i&amp;&amp;indexBorder[1]==j){
ended=true;
}
else{
if(i==indexBorder[0]){
SpecialCondition=true;
}
i=indexBorder[0];
j=indexBorder[1];
ended=false;
}
}
else{
i=indexValue[0];
j=indexValue[1];
ended=false;
}
}
}
if((j==0||j==input[i].length-1)&amp;&amp;ended){
if(input[i][j].hasBorderX()==false){
if(input[i][j].wasAccesedByValue()==false){
input[i][j].addValuetoList(listObject);
}
else if(input[i][j].hasBorderY()){
input[i][j].addYtoList(listObject);
}
if(input[i+1]!=undefined&amp;&amp;is_Special(input[i+1][j])&amp;&amp;input[i+1][j].wasAccesedByValue()==false){
i++;
ended=false;
}
else if(input[i+1]!=undefined&amp;&amp;is_Special(input[i+1][j])&amp;&amp;input[i+1][j].wasAccesedByValue()==true&amp;&amp;input[i+1][j].hasBorderY()==true&amp;&amp;input[i+1][j].wasAccesedByBorder()==false){
i++;
ended=false;
SpecialCondition=true;
}
else if(input[i-1]!=undefined&amp;&amp;is_Special(input[i-1][j])&amp;&amp;input[i-1][j].wasAccesedByValue()==false){
i--;
ended=false;
}
else if(input[i-1]!=undefined&amp;&amp;is_Special(input[i-1][j])&amp;&amp;input[i-1][j].wasAccesedByValue()==true&amp;&amp;input[i-1][j].hasBorderY()==true&amp;&amp;input[i-1][j].wasAccesedByBorder()==false){
i--;
ended=false;
SpecialCondition=true;
}
else if(SpecialCondition==true){
SpecialCondition=false;
var indexBorder=isAccesibleByBorder(input,i,j);
if(indexBorder[0]==i&amp;&amp;indexBorder[1]==j){
ended=true;
}
else{
i=indexBorder[0];
j=indexBorder[1];
ended=false;
}
}
}
else{
if(listObject.list.length==0){
if(input[i][j].hasBorderY())
input[i][j].addYtoList(listObject);
if(input[i][j].hasBorderX())
input[i][j].addXtoList(listObject);
input[i][j].addValuetoList(listObject);
}
else{
if(listObject.list[listObject.list.length-1][1]==input[i][j].value[1]){
input[i][j].addValuetoList(listObject);
if(input[i][j].hasBorderX())
input[i][j].addXtoList(listObject);
if(input[i][j].hasBorderY())
input[i][j].addYtoList(listObject);
}
else{
if(input[i][j].hasBorderY())
input[i][j].addYtoList(listObject);
if(input[i][j].hasBorderX())
input[i][j].addXtoList(listObject);
input[i][j].addValuetoList(listObject);
}
}
var indexBorder=isAccesibleByBorder(input,i,j);
var indexValue = isAccesibleByValue(input,i,j);
if(indexValue[0]==i&amp;&amp;indexValue[1]==j){
ended=true;
if(indexBorder[0]==i&amp;&amp;indexBorder[1]==j){
ended=true;
}
else{
if(j==indexBorder[1]){
SpecialCondition=true;
}
i=indexBorder[0];
j=indexBorder[1];
ended=false;
}
}
else{
i=indexValue[0];
j=indexValue[1];
ended=false;
}
}
}
if((j!=0&amp;&amp;j!=input[i].length-1)&amp;&amp;(i!=0&amp;&amp;i!=input.length-1)){
addBorderPointsInOrder(input,i,j,listObject);
var index=isAccesibleByBorder(input,i,j);
if(index[0]==i&amp;&amp;index[1]==j){
ended=true;
}
else{
i=index[0];
j=index[1];
ended=false;
}
}
}
}
function insertBorderInOrderX(input,i,j,listObject){%This function insert a border point x-Axis oriented
if(listObject.list.length==0){
input[i][j].addValuetoList(listObject);
input[i][j].addXtoList(listObject);
if(input[i][j].hasBorderY()){
input[i][j].addYtoList(listObject);
input[i][j].y=true;
}
}
else{
if(listObject.list[listObject.list.length-1][1]==get_value(input[i][j])[1]){
input[i][j].addValuetoList(listObject);
input[i][j].addXtoList(listObject);
if(input[i][j].hasBorderY()){
input[i][j].addYtoList(listObject);
input[i][j].y=true;
}
}
else{
if(input[i][j].hasBorderY()){
input[i][j].addYtoList(listObject);
input[i][j].y=true;
}
input[i][j].addXtoList(listObject);
input[i][j].addValuetoList(listObject);
}
}
}
function insertBorderInOrderY(input,i,j,listObject){%this function insert a border point y-Axis oriented
if(listObject.list.length==0){
input[i][j].addYtoList(listObject);
input[i][j].addValuetoList(listObject);
}
else{
var lastPoint=listObject.list[listObject.list.length-1][1];
var valPoint=get_value(input[i][j])[1];
var borderPoint=input[i][j].getY()[1];
if(Math.abs(lastPoint-valPoint)&lt;Math.abs(lastPoint-borderPoint)){
input[i][j].addValuetoList(listObject);
input[i][j].addYtoList(listObject);
}
else{
input[i][j].addYtoList(listObject);
input[i][j].addValuetoList(listObject);
}
}
}
function addBorderPointsInOrder(input,i,j,listObject){%this function inserts the x-y border points depending of the distance they have with the inpunt[i][j] point
var aux1;
var aux2;
var boolaux1=false;
var boolaux2=false;
if(listObject.list.length==0){
if(input[i][j].hasBorderY()){
input[i][j].addYtoList(listObject);
}
if(input[i][j].hasBorderX()){
input[i][j].addXtoList(listObject);
}
}
else{
if(input[i][j].hasBorderX()){
aux1 = distance2d(listObject.list[listObject.list.length-1],input[i][j].getX());
boolaux1=true;
}
if(input[i][j].hasBorderY()){
aux2 = distance2d(listObject.list[listObject.list.length-1],input[i][j].getY());
boolaux2=true;
}
if(boolaux1==false&amp;&amp;boolaux2==true){
input[i][j].addYtoList(listObject);
}
else if(boolaux1==true&amp;&amp;boolaux2==false){
input[i][j].addXtoList(listObject);
}
else if(boolaux1==true&amp;&amp;boolaux2==true){
if(aux1&lt;aux2){
input[i][j].addXtoList(listObject);
input[i][j].addYtoList(listObject);
}
else{
input[i][j].addYtoList(listObject);
input[i][j].addXtoList(listObject);
}
}
}
}
function get_value(pto){%this function reruns the value attribute of a point if it is a special point, or the value of a point if it is represented in a normal array
if(pto==undefined){
console.println("pto undefined in function get_value");
}
if(is_Special(pto)){
return pto.value;
}
else{
return pto;
}
}
function angle(val){% this function return a valid angle
return val*Math.PI/180;
}
function is_Special(pto){%this function verify if a point is special
if(pto==undefined||pto.value==undefined){
return false;
}
return true;
}
function condition(begin,end,j){
if(begin&lt;end){
if(j&lt;=end)
return true;
return false;
}
else{
if(j&gt;=end)
return true;
return false;
}
}
function is_outAbove2d(pto,f){
if(pto&gt;f)
return true;
return false;
}
function is_outBelow2d(pto,f){
if(pto&lt;f)
return true;
return false;
}
function is_outAbove(pto,f){
if(is_Special(pto)){
if(pto.value[2]&gt;f.frange.end)
return true;
return false;
}
else{
if(pto[2]&gt;f.frange.end)
return true;
return false;
}
}
function is_outBelow(pto,f){
if(is_Special(pto)){
if(pto.value[2]&lt;f.frange.ini)
return true;
return false;
}
else{
if(pto[2]&lt;f.frange.ini)
return true;
return false;
}
}
function is_graphicable(pto,f){
if(is_Special(pto)){
if(pto.value[2]&gt;=f.frange.ini&amp;&amp;pto.value[2]&lt;=f.frange.end)
return true;
return false;
}
else{
if(pto[2]&gt;=f.frange.ini&amp;&amp;pto[2]&lt;=f.frange.end)
return true;
return false;
}
}
function create_specialPoints(matrixValues,func){%this function convert (if is the case) normal points to special points
 create_specialBorderPoints(matrixValues,func);
 create_specialPointsInY(matrixValues,func);
 create_specialPointsInX(matrixValues,func);
}
function create_specialPointsInY(matrixValues,func){%in this function the matrixValues is recorred in Y and evaluate if a point is a special point, if is the case, calculate the border point in Y
for(var i = 0; i&lt;matrixValues.length;i++){
for(var j = 0; j&lt;matrixValues[i].length;j++){
if(j&gt;0){
if(is_outAbove(matrixValues[i][j],func)&amp;&amp;is_graphicable(matrixValues[i][j-1],func)){
var modxgrande = Math.abs(get_value(matrixValues[i][j])[1]-get_value(matrixValues[i][j-1])[1]);
var modygrande = Math.abs(get_value(matrixValues[i][j])[2]-get_value(matrixValues[i][j-1])[2]);
var modypequena = Math.abs(get_value(matrixValues[i][j])[2] - func.frange.end);
var porcentaje = modypequena/modygrande;
var fixedresult = get_value(matrixValues[i][j])[1]-porcentaje*modxgrande;
if(!is_Special(matrixValues[i][j-1])){
var aux = matrixValues[i][j-1];
matrixValues[i][j-1]= new borderClass();
matrixValues[i][j-1].setValue(aux);
}
matrixValues[i][j-1].setY([get_value(matrixValues[i][j])[0],fixedresult,func.frange.end]);
}
else if(is_outAbove(matrixValues[i][j-1],func)&amp;&amp;is_graphicable(matrixValues[i][j],func)){
var modxgrande = Math.abs(get_value(matrixValues[i][j-1])[1]-get_value(matrixValues[i][j])[1]);
var modygrande = Math.abs(get_value(matrixValues[i][j-1])[2]-get_value(matrixValues[i][j])[2]);
var modypequena = Math.abs(get_value(matrixValues[i][j])[2] - func.frange.end);
var porcentaje = modypequena/modygrande;
var fixedresult = get_value(matrixValues[i][j])[1]-porcentaje*modxgrande;
if(!is_Special(matrixValues[i][j])){
var aux = matrixValues[i][j];
matrixValues[i][j]= new borderClass();
matrixValues[i][j].setValue(aux);
}
matrixValues[i][j].setY([get_value(matrixValues[i][j])[0],fixedresult,func.frange.end]);
}
else if(is_outBelow(matrixValues[i][j-1],func)&amp;&amp;is_graphicable(matrixValues[i][j],func)){
var modxgrande = Math.abs(get_value(matrixValues[i][j-1])[1]-get_value(matrixValues[i][j])[1]);
var modygrande = Math.abs(get_value(matrixValues[i][j-1])[2]-get_value(matrixValues[i][j])[2]);
var modypequena = Math.abs(get_value(matrixValues[i][j])[2] - func.frange.ini);
var porcentaje = modypequena/modygrande;
var fixedresult = get_value(matrixValues[i][j])[1]-porcentaje*modxgrande;
if(!is_Special(matrixValues[i][j])){
var aux = matrixValues[i][j];
matrixValues[i][j]= new borderClass();
matrixValues[i][j].setValue(aux);
}
matrixValues[i][j].setY([get_value(matrixValues[i][j])[0],fixedresult,func.frange.ini]);
}
else if(is_outBelow(matrixValues[i][j],func)&amp;&amp;is_graphicable(matrixValues[i][j-1],func)){
var modxgrande = Math.abs(get_value(matrixValues[i][j-1])[1]-get_value(matrixValues[i][j])[1]);
var modygrande = Math.abs(get_value(matrixValues[i][j-1])[2]-get_value(matrixValues[i][j])[2]);
var modypequena = Math.abs(get_value(matrixValues[i][j])[2] - func.frange.ini);
var porcentaje = modypequena/modygrande;
var fixedresult = get_value(matrixValues[i][j])[1]-porcentaje*modxgrande;
if(!is_Special(matrixValues[i][j-1])){
var aux = matrixValues[i][j-1];
matrixValues[i][j-1]= new borderClass();
matrixValues[i][j-1].setValue(aux);
}
matrixValues[i][j-1].setY([get_value(matrixValues[i][j])[0],fixedresult,func.frange.ini]);
}
}
}
}
}
function create_specialPointsInX(matrixValues,func){%in this function the matrixValues is recorred in X and evaluate if a point is a special point, if is the case, calculate the border point in X
for(var j = 0; j&lt;matrixValues[0].length;j++){
for(var i = 0; i&lt;matrixValues.length;i++){
if(i&gt;0){
if(is_outAbove(matrixValues[i][j],func) &amp;&amp; is_graphicable(matrixValues[i-1][j],func)){
var pto0=get_value(matrixValues[i][j]);
var pto1=get_value(matrixValues[i-1][j]);
var modxgrande = Math.abs(pto0[0]-pto1[0]);
var modygrande = Math.abs(pto0[2]-pto1[2]);
var modypequena = Math.abs(pto0[2] - func.frange.end);
var porcentaje = modypequena/modygrande;
var fixedresult = pto0[0]-porcentaje*modxgrande;
if(!is_Special(matrixValues[i-1][j])){
var aux = matrixValues[i-1][j];
matrixValues[i-1][j]= new borderClass();
matrixValues[i-1][j].setValue(aux);
}
matrixValues[i-1][j].setX([fixedresult,matrixValues[i-1][j].value[1],func.frange.end]);
}
else if(is_outAbove(matrixValues[i-1][j],func)&amp;&amp;is_graphicable(matrixValues[i][j],func)){
var pto0=get_value(matrixValues[i][j]);
var pto1=get_value(matrixValues[i-1][j]);
var modxgrande = Math.abs(pto1[0]-pto0[0]);
var modygrande = Math.abs(pto1[2]-pto0[2]);
var modypequena = Math.abs(pto0[2] - func.frange.end);
var porcentaje = modypequena/modygrande;
var fixedresult = pto0[0]-porcentaje*modxgrande;
if(!is_Special(matrixValues[i][j])){
var aux = matrixValues[i][j];
matrixValues[i][j]= new borderClass();
matrixValues[i][j].setValue(aux);
}
matrixValues[i][j].setX([fixedresult,matrixValues[i][j].value[1],func.frange.end]);
}
else if(is_outBelow(matrixValues[i-1][j],func)&amp;&amp;is_graphicable(matrixValues[i][j],func)){
var pto0=get_value(matrixValues[i-1][j]);
var pto1=get_value(matrixValues[i][j]);
var modxgrande = Math.abs(pto0[0]-pto1[0]);
var modygrande = Math.abs(pto0[2]-pto1[2]);
var modypequena = Math.abs(pto1[2] - func.frange.ini);
var porcentaje = modypequena/modygrande;
var fixedresult =pto1[0]-porcentaje*modxgrande;
if(!is_Special(matrixValues[i][j])){
var aux = matrixValues[i][j];
matrixValues[i][j]= new borderClass();
matrixValues[i][j].setValue(aux);
}
matrixValues[i][j].setX([fixedresult,matrixValues[i][j].value[1],func.frange.ini]);
}
else if(is_outBelow(matrixValues[i][j],func)&amp;&amp;is_graphicable(matrixValues[i-1][j],func)){
var pto0=get_value(matrixValues[i-1][j]);
var pto1=get_value(matrixValues[i][j]);
var modxgrande = Math.abs( pto0[0]- pto1[0]);
var modygrande = Math.abs( pto0[2]- pto1[2]);
var modypequena = Math.abs(pto1[2] - func.frange.ini);
var porcentaje = modypequena/modygrande;
var fixedresult = pto1[0]-porcentaje*modxgrande;
if(!is_Special(matrixValues[i-1][j])){
var aux = matrixValues[i-1][j];
matrixValues[i-1][j]= new borderClass();
matrixValues[i-1][j].setValue(aux);
}
matrixValues[i-1][j].setX([fixedresult,matrixValues[i-1][j].value[1],func.frange.ini]);
}
}
}
}
}
function create_specialBorderPoints(matrixValues,func){%this function create all the special border points
for(var i=0;i&lt;matrixValues.length;i++){
if(!is_Special(matrixValues[i][0])&amp;&amp;is_graphicable(matrixValues[i][0],func)){
var aux=matrixValues[i][0];
matrixValues[i][0]= new borderClass();
matrixValues[i][0].setValue(aux);
}
if(!is_Special(matrixValues[i][matrixValues[i].length-1])&amp;&amp;is_graphicable(matrixValues[i][matrixValues[i].length-1],func)){
var aux=matrixValues[i][matrixValues[i].length-1];
matrixValues[i][matrixValues[i].length-1]= new borderClass();
matrixValues[i][matrixValues[i].length-1].setValue(aux);
}
}
for(var j=0;j&lt;matrixValues[0].length;j++){
if(!is_Special(matrixValues[0][j])&amp;&amp;is_graphicable(matrixValues[0][j],func)){
var aux=matrixValues[0][j];
matrixValues[0][j]= new borderClass();
matrixValues[0][j].setValue(aux);
}
if(!is_Special(matrixValues[matrixValues.length-1][j])&amp;&amp;is_graphicable(matrixValues[matrixValues.length-1][j],func)){
var aux=matrixValues[matrixValues.length-1][j];
matrixValues[matrixValues.length-1][j]= new borderClass();
matrixValues[matrixValues.length-1][j].setValue(aux);
}
}
}
function borderClass(){%if a point is a borderClass it is a special point
this.value=new Array();
this.borderX=new Array();
this.borderY=new Array();
this.indexXinList;
this.indexYinList;
this.indexValinList;
this.val;
this.valId;
this.x;
this.xId;
this.y;
this.yId;
this.setX=setX;
function setX(pto){
this.borderX=pto;
this.x=false;
this.xId=0;
}
this.setY=setY;
function setY(pto){
this.borderY=pto;
this.y=false;
this.yId=0;
}
this.setValue=setValue;
function setValue(pto){
this.value=pto;
this.val=false;
this.valId=0;
}
this.getX=getX;
function getX(){
return this.borderX;
}
this.getY=getY;
function getY(){
return this.borderY;
}
this.getValue=getValue;
function getValue(){
return this.value;
}
this.checkX=checkX;
function checkX(){
return this.x;
}
this.checkY=checkY;
function checkY(){
return this.y;
}
this.checkValue=checkValue;
function checkValue(){
return this.val;
}
this.addXtoList=addXtoList;
function addXtoList(listObject){
this.xId=listObject.id;
this.x=true;
listObject.list.push(this.borderX);
this.valId=listObject.id;
this.indexXinList=listObject.list.length-1;
}
this.addYtoList=addYtoList;
function addYtoList(listObject){
this.yId=listObject.id;
this.y=true;
listObject.list.push(this.borderY);
this.valId=listObject.id;
this.indexYinList=listObject.list.length-1;
}
this.addValuetoList=addValuetoList;
function addValuetoList(listObject){
this.valId=listObject.id;
this.val=true;
listObject.list.push(this.value);
this.indexValinList=listObject.list.length-1;
}
this.getXId=getXId;
function getXId(){
return this.xId;
}
this.getYId=getYId;
function getYId(){
return this.yId;
}
this.getValueId=getValueId;
function getValueId(){
return this.valId;
}
this.wasAccesed=wasAccesed;
function wasAccesed(){
if(this.valId==0&amp;&amp;(this.xId==0||this.yId==0||(this.xId==undefined&amp;&amp;this.yId==undefined))){
return false;
}
return true;
}
this.wasAccesedByValue=wasAccesedByValue;
function wasAccesedByValue(){
if(this.valId==0){
return false;
}
else{
return true;
}
}
this.wasAccesedByBorder=wasAccesedByBorder;
function wasAccesedByBorder(){
if(this.xId==0||this.yId==0||(this.xId==undefined&amp;&amp;this.yId==undefined)){
return false;
}
else{
return true;
}
}
this.wasAccesedByBorderY=wasAccesedByBorderY;
function wasAccesedByBorderY(){
if(this.yId==0||this.yId==undefined){
return false;
}
else{
return true;
}
}
this.wasAccesedByBorderX=wasAccesedByBorderX;
function wasAccesedByBorderX(){
if(this.xId==0||this.xId==undefined){
return false;
}
else{
return true;
}
}
this.hasBorder=hasBorder;
function hasBorder(){
if(this.borderX.length!=0||this.borderY.length!=0){
return true;
}
else{
return false;
}
}
this.hasBorderX=hasBorderX;
function hasBorderX(){
if(this.borderX.length==0){
return false;
}
else{
return true;
}
}
this.hasBorderY=hasBorderY;
function hasBorderY(){
if(this.borderY.length==0){
return false;
}
else{
return true;
}
}
}
function substracX(point1,point2){
return Math.round(Math.abs(point2[0]-point1[0])*100)/100;
}
function substracY(point1,point2){
return Math.abs(point2[1]-point1[1]);
}
function distance2d(point1,point2){
return Math.sqrt(Math.pow((point2[0]-point1[0]),2)+Math.pow((point2[1]-point1[1]),2));
}
function containedIn(array,item){
for(var i = 0; i &lt; array.length ; i++){
if(array[i]!=undefined&amp;&amp;array[i][0]==item[0]&amp;&amp;array[i][1]==item[1]&amp;&amp;array[i][2]==item[2]){
return true;
}
}
return false;
}
function matrixMultiply(matrix1,matrix2){
     if(matrix1[0].length != matrix2.length)
return undefined;
var result = new Array();
for (var i = 0; i &lt; matrix1.length; i++) {
   result[i] = new Array();
   for (var j = 0; j &lt; 1; j++) {
             var sum = 0;
             for (var k = 0; k &lt; matrix1[0].length; k++) {
         sum += matrix1[i][k] * matrix2[k];
             }
             result[i] = sum;
           }
}
return result;
}
function acot(input){
return Math.atan(1/input);
}
function acsc(input){
return Math.asin(1/input);
}
function asec(input){
return Math.acos(1/input);
}
function asech(input){
return acosh(1/input);
}
function acsch(input){
return asinh(1/input);
}
function csch(input){
return 1/sinh(input);
}
function sech(input){
return 1/cosh(input);
}
function sinh(input) {
var e=Math.E;
var p=Math.pow(e,input);
var n=1/p;
return (p-n)/2;
}
function cosh(input) {
var e=Math.E;
var p=Math.pow(e,input);
var n=1/p;
return (p*1+n*1)/2;
}
function tanh(input) {
var s=sinh(input);
var c=cosh(input);
return s/c;
}
function coth(input) {
return 1/tanh(input);
}
function asinh(input) {
var L=input*1+Math.sqrt(input*input+1);
return Math.log(L);
}
function acosh(input) {
var L=input*1+Math.sqrt(input*input-1);
return Math.log(L);
}
function atanh(input) {
var L=(1+input*1)/(1-input);
return Math.log(L)/2;
}
function acoth(input) {
return 1/atanh(input);
}
var alpha=0;
var beta=angle(10);%10
var gama=angle(60);%60
var left = - 2;
var right = 2 ;
var top =   2 ;
var bottom = -2 ;
var far =  2;
var near =  -2;
var rotacion= new Array();
var Rx = new Array ( [1, 0, 0 ],
[0, Math.cos(alpha), -Math.sin(alpha) ],
[0, Math.sin(alpha), Math.cos(alpha) ]);
var Ry = new Array ( [Math.cos(beta), 0, Math.sin(beta) ],
[0, 1, 0 ],
[-Math.sin(beta), 0, Math.cos(beta) ]);
var Rz = new Array ( [Math.cos(gama), -Math.sin(gama), 0 ],
[Math.sin(gama), Math.cos(gama), 0 ],
[0, 0, 1, ]);
var P   = new Array ( [0, 2/(top-bottom), 0, -(top+bottom)/(top-bottom) ],
[0, 0, 2/(far-near), -(far+near)/(far-near) ],
[2/(right-left), 0, 0, -(right+left)/(right-left) ],
[0, 0, 0, 1 ]);
}
\xdef\interactiveplot@boxes{
var auxiliarlinescount=0;
this.syncAnnotScan();
var box=this.getAnnots();
var boxsidecount=0;
}
\AtEndDocument {
\ifdef{\interactiveplot@JScode}{
\interactiveplot@insertobj{render}{  &lt;&lt; /S /JavaScript /JS ( \interactiveplot@javascriptMathDefinitions\interactiveplot@boxes\interactiveplot@JScode \interactiveplot@buttonsmanage )  &gt;&gt;  }
\pdfnames{%
/JavaScript &lt;&lt; /Names [ (iplot) \interactiveplot@oref{render} ] &gt;&gt;
}
}{}
}
\endinput
%%
%% End of file `interactiveplot.sty'.
</pre></body></html>