79
5.3.2 SVG Animations
SVG supports a number of animation and interaction features. This example will demonstrate the use of SVG
animations.
The source for this example is in webMathematica/Examples/SVG/NDSolvePlot.jsp. If you installed
webMathematica as described
above
, you should be able to connect to this JSP via http://localhost:8080/web
Mathematica/Examples/SVG/NDSolvePlot.jsp. (You may have some other URL for accessing your server.)
The source contains an HTML form that sets up a number of input fields to collect the equation, starting and ending
points, as well as initial conditions. These are then fed to a function that solves the differential equation and returns a
plot of the result formatted as SVG. The SVG is then displayed with the function SVGDisplay, which is defined
in the package MSP SVG . The code, which inserts the plot, is shown below.
MSPBlock[ {$$eqn, $$t0, $$init1, $$init2, $$t1},
svg = NDSolveToSVG[ $$eqn, {$$init1, $$init2},
{$$t0,$$t1}] ;
SVGDisplay[ svg, {400, 300}]]
The actual definition of the function that creates the SVG is shown below. This solves the differential equation and
generates a plot of the result. It then generates Symbolic XML, which represents the SVG of the result, using the
function XML SVG GraphicsToSymbolicSVG. Next, it finds the points that represent the plot of the result
and uses these to form an SVG animation of a red ball, which moves along these points. This animation is inserted
into the SVG to form a new result, which is returned to be plotted.
.
<
New Page 1
Comcast Web Hosting