
|
Search
Search Loci: Developers: |
Loci: DevelopersConstructing Mathlets Quickly using LiveGraphics3DLiveGraphics3D InputWe begin our tutorial with a basic example in which only one parameter, To create this applet on your computer system, download the file
<html><body>
<applet archive="live.jar" code="Live.class" width="300" height="300">
<param name="INPUT"
value="Graphics3D[{
Line[{{0,0,0},{2,0,0}}],
{RGBColor[1,0,0],PointSize[0.06],Point[{2,0,0}]},
{RGBColor[0,0,1],PointSize[0.03],Point[{1,0,0}]}
}, (* Done with list of primitives; now include options *)
PlotRange->{{-2,2}, {-2,2}, {-1,1}},
Axes -> True, AxesLabel -> {X, Y, Z}]" />
</applet>
</body></html>
Resulting Applet:
You should be able to rotate, spin, and change the zoom level in the image using the same controls as in the introduction. In this particular applet neither point can be dragged. Equipped with the basic knowledge of how to embed LiveGraphics3D into a web page, we can start to construct the example from the introduction. First we'll create the wireframe mesh which represents a portion of the graph of z = f(x, y) = 2 y e−x2−y2 over the rectangle −1 ≤ x ≤ 3, −2 ≤ y ≤ 1 We used a 20 by 20 grid, which can be constructed using the following Mathematica commands. (For those who are unfamiliar with Mathematica and have not yet read the syntax overview,
f[x_,y_]= 2y*Exp[-x^2-y^2];
xmin = -1; xmax = 3;
ymin = -2; ymax = 1;
n = 20;
dx = (xmax-xmin)/n;
dy = (ymax-ymin)/n;
mesh = {GrayLevel[0.7], (* Make the line segments gray, not black *)
(* This pair of nested Tables creates the cross sections y=j *)
Table[ (* Let the y-values vary *)
Table[ (* y fixed, now let x-values vary *)
Line[{{i, j, f[i, j]}, {i + dx, j, f[i + dx, j]}}],
{i, xmin, xmax - dx/2, dx}],
{j, ymin, ymax, dy}],
(* This pair of nested Tables creates the cross sections x=i *)
Table[ (* Let the x-values vary *)
Table[ (* x fixed, now let the y-values vary *)
Line[{{i, j, f[i, j]}, {i, j + dy, f[i, j + dy]}}],
{j, ymin, ymax - dy/2, dy}],
{i, xmin, xmax, dx}]
};
The variable example = Graphics3D[mesh, Boxed -> False]; WriteLiveForm["mesh.lg3d", example] To show the mesh in LiveGraphics3D, we use the <html><body> <applet archive="live.jar" code="Live.class" width="300" height="300"> <param name="INPUT_FILE" value="mesh.lg3d"/> </applet> </body></html>Resulting Applet: The use of |