This is documentation for an earlier version of webMathematica.
View current User Guide (Version 3.3)

Documentation3. Basic Examples

 

3.6 Live 3D Plotting: Plot3DLive.jsp

If you installed webMathematica as described above, you should be able to connect to this JSP via http://localhost:8080/webMathematica/Examples/Plot3DLive.jsp. (You may have some other URL for accessing your server.) It allows the user to enter a function to be plotted by the LiveGraphics3D applet. The source for this page is in webMathematica/Examples/Plot3DLive.jsp.

<%@ page language="java" %>
<%@ taglib uri="/webMathematica-taglib" prefix="msp" %>

<html>
<head>
<title>Live 3D Plotting</title>
</head>

<body text="#171717" bgcolor = "#ffffff">
<msp:allocateKernel>

<msp:evaluate>
$ImageBackground = "#ffffff";
$ImageSize = {300, 300};
</msp:evaluate>

<h1>Live 3D Plotting</h1>
<form action="Plot3DLive.jsp" method="post">
Plot3D of
<input type="text" name="fun" size="22" value =
"<msp:evaluate> MSPValue[ $$fun, "Sin[x y]^2"] </msp:evaluate>">
<br>
x from:
<input type="text" name="x0" size="10" value =
"<msp:evaluate>MSPValue[ $$x0, "-2"] </msp:evaluate>">
to:
<input type="text" name="x1" size="10" value =
"<msp:evaluate>MSPValue[ $$x1, "2"] </msp:evaluate>">
<br>
y from:
<input type="text" name="y0" size="10" value =
"<msp:evaluate>MSPValue[ $$y0, "-2"] </msp:evaluate>">
to:
<input type="text" name="y1" size="10" value =
"<msp:evaluate>MSPValue[ $$y1, "2"] </msp:evaluate>">
<br>
Number of points to plot
<input type="text" name="pts" size="5" value =
"<msp:evaluate>MSPValue[ $$pts, "20"] </msp:evaluate>">
<br>
<msp:evaluate>
   MSPBlock[ {$$fun, $$x0, $$x1, $$y0, $$y1, $$pts},
         MSPLive3D[
            Plot3D[$$fun,
            {x, $$x0, $$x1}, {y, $$y0, $$y1}, PlotPoints -> $$pts]]]
</msp:evaluate>
<br><hr>
<input type="submit" name="btnSubmit" value="Evaluate">
</form>
</msp:allocateKernel>
</body>
</html>

This example uses a number of evaluations to set up parameters. The last evaluation takes the values of these parameters and uses them in a call to Plot3D. The result of this goes to MSPLive3D, which calls the LiveGraphics3D applet. This gives a real-time rotation of the three-dimensional graphics object.