summaryrefslogtreecommitdiff
path: root/texmf-dist/doc/latex/acroflex/examples/afgraph.tex
blob: 62d8be729af57cac9fa64e17f4224c21b6e3000c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
\documentclass{article}
\usepackage{amsmath}
\usepackage[%
    web={pro,tight,usesf},
    eforms,exerquiz,dljslib={ImplMulti},
    graphicxsp={showembeds}
]{aeb_pro}
\usepackage{acroflex}
\usepackage{wrapfig}

\margins{.25in}{.25in}{24pt}{.25in} % left,right,top, bottom
\screensize{5in}{5.5in}             % height, width dimensions


\DeclareDocInfo
{
    title=\texorpdfstring{{\AcroFLeX}}{AcroFleX} Graphing System,
    author=D. P. Story,
    university=Acro\negthinspace\TeX.Net,
    email=dpstory@acrotex.net,
    subject=Demo of the acroflex and the rmannot package,
    keywords={Adobe Acrobat, JavaScript, Adobe FLEX 3, ActionScript},
    talksite=\url{http://www.acrotex.net},
    talkdate={July 2008},
    copyrightStatus=True,
    copyrightNotice={Copyright (C) \the\year, D. P. Story},
    copyrightInfoURL=http://www.acrotex.net
}
\talkdateLabel{Published:}

\setWindowOptions{showtitle}

\requiredVersionMsg{%
    Version 9 required: This document may be viewed, but version 9
    of Acrobat/Adobe Reader is required to view the rich media
    annotations present in this document.}
\requiredVersionMsgRedirect{%
    Version 9 required: This document may be viewed, but version 9
    of Acrobat/Adobe Reader is required to view the rich media
    annotations present in this document.}
\requiresVersion[warnonly]{9}

\def\AcroTeX{Acro\!\TeX}
\def\myURL{http://www.math.uakron.edu/\string~dpstory}
%
% The following definitions are for the rmannot package.
% The \saveNamedPath associates the name AcroAd with the
% path to a Flash animation, Acro_Advertiser.swf.
% The two \makePoster definitions are for the posters of the
% rich media annotations. The first for the animation on page 1
% and the second for all the AcroFlex graphing screens.
\newcommand{\myRMFiles}{C:/Users/Public/Documents/My TeX Files/%
    tex/latex/aeb/aebpro/rmannot/RMfiles}
\saveNamedPath{AcroAd}{\myRMFiles/Acro_Advertiser.swf}
%
% See the rmannot documentation. You can create your own
% poster graphic and declare it in the preamble.
%
\makePoster[hiresbb]{aflogo}{aflogo}
\makePoster[hiresbb]{AcroAd_poster}{AcroAd_poster}

\parindent=0pt
\pagestyle{empty}   %\previewtrue
\def\graphAndControls{\kern0pt\noindent
    \graphScreen[poster=aflogo]{\hScreenGraph}{\vScreenGraph}\\[1ex]
    \makebox[\hScreenGraph][l]{%
        \savedelSelBtn[\textSize{7}\CA{S}]{9bp}{11bp}\kern1bp
        \functionSelect{50bp}{11bp}\hfill
        \funcInputField{\hScreenGraph-50bp-6bp-9bp}{11bp}%
    }\\[1ex]
    \makebox[\hScreenGraph][c]{\scriptsize
        \graphBtn[\textSize{7}]{}{9bp}\kern1pt
        \graphClrBtn[\textSize{7}]{}{9bp}\hfill
        \hShiftL{\raisebox{1bp}{\reflectbox{\ding{220}}}}\,%
        \vShiftU{\raisebox{1bp}{\rotatebox{90}{\ding{220}}}}\,\,%
        \amtShift[\textSize{7}]{12bp}{9bp}\,\,%
        \vShiftD{\raisebox{1bp}{\rotatebox[origin=c]{-90}{\ding{220}}}}
        \hShiftR{\raisebox{1bp}{\ding{220}}}\enspace
        \hfill\zoomInOut[\textSize{7}]{}{9bp}%
    }\\[1pt]%
    \makebox[\hScreenGraph][l]{\scriptsize
        $x = $ \strut\domMin[\textSize{7}]{36bp}{9bp}\ldots
            \domMax[\textSize{7}]{36bp}{9bp}\hfill
        $n = $\numPoints[\textSize{7}]{16bp}{9bp}
    }\\[1pt]%
    \makebox[\hScreenGraph][l]{\scriptsize
        $y = $ \rngMin[\textSize{7}]{36bp}{9bp}\ldots
            \rngMax[\textSize{7}]{36bp}{9bp}%
    }\\[1pt]%%
    \makebox[\hScreenGraph][l]{\scriptsize
        $t = $ \strut\domMinP[\textSize{7}]{36bp}{9bp}\ldots
            \domMaxP[\textSize{7}]{36bp}{9bp}%
    }
\par
}
%
% Display an advertisement on the opening page through the
% \optionalPageMatter command.
%
\optionalPageMatter{%
\begin{center}
\begin{minipage}{.7\linewidth}
    \resizebox{\linewidth}{!}{%
        \rmAnnot[poster=AcroAd_poster,enabled=pageopen]{612bp}{265bp}{AcroAd}}%
\end{minipage}
\end{center}
}

\begin{document}

\maketitle

\parskip6pt
\begin{center}
    \large\bfseries\color{blue} What is {\AcroFLeX}?
\end{center}

The word \textbf{\AcroFLeX} is meant to convey a merging of two computer technologies:
 \begin{itemize}
 \item \textbf{Acro}: connotes both \textbf{Adobe Acrobat} (\textbf{Adobe Reader})
  and \textbf{{Acro\negthinspace\TeX}} (as in the
 \textbf{{Acro\negthinspace\TeX} eDucation Bundle} or, just \textbf{AeB}).
 \item \textbf{F\kern-.1667em\lower.5ex\hbox{L}\kern-.3eme\kern-.125emX\@}: connotes
       \textbf{Adobe FLEX 3}. FLEX 3 is used to create SWF files to interact with the user.
       In the case of graphing, plotting information is passed from Acrobat, via JavaScript,
       to the Flash widget. ActionScript takes the data, plots the points provided, and
       connects them with a smooth curve.
 \end{itemize}

\textbf{\textcolor{blue}{{\AcroFLeX} by Acro\!\TeX:}} This graphing
system and this demonstration file were developed by D.~P. Story
using the \href{http://www.ctan.org/pkg/acrotex}{{Acro\!\TeX} eDucation
Bundle}, \href{http://www.adobe.com/products/acrobat/}
{$\text{Adobe}^{\text{\tiny\circledR}}$
$\text{Acrobat}^{\text{\tiny\circledR}}$~9 Pro}, and
\href{http://www.adobe.com/products/flex/}{$\text{Adobe}^{\text{\tiny\circledR}}$
$\text{FLEX}^{\text{\tiny TM}}$~3}.

Acrobat 9 Pro introduces the rich media annotation that plays FLV
movies and SWF files natively. Acrobat also provides a scripting
bridge between JavaScript for Acrobat, and ActionScript, the
scripting language of Flash player. This bridge enables the PDF and
the Flash widget, embedded in the rich media annotation, to
communicate. The scripting bridge opens up wonderful opportunities
for application to the education sector. The graphing of {\AcroFLeX}
is one such application of the new PDF-Flash connection to
education.

\textbf{{\AcroFLeX}} uses the commercial product Adobe FLEX
Builder~3 and   FLEX~3 SDK to produce Flash widgets, and the AeB to
create PDF documents with appropriate JavaScript to communicate with
the Flash widget. FLEX Builder~3 is currently free for students and
educators, the FLEX 3 SDK is free to all.

\newpage
\parskip0pt

% Basic parameters. These are the graphing screen dimensions you wish
% for the AcroFleX graphing widget, and the \graphName is the base name used by
% all the supporting components to the graphing screen.

\dimScreenGraph{186bp}{186bp*3/4}
\graphName{graph1}

\begin{center}\bfseries\Large\color{blue}
    {\AcroFLeX} by {\AcroTeX}
\end{center}

\medskip
The first goal in {\AcroFLeX} development was to build an interactive graphing
screen educators could  use in their PDFs.
\medskip

\begin{minipage}[t]{\hScreenGraph + 10bp}
%
% Insert the \graphScreen with all possible controls. Plot data entered by the
% user is interactive mode.
\graphAndControls
\medskip
%
% Pass plot data to this graphing screen, and allow user to interact with it.
%
\makebox[\linewidth][c]{\textbf{Populate Mode}}
Parametric Equations: \sgraphLink{xInterval={[-1,1]},yInterval={[-1,1]},tInterval={[0,2*pi]},
    points=40,populate=true}{cos(t);sin(t)}{$x=\cos(t)$; $y=\sin(t)$}\\[1ex]
Polar Function: \sgraphLink{type=polar,xInterval={[-1.5,1.5]},yInterval={[-1,2]},tInterval={[0,2*pi]},
    points=60,populate=true}{1+sin(t)}{$r = 1 + \sin(\theta)$ }
\end{minipage}\hfill
\begin{minipage}[t]{\linewidth - \hScreenGraph - 10bp}\small\par
\textbf{\textcolor{red}{Instructions:}} This graphing system can graph
a function of $x$, a pair of parametric functions of $t$,
or a polar function of $t$.
\begin{questions}
    \item For a function of $x$, enter an algebraic expression to be graphed, e.g.,
        \verb!3x^2-1!, \verb!4sin(2x)!, \verb!ln(x)!,
        \verb!e^(x+1)!. For parametric equations, two functions of
        $t$ separated by a semicolon (;) e.g.,
        \texttt{cos(t);sin(t)}. For a polar function, enter a single
        expression that is a function of $t$, e.g.,
        \texttt{1+sin(t)}.
    \item Set the graph viewing window: The range of the horizontal
        axis ($x$-axis) and range of the vertical axis ($y$-axis).
        For parametric plotting, set the range of the $t$ variable.
    \item Enter the number of points, $n$, to plot.
    \item Click the \textsf{Graph It!} button.
    \item Shift the viewing window horizontally or vertical;
    or zoom in or out.
    \item Click \texttt{Clear} to clear the plot; use
         \textsf{shift-click} to deactivate the graphing screen.
\end{questions}
\end{minipage}

\def\DomX{[0,2pi]}\def\DomY{[-1,1+.2]}

%\end{document}

\newpage
\graphName{graph2}
\begin{center}
    {\large\textbf{\textcolor{blue}{Graphing Predefined Functions}}}\\[3ex]
    \graphScreen[poster=aflogo]{\hScreenGraph}{\vScreenGraph}\par\smallskip
    \makebox[\hScreenGraph][c]{\small\graphClrBtn{}{11bp}}
\end{center}

\begin{center}
    \rule{.67\linewidth}{.4pt}
\end{center}
The document author, that's you, can prepare some functions for the student to view:
\sgraphLink{xInterval={\DomX},yInterval={\DomY},points=40}{sin(x)}{$\sin(x)$},
\sgraphLink{xInterval={\DomX},yInterval={\DomY},points=80}{sin(2x)}{$\sin(2x)$},
\sgraphLink{xInterval={\DomX},yInterval={\DomY},points=100}{sin(3x)}{$\sin(3x)$}, and
\sgraphLink{xInterval={\DomX},yInterval={\DomY},points=100}{sin(4x)}{$\sin(4x)$}.
All functions are graphed over the interval
$[\,0, 2\pi\,]$. Let's view a graph with a vertical asymptote, shall we?
Try \sgraphLink{xInterval={[.5,1.5]},yInterval={[-20,20]},points=200}{1/(x-1)}{$y = 1/(x-1)$}
and \sgraphLink{xInterval={[0,2]},yInterval={[0,20]},points=200}{1/(x-1)^2}{$y = 1/(x-1)^2$}.

\smallskip
\begin{center}
    \rule{.67\linewidth}{.4pt}
\end{center}
\begin{shortquiz}
What type of symmetry does the \sgraphLink{xInterval={[-pi,pi]},yInterval={[-1,1]},
points=40}{sin(x)}{function}, graphed above, have?
\begin{answers}{3}
\Ans0 $x$-axis symmetry & \Ans0 $y$-axis symmetry & \Ans1 origin symmetry
\end{answers}
\end{shortquiz}

\newpage
\graphName{graph3}

\begin{center}
    {\large\textbf{\textcolor{blue}{Multiple Curves and Plots}}}\\[3ex]
    \graphScreen[poster=aflogo]{\hScreenGraph}{\vScreenGraph}\par\smallskip
    \makebox[\hScreenGraph][c]{\small\graphClrBtn{}{11bp}}
\end{center}

\smallskip
\begin{center}
    \rule{.67\linewidth}{.4pt}
\end{center}

Plot multiple curves using predefined functions:
\begin{itemize}
    \item \sgraphLink{graph=c1,xInterval={\DomX},yInterval={\DomY},points=40}{sin(x)}{$\sin(x)$},
        \sgraphLink{graph=c2,xInterval={\DomX},yInterval={\DomY},points=80}{sin(2x)}{$\sin(2x)$},
        \sgraphLink{graph=c3,xInterval={\DomX},yInterval={\DomY},points=100}{sin(3x)}{$\sin(3x)$},
        \sgraphLink{graph=c4,xInterval={\DomX},yInterval={\DomY},points=100}{sin(4x)}{$\sin(4x)$}.
\end{itemize}

Let's plot some points:
\begin{itemize}

\item Points on \sgraphLink{graph=p1,xInterval={\DomX},yInterval={\DomY}}{(0,sin(0));(pi/2,sin(pi/2));(pi,sin(pi));(3pi/2,sin(3pi/2));(2pi,sin(2pi))}{$\sin(x)$}
(clear the graphing screen, click on this \sgraphLink{graph=c1,xInterval={\DomX},yInterval={\DomY},points=40}{sin(x)}{$\sin(x)$}
link, then click on the plotted points link)


\item Plot \sgraphLink{graph=p2,xInterval={\DomX},yInterval={\DomY}}{(1,1);(2,-1);(4,1/3);(3,-1/2)}
    {$(1,1); (2,-1); (4,1/3); (3,-1/2)$}

\item Plot \sgraphLink{graph=c2,connectwith=segment,xInterval={\DomX},yInterval={\DomY}}{(2,0);(1,-1);(3,.5);(4,1);(6,0)}
    {$(2,0);(1,-1);(3,.5);(4,1);(6,0)$}

\end{itemize}

\newpage

\graphName{graph4}

\begin{center}
    {\large\textbf{\textcolor{blue}{Graphing in a Floating Window}}}
\end{center}

\begin{wrapfigure}[3]{l}{40bp}%
\vspace{-\baselineskip}
\iconFloatGraphScreen[poster=aflogo]{40bp}{!}
\end{wrapfigure}%
On this page, we take a different approach, by graphing functions
in a \textsl{floating window}. This might be appropriate for graphing
preset functions. Now let's copy and paste some of the previous text
here: The document author, that's you, can prepare some functions
for the student to view:
\sgraphLink{xInterval={\DomX},yInterval={\DomY},points=40}{sin(x)}{$\sin(x)$},
\sgraphLink{xInterval={\DomX},yInterval={\DomY},points=80}{sin(2x)}{$\sin(2x)$},
\sgraphLink{xInterval={\DomX},yInterval={\DomY},points=100}{sin(3x)}{$\sin(3x)$}, and
\sgraphLink{xInterval={\DomX},yInterval={\DomY},points=100}{sin(4x)}{$\sin(4x)$}.
All functions are graphed over the interval
$[\,0, 2\pi\,]$. Let's view a graph with a vertical asymptote, shall we?
Try \sgraphLink{xInterval={[.5,1.5]},yInterval={[-20,20]},points=200}{1/(x-1)}{$y = 1/(x-1)$}
and \sgraphLink{xInterval={[0,2]},yInterval={[0,20]},points=200}{1/(x-1)^2}{$y = 1/(x-1)^2$}.


\makebox[\linewidth][c]{\rule{.67\linewidth}{.4pt}}

\parskip6pt

\paragraph*{Controlling the Floating Window.} Clicking a graphing
link will open the floating window and graph the defined function.
Clicking the {\AcroFLeX} icon closes the window. The window itself
has controls. The clicking the upper-right corner closes the window.
Use the lower-left corner to resize the graph window (click and drag
the lower-left corner). Click and drag anywhere else on the boundary
will move the window.

\makebox[\linewidth][c]{\rule{.67\linewidth}{.4pt}}

The following quiz integrates the quiz/shortquiz environment with
the {\AcroFLeX} Graphing routines, and uses \texttt{\string\defineGraphJS}
to graph the input of the user.

\begin{oQuestion}{afGraphQuiz}
\defineGraphJS{graph=c3,xInterval={[-1,3]},yInterval={[-1,9]},
    noquotes,points=40}{event.value}{\myGraph}%
\textbf{\textcolor{red}{Question}} Find the equation of the line
tangent to the \sgraphLink{xInterval={[-1,3]},
yInterval={[-1,9]},points=40}{2x^2}{graph of $f(x) = 2x^2 $} at the
\sgraphLink{graph=p1,xInterval={[-1,3]},yInterval={[-1,9]}}{(1,2)}
    {point $ (1,2) $}. \RespBoxMath[%
    \AddAAKeystroke{if (retn != null){\r\myGraph}}]
    {4x-2}{4}{.0001}{[-1,3]}\hfill\CorrAnsButton{4x-2}\kern1bp\sqClearButton

\end{oQuestion}

\defineGraphJS{graph=c1,wait,xInterval={\DomX},yInterval={\DomY},
    points=40}{sin(x)}{\mySineCurve}
\defineGraphJS{graph=p1,wait,xInterval={\DomX},yInterval={\DomY}}
    {(0,sin(0));(pi/2,sin(pi/2));(pi,sin(pi));(3pi/2,sin(3pi/2));
    (2pi,sin(2pi))}{\mySinePoints}

Below is another example of the use of
\texttt{\string\defineGraphJS}. A link is created with two calls to
the graphing routines, one to plot a sine curve, the other to plot
points on that curve.
\setLinkText[\A{\JS{%
    \clearGraphJS\r
    \mySineCurve\r
    \mySinePoints
}}]{Consider the sine function, and indicated points}%


\newpage

\graphName{graph5}

\begin{center}
    {\large\textbf{\textcolor{blue}{Curves with filled area}}}\\[3ex]
    \graphScreen[poster=aflogo]{\hScreenGraph}{\vScreenGraph}\par\smallskip
    \makebox[\hScreenGraph][c]{\small\graphClrBtn{}{11bp}}
\end{center}

Plot multiple curves using predefined functions:\\
\begin{minipage}[t]{.5\linewidth-10pt}\kern0pt
\begin{itemize}
    \item \sgraphLink{graph=a1,xInterval={\DomX},yInterval={\DomY},points=40}{sin(x)}{$\sin(x)$},
        \sgraphLink{graph=a2,xInterval={\DomX},yInterval={\DomY},points=80}{sin(2x)}{$\sin(2x)$},
        \sgraphLink{graph=a3,xInterval={\DomX},yInterval={\DomY},points=100}{sin(3x)}{$\sin(3x)$},
        \sgraphLink{graph=a4,xInterval={\DomX},yInterval={\DomY},points=100}{sin(4x)}{$\sin(4x)$}.
        \item Parametric Equations
            \begin{itemize}
                \item \sgraphLink{graph=a1,xInterval={[-1,1]},yInterval={[-1,1]},tInterval={[0,2*pi]},
                        points=40}{cos(t);sin(t)}{$x=\cos(t)$; $y=\sin(t)$}
                \item \sgraphLink{graph=a3,xInterval={[0,4]},yInterval={[-2,2]},tInterval={[-2,2]},
                        points=40}{t^2;t}{$x=t^2$; $y=t$}
            \end{itemize}
\end{itemize}
\end{minipage}\hfill\begin{minipage}[t]{.5\linewidth-10pt}\kern0pt
\begin{itemize}
        \item Polar Functions
            \begin{itemize}
                \item \sgraphLink{graph=a2,type=polar,xInterval={[-1.5,1.5]},yInterval={[-1,2.3]},tInterval={[0,2pi]},
            points=60}{1+sin(t)}{$ r = 1 + \sin(\theta) $ }
                \item \sgraphLink{graph=a4,type=polar,xInterval={[-1.5,1.5]},yInterval={[-1,2.3]},tInterval={[0,2pi]},
            points=60}{1+1.25sin(t)}{$r = 1 + 1.25\sin(\theta)$ }
            \end{itemize}
\end{itemize}
\end{minipage}

\begin{oQuestion}{afAreaQuiz}
\textbf{\textcolor{red}{Question}} Find the area of the region
\emph{below} the graph of \sgraphLink{graph=a1,xInterval={[0,pi/2]},
yInterval={[0,1.1]}, points=40}{cos(x)}{$ f(x) = \cos(x) $} and
\emph{above} the graph of \sgraphLink{graph=a2,
xInterval={[0,pi/2]}, yInterval={[0,1.1]}, points=40}{sin(x)}{$ g(x)
= \sin(x) $},
as shown in the graph screen above.\\[1ex]
\RespBoxMath{sqrt(2)-1}{1}{.0001}{[0,1]}\hfill\CorrAnsButton{sqrt(2)-1}\kern1bp\sqClearButton
\end{oQuestion}


\end{document}