|
3.6 ライブ3Dプロット:Plot3DLive.jsp
3.6 ライブ3Dプロット:Plot3DLive.jsp 前述のようにwebMathematica をインストールするとhttp://localhost:8080/webMathematica/Examples/Plot3DLive.jspでこのJSPに接続することができます(ご自分のサーバに接続するURLはこれとは多少異なる場合もあります).ユーザはここで関数を入力し,LiveGraphics3Dのアプレットを使ってプロットすることができます.このページのソースは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>
この例ではたくさんの評価を使ってパラメータを設定しています.Plot3Dを呼び出すのに,最後の評価がこれらのパラメータの値を使っています.この結果はLiveGraphics3Dアプレットを呼び出すMSPLive3Dに伝えられます.これで3Dグラフィックスオブジェクトのリアルタイムの回転ができるようになります.
| |