(*^ ::[ Information = "This is a Mathematica Notebook file. It contains ASCII text, and can be transferred by email, ftp, or other text-file transfer utility. It should be read or edited using a copy of Mathematica or MathReader. If you received this as email, use your mail application or copy/paste to save everything from the line containing (*^ down to the line containing ^*) into a plain text file. On some systems you may have to give the file a name ending with ".ma" to allow Mathematica to recognize it as a Notebook. The line below identifies what version of Mathematica created this file, but it can be opened using any other version as well."; FrontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.2"; MacintoshStandardFontEncoding; fontset = title, nohscroll, center, bold, L0, 24, "Times"; fontset = subtitle, nohscroll, center, bold, L0, 18, "Times"; fontset = subsubtitle, nohscroll, center, italic, L0, 14, "Times"; fontset = section, nohscroll, grayBox, bold, L0, 18, "Times"; fontset = subsection, nohscroll, blackBox, bold, L0, 14, "Times"; fontset = subsubsection, nohscroll, whiteBox, bold, L0, 12, "Times"; fontset = text, nohscroll, L0, 12, "Times"; fontset = smalltext, nohscroll, L0, 10, "Times"; fontset = input, nowordwrap, bold, L-4, 12, "Courier"; fontset = output, nowordwrap, L-4, 12, "Courier"; fontset = message, nowordwrap, R32768, L-4, 12, "Courier"; fontset = print, nowordwrap, L-4, 12, "Courier"; fontset = info, nowordwrap, B32768, L-4, 12, "Courier"; fontset = postscript, nowordwrap, L0, 12, "Courier"; fontset = name, nohscroll, italic, L0, 10, "Geneva"; fontset = header, L0, 12, "Times"; fontset = leftheader, L2, 12, "Times"; fontset = footer, center, L0, 12, "Times"; fontset = leftfooter, L2, 12, "Times"; fontset = help, nohscroll, L0, 10, "Times"; fontset = clipboard, nohscroll, L0, 12, "Times"; fontset = completions, nohscroll, L0, 12, "Times"; fontset = special1, nohscroll, L0, 12, "Times"; fontset = special2, nohscroll, L0, 12, "Times"; fontset = special3, nohscroll, L0, 12, "Times"; fontset = special4, nohscroll, L0, 12, "Times"; fontset = special5, nohscroll, L0, 12, "Times"; currentKernel; ] :[font = title; inactive; preserveAspect; startGroup] MathLive 2.0 Help :[font = text; center; plain; italic; fontSize = 14] Original by W. Shaw © 1993-1996 :[font = section; output; inactive; Cclosed; preserveAspect; startGroup] Background Information ;[o] Background Information :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] What Is MathLive? :[font = text; inactive; preserveAspect; endGroup] MathLive is a real-time visualization environment for mathematics, tailored to provide an exciting real-time viewing extension to Mathematica. With MathLive and a reasonably powerful computer, you can do the kind of real-time 3D graphics previously available only on expensive workstations equipped with specialized hardware and software. MathLive makes use of revolutionary algorithms in software rendering to take you to a mathematical virtual reality on your personal computer. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Why Use MathLive? :[font = text; inactive; preserveAspect; endGroup] MathLive adds new capabilities to your Mathematica environment that complement those of Mathematica itself. Instead of having to enter cumbersome text commands to adjust viewpoints, geometry, or other graphics options, and having to wait for the surface to re-render, you can adjust such parameters in real time. You can convert to wire frame or scatter plot graphics on the fly, adjust surface color instantly, and make immediate use of a rich set of pre-set options. MathLive gives you surface properties, such as diffuse and specular reflectivity, which can be adjusted in real time, using a choice of flat or smooth shading models for the surface. One of MathLive's most impressive features is its ability to implement both static and animated texture mapping, thus allowing the salient features of any object toht dramatically to life. Mathematica can itself be used to create textures that can be mapped onto objects within MathLive. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Ways to use MathLive :[font = text; inactive; preserveAspect; endGroup] MathLive can be used with Mathematica in various ways. It can be used either with files exported by Mathematica in 3-Script format, or by exploiting a direct process-to-process connection using the MathLink protocol between MathLive and Mathematica . Objects for use within MathLive may be created with standard Mathematica graphics commands such as Plot3D, ParametricPlot3D and the more general Graphics3D. A Mathematica NoteBook for creating texture maps using the DensityPlot function is also included. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Creating Interesting Graphics :[font = text; inactive; preserveAspect; endGroup; endGroup] Experimentation is one way of exploring the capabilities of MathLive. If you require some ideas to get you going, or help with the commands of Mathematica, then we suggest that you consult the following sources. For general Mathematica, including graphics, there is S. Wolfram's book 'Mathematica, A System for Doing Mathematics by Computer'. You should also consult the package documentation 'Guide to Standard Mathematica Packages', Wolfram Research's technical report for examples of extended graphics fu nctions. For fun mathematical constructions we suggest that you turn to the book by T. Gray and Glynn 'Exploring Mathematics with Mathematica' (Addison-Wesley). You should also keep an eye open for a beautiful treatise on curves and surfaces by A. Gray, that uses Mathematica extensively, called 'Modern Differential Geometry of Curves and Surfaces' (CRC Press). For more down-to-earth scientific graphics based on functions and data, we recommend the book 'Applied Mathematica, Getting Started, Getting it Done', published by Addison-Wesley. An article entitled "MathLive and the Virtual Dynamics Laboratory" is scheduled to appear in the Spring 1995 issue of the Mathematica Journal. This contains several hints on how to make the most of MathLive. :[font = section; inactive; Cclosed; preserveAspect; startGroup] Installing MathLive and Basic Use :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Hardware Requirements (Macintosh) :[font = text; inactive; preserveAspect; endGroup] MathLive will run on any Macintosh containing a 32-bit processor (68020 and above) or PowerPC, and a display capable of 256 colors. It is supplied in both 680x0 and PowerPC versions (both are optimised for their particular processor). To run MathLive alone, we recommend a minimum of 8M of RAM. To use MathLive with Mathematica and MathLink, we recommend 16M of RAM. It can be used with virtual memory and less RAM. MathLive 2.0 or later works in all video modes, but we recommend the settings of "Thousands of colors" for the best representation of color graphics, on both Macintosh and Power Macintosh. 256 color also works well. Check your Monitors control panel (including the options button) for color depths and screen resolutions supported by your system. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Hardware Requirements (Windows PC) :[font = text; inactive; preserveAspect; endGroup] MathLive will run on any Windows PC containing a 486 or higher processor. A minimum of 8M RAM is recommended. For responsive use in conjunction with Mathematica andMathLink, we suggest that you install 16M of RAM, but MathLive will use virtual memory. MathLive 2.0 or later works best (in terms of color display) in 15/16bit video modes (32k or 65k colors), and works well (in fact faster, but with fewer colors) in 8bit mode (256 colors). There is a significant performance drop when using 16 colors (4-bit) or 16.7M colors (24-bit). Check your video system hardware for help on setting your display to 8/15/16 bit. You will proably find that higher color depth is supported if you lower the screen resolution. A video card with 1M V/DRAM will usually support 15 /16 bit colour at 800 by 600, and a card with 2M will usually support the same color depth at 1024 by 768. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Backing Up Your Master Disk :[font = text; inactive; preserveAspect; endGroup] Before installing MathLive on your personal computer, initialize a fresh high density floppy disk, and copy the MathLive master disk to this fresh disk. When installing MathLive, or if re-installing later, always work from the back-up disk, and keep your original master disk in a safe environment, away from dust, liquids, magnetic fields, software pirates and other malicious influences! :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Installing MathLive on your Hard Disk (Macintosh) :[font = text; inactive; preserveAspect; endGroup] Insert the disk entitled "Setup" into your computer and run the installation program entitled "MathLive Installer". There is a choice of install modes. Provided that you have enough disk space we recommend that you use the Full Installation option obtained by just clicking on the "Install" button. If you are short of disk space, or wish to make a minimal installation, or wish to add to a previous minimal installation, click the "custom" option, where you will be presented with various choices. Your choices include a minimum installation that only installs the files necessary for the correct operation of MathLive. Whatever the choice, clicking on the "Install" button will commence the installation. The installer will automatically determine the correct application for your particular Macintosh (680x0 or PowerPC). You have the option to choose where to install the folder containing the MathLive program. Use the dialog box navigation tools to make the choice. Once the installation is complete, we suggest that you make an alias of the MathLive program, and move this alias to the folder where the 'Mathematica kernel' application resides. For convenience, we suggest you rename this alias to 'MathLive' (subsequent instructions regarding MathLink will assume this is the case, or that the application has itself been placed in the Mathematica directory). :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Installing MathLive on your Hard Disk (Windows PC) :[font = text; inactive; preserveAspect; endGroup] Insert the disk entitled "Setup" into your computer. Make sure that the Windows Program Manager is active, and choose "Run" from the File menu. Type A:\SETUP.EXE into the dialog box, and click on the "OK" button. The Installer will display a "Welcome" screen, where your should click on "Continue" unless you decide to "Exit" or request "Help". You will then be prompted for the name of a directory in which to install the software. The default shown will usually suffice. Click on "Continue", and enter the ser ial number (shown on either of your Master disks) when asked. Then enter your name and address. The installation will then proceed. When the installation is complete you will be advised to make an association between .TS and .AMS files and MathLive using the Associate menu command (under the File menu in the File Manager.) :[font = text; inactive; preserveAspect] :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Testing the Basic Use of MathLive :[font = text; inactive; preserveAspect; endGroup] To check that MathLive has installed without error, make sure the MathLive folder is open and double-click on the 'MathLive' application icon. (On a Macintosh only, you should obtain a dialog box with the prompt "Listen On" and the editable name "MathLive". Click the "OK" button.) You should see a blank window with a colored or gray background. Choose Open from the File menu. You will see a dialog box. Navigate to the Shapes folder and open the file called 'catenoid.ams'. You should see a screen containing an object that is part of the surface of a catenoid, shaded with a checkered pattern. You may use the mouse to control the scene in various ways. You will probably just wish to experiment! :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Interaction (Macintosh) :[font = text; inactive; preserveAspect] Note that help on mouse control is available under the Apple Menu command "Show Modifier Keys". :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] Object Manipulation :[font = text; inactive; preserveAspect] The mouse button, when clicked and held down on an object, together with the Shift, Option and Command keys is used to spin, drag, zoom and delete objects. :[font = input; Cclosed; preserveAspect; startGroup] Mouse button alone :[font = info; inactive; preserveAspect; endGroup] Spins the object :[font = input; Cclosed; preserveAspect; startGroup] Shift + Mouse button :[font = info; inactive; preserveAspect; endGroup] Moves the object :[font = input; Cclosed; preserveAspect; startGroup] Option + Mouse button :[font = input; preserveAspect; endGroup] Zooms the object :[font = input; Cclosed; preserveAspect; startGroup] Command + Mouse button :[font = info; inactive; preserveAspect; endGroup; endGroup] Deletes the object :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] Scene Manipulation :[font = text; inactive; preserveAspect] The camera and light may be positioned using a combination of the mouse button and the Shift, Option and Command keys. In each of the following cases the mouse button must be clicked and held down off the object. :[font = input; Cclosed; preserveAspect; startGroup] Shift + Mouse button :[font = info; inactive; preserveAspect; endGroup] Rotates and tilts the light :[font = input; Cclosed; preserveAspect; startGroup] Option + Mouse button :[font = input; preserveAspect; endGroup] Zooms the camera :[font = input; Cclosed; preserveAspect; startGroup] Command + Mouse button :[font = info; inactive; preserveAspect; endGroup] Tilts the camera :[font = input; Cclosed; preserveAspect; startGroup] Ctrl + Mouse button :[font = info; inactive; preserveAspect; endGroup; endGroup; endGroup] Selects a region for copying to the clipboard :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Interaction (Windows PC) :[font = text; inactive; preserveAspect] Note that help on mouse control is available under the Help menu, in the "Interaction" section of "Installation and Basic use". The Left mouse button controls object manipulation, and the Right button controls the scene manipulation. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] Object Manipulation :[font = text; inactive; preserveAspect] The left mouse button, when clicked and held down on an object, together with the Shift, and Control keys is used to spin, drag, zoom and delete objects. :[font = input; Cclosed; preserveAspect; startGroup] Left Mouse button alone :[font = info; inactive; preserveAspect; endGroup] Spins the object :[font = input; Cclosed; preserveAspect; startGroup] Shift + Left Mouse button :[font = info; inactive; preserveAspect; endGroup] Moves the object :[font = input; Cclosed; preserveAspect; startGroup] CTRL + Left Mouse button :[font = input; preserveAspect; endGroup] Zooms the object :[font = input; Cclosed; preserveAspect; startGroup] CTRL + Shift + Left Mouse button :[font = info; inactive; preserveAspect; endGroup; endGroup] Deletes the object :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] Scene Manipulation :[font = text; inactive; preserveAspect] The camera and light may be positioned using a combination of the right mouse button and the Shift and Control keys. :[font = input; Cclosed; preserveAspect; startGroup] Right Mouse button :[font = input; preserveAspect; endGroup] Pans the camera :[font = input; Cclosed; preserveAspect; startGroup] CTRL + Right Mouse button :[font = info; inactive; preserveAspect; endGroup] Zoom the camera :[font = input; Cclosed; preserveAspect; startGroup] Shift + Right Mouse button :[font = info; inactive; preserveAspect; endGroup] Spins the light :[font = input; Cclosed; preserveAspect; startGroup] 'C' + Left Mouse button :[font = info; inactive; preserveAspect; endGroup; endGroup; endGroup] Selects a region for copying to the clipboard :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Menu commands :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] File :[font = input; Cclosed; preserveAspect; startGroup] Open :[font = info; inactive; preserveAspect; endGroup] Read a 3-Script or Ascii Mesh file. :[font = input; Cclosed; preserveAspect; startGroup] Save Scene As... :[font = info; inactive; preserveAspect; endGroup] Save the scene as an Ascii Mesh file. Note that this is not possible if the scene is empty. :[font = input; Cclosed; preserveAspect; startGroup] Quit :[font = info; inactive; preserveAspect; endGroup; endGroup] Quit MathLive. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] Edit :[font = input; Cclosed; preserveAspect; startGroup] Copy :[font = info; inactive; preserveAspect; endGroup] Copy a selected region to the clipboard :[font = input; Cclosed; preserveAspect; startGroup] Preferences :[font = info; inactive; preserveAspect; backColorRed = 32768; backColorGreen = 32768; backColorBlue = 32768; fontName = "Times"; endGroup; endGroup] Open a dialog box where you can: control object positioning; set window sizes (Macintosh); adjust background color. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] Animations :[font = input; Cclosed; preserveAspect; startGroup] Object and Rotate :[font = info; inactive; preserveAspect; endGroup] Rotate object about Y. :[font = input; Cclosed; preserveAspect; startGroup] Object and Tilt :[font = info; inactive; preserveAspect; endGroup] Rotate object about X. :[font = input; Cclosed; preserveAspect; startGroup] Camera and Rotate :[font = info; inactive; preserveAspect; endGroup] Rotate camera about Y. :[font = input; Cclosed; preserveAspect; startGroup] Camera and Tilt :[font = info; inactive; preserveAspect; endGroup] Rotate camera about X. :[font = input; Cclosed; preserveAspect; startGroup] Camera and Fly past :[font = info; inactive; preserveAspect; endGroup] Only active when an object is selected. Fly past the selected object on an elliptical path, keeping the camera pointing at the selected object. :[font = input; Cclosed; preserveAspect; startGroup] Camera and Corkscrew :[font = info; inactive; preserveAspect; endGroup] Only active when an object is selected. Fly past the selected object on a corkscrew-like path, keeping the camera pointing at the selected object. :[font = input; Cclosed; preserveAspect; startGroup] Light and Rotate :[font = info; inactive; preserveAspect; endGroup] Rotate light about Y. :[font = input; Cclosed; preserveAspect; startGroup] Light and Tilt :[font = info; inactive; preserveAspect; endGroup; endGroup] Rotate light about X. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] Surface :[font = text; inactive; preserveAspect] Objects may be shown as Point Clouds, Wire-frames or as solids, with various choices of colors and lighting schemes. :[font = input; Cclosed; preserveAspect; startGroup] Color and Color Picker :[font = info; inactive; preserveAspect; endGroup] Select a surface color using the system color picker. :[font = input; Cclosed; preserveAspect; startGroup] Color and Zippy :[font = info; inactive; preserveAspect; endGroup] Set the color to a zippy patch work. :[font = input; Cclosed; preserveAspect; startGroup] Geometry and Point Cloud :[font = info; inactive; preserveAspect; endGroup] Select point cloud geometry sampling. (You may find it useful to increase the ambient lighting value.) :[font = input; Cclosed; preserveAspect; startGroup] Geometry and Wire Frame :[font = info; inactive; preserveAspect; endGroup] Select wire frame geometry sampling. :[font = input; Cclosed; preserveAspect; startGroup] Geometry and Flat Solid :[font = info; inactive; preserveAspect; endGroup; endGroup] Select solid geometry sampling with flat shading. :[font = input; Cclosed; preserveAspect; startGroup] Geometry and Smooth Solid :[font = info; inactive; preserveAspect; endGroup] Select solid geometry sampling with smooth shading. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] Surface - Lighting sub-menu :[font = text; inactive; preserveAspect] The surface characteristics of an object may be adjusted by means of the following set of parameters, each of which can take a range of values from zero to one or a percentage. :[font = input; Cclosed; preserveAspect; startGroup] Ambient :[font = info; inactive; preserveAspect; endGroup] Set the surface ambient reflectivity property. :[font = input; Cclosed; preserveAspect; startGroup] Diffuse :[font = info; inactive; preserveAspect; endGroup] Set the surface diffuse reflectivity property. :[font = input; Cclosed; preserveAspect; startGroup] Specular :[font = info; inactive; preserveAspect; endGroup; endGroup] Set the surface specular reflectivity property. :[font = input; Cclosed; preserveAspect; startGroup] Opacity :[font = info; inactive; preserveAspect; endGroup] Set the surface opacity. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] QuickTime (Macintosh only) :[font = text; inactive; preserveAspect] Animations may be captured and stored as QuickTime movies. These movies can be played back within MathLive, or indeed in any other application that supports QuickTime. The MathLive QuickTime movie viewer can also be used to view QuickTime movies created in other applications. If you wish to record an animation that relies on an object being selected, make sure that the object is selected first, before choosing the "Start recording" menu. :[font = input; Cclosed; preserveAspect; startGroup] Start recording :[font = info; inactive; preserveAspect; endGroup] Choose an animation sequence to be stored as a QuickTime movie, and select the name of the file in which the movie is to be stored. :[font = input; Cclosed; preserveAspect; startGroup] Open movie :[font = info; inactive; preserveAspect; endGroup; endGroup] Open a QuickTime movie file. :[font = input; Cclosed; preserveAspect; startGroup] Close movie :[font = info; inactive; preserveAspect; endGroup] Close a QuickTime movie file (may also be closed by clicking on the "Close" box at the top left of the movie window. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] Textures :[font = text; inactive; preserveAspect] Textures may be loaded and applied to the currently selected object. Many textures may be stored at any one time, and those that have been opened will be stored in this menu for as long as MathLive remains open. (The number is limited only by the amount of memory allocated to MathLive). Textures with multiple frames will automatically be animated. :[font = input; Cclosed; preserveAspect; startGroup] Open :[font = info; inactive; preserveAspect; endGroup] Load a texture map and apply to the selected object. :[font = input; Cclosed; preserveAspect; startGroup] No texture :[font = info; inactive; preserveAspect; endGroup; endGroup; endGroup; endGroup] Remove a texture from the current object. :[font = section; inactive; Cclosed; preserveAspect; startGroup] Using MathLive with Files :[font = text; inactive; preserveAspect] You can use MathLive with files in various ways. One is the 3-Script file interface to Mathematica. Using the 3-Script package (consult the packages documentation for details), you can write a representation of 3-dimensional graphics to a standard text file format. This may be read directly into MathLive. However, because of the limitations of the 3-Script format, you will normally find that the use of MathLink is preferable, since considerably more information about the surface can be passed directly via MathLink. Another type of file is a texture file, we shall also show you how to add textures to your graphics. MathLive also has its own file type called an ascii mesh file. MathLive scenes can be saved in this format and reloaded later in new sessions of MathLive. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Creating and Using 3-Script files :[font = text; inactive; preserveAspect] We begin by showing how to create 3-Script files. The following series of steps are provided in the NoteBook '3script.ma', which will have been placed in the 'Notebooks' folder where MathLive was installed. You may wish to copy exactly the following series of steps, but you should also experiment with graphics of your own. :[font = input; preserveAspect] Needs["Graphics`ThreeScript`"] :[font = input; preserveAspect] bell = Plot3D[Exp[-x^2 + -y^2], {x, -2, 2}, {y, -2, 2}, PlotPoints -> 25] :[font = input; preserveAspect] ThreeScript["bell.ts", bell] :[font = input; preserveAspect] twospheres = ParametricPlot3D[ {{Sin[v] Cos[u], Sin[v] Sin[u], Cos[v]}, {Sin[v] Cos[4 u/3]/2, Sin[v] Sin[4 u /3]/2, Cos[v]/2}}, {u, 0, 3 Pi/2},{v, 0, Pi}] :[font = input; preserveAspect] ThreeScript["twosphes.ts", twospheres] :[font = text; inactive; preserveAspect; endGroup] Now open MathLive. Now choose Open from the MathLive File menu. Using the dialog box, navigate to where the 3-Script files have been created (this will be in your Mathematica folder unless you have added a path to the file names). Open both "bell.ts" and " twosphes.ts". Experiment with moving each object in turn. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Adding Texture Maps :[font = text; inactive; preserveAspect; endGroup] Delete all the objects in the MathLive window, and reload the file "bell.ts". Select the object by clicking on it with the left mouse button. Now choose Open from the Textures menu, navigate to the MathLive textures folder, and choose a texture from the list. Repeat this procedure, loading "twosphes.ts" and assign to it any of the .ras files to be found in the textures folder. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Creating Mathematica Texture Maps :[font = text; inactive; preserveAspect] This is discussed in detail in the notebook "textgen.ma" which you will find in the "Notebooks" folder where MathLive was installed. Here is one simple example for the creation of a texture map. We have to create a binary file, and we make use of the Mathematica function FromCharacterCode to do so. Further enlightenment about binary files can be obtained by scrutinizing the BinaryFiles package. However, you do not need to do this to create some simple textures, and using the following as a recipe will suffice for many interesting examples. First we create some standard header information: :[font = input; preserveAspect] headerdata = {16^^59,16^^a6,16^^6a,16^^95,0,0,0,16^^80,0,0,0, 16^^80,0,0,0,16^^8,0,0,16^^40,0,0,0,0, 1,0,0,0,1,0,0,3,0}; :[font = text; inactive; preserveAspect] The next step is to create a suitable color map. Here is one example tested to produce vivid if rather tasteless colors (feel free to experiment with the choices of colors here!): :[font = input; preserveAspect] huefunc[x_] := 255*Which[x<1,x,x<3,1,x<4,4-x,True,0]; rgb[x_] := Floor[{huefunc[Mod[x+2,6]],huefunc[x], huefunc[Mod[x-2,6]]}]; colormap = Flatten[Transpose[Table[rgb[x],{x,0,6,6/255.0}]]]; :[font = text; inactive; preserveAspect] Here is another example that produces a striking chess-board pattern in black and red: :[font = input; preserveAspect] check[x_] := If[x<0.5, {0,0,0}, {255,0,0}]; checkcolormap = Flatten[Transpose[Table[check[x],{x,0,1,1/255.0}]]]; :[font = text; inactive; preserveAspect] The notebook "textgen.max" also contains a convenient way of visualizing this color map. Next we need to create some data that the color map will use to create a color map of the data. We will make some completely random data (note that the array is 128 by 128, this array size is a fixed parameter in this version of MathLive) and some data that uses are checkered scheme: :[font = input; preserveAspect] randomdata = Flatten[Table[2*Ceiling[100*Random[]],{128},{128}]]; :[font = input; preserveAspect] checkdata = Flatten[Table[If[EvenQ[x+y],0,200],{x,1,128,1},{y,1,128,1}]]; :[font = input; Cclosed; preserveAspect; startGroup] outline = OpenWrite["random.ras"]; WriteString[outline,FromCharacterCode[headerdata]]; WriteString[outline,FromCharacterCode[colormap]]; WriteString[outline,FromCharacterCode[randomdata]]; Close[outline] :[font = output; output; inactive; preserveAspect; endGroup] "random.ras" ;[o] random.ras :[font = input; Cclosed; preserveAspect; startGroup] outline = OpenWrite["check.ras"]; WriteString[outline,FromCharacterCode[headerdata]]; WriteString[outline,FromCharacterCode[checkcolormap]]; WriteString[outline,FromCharacterCode[checkdata]]; Close[outline] :[font = output; output; inactive; preserveAspect; endGroup] "check.ras" ;[o] check.ras :[font = text; inactive; preserveAspect; endGroup; endGroup] The files "random.ras" and "check.ras" may be opened and used as a texture in the usual way. Texture maps provide an interesting way of transferring Mathematica animation information to the MathLive environment. The notebook contains an example of the creation of an animated color map that can be used to dump a "glowing" fractal onto any surface! Check out the Mathematica Journal amd MathSource for other examples. :[font = section; inactive; Cclosed; preserveAspect; startGroup] Using MathLive with MathLink :[font = text; inactive; preserveAspect] Thus far you have used MathLive to load 3-Script files and to overlay texture maps. The 3-Script file method is useful, but 3-Script does not capture all the information in a plot. MathLive has been developed to handle the MathLink communications standard for direct communication to Mathematica. By using MathLink, graphics may be sent directly from Mathematica to MathLive, and we can send over more information more quickly. Note that the range of objects that may be sent over MathLink is continually b eing extended as MathLive is developed, Future versions of MathLive will use MathLink to utilize complete 2-way communication with the kernel, providing an alternative visualization front end. Before using Mathematica and MathLive simultaneously, you should check that you have sufficient memory on your system. MathLive is a 32 bit application and will make use of as much memory as you can provide. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Setting the Path :[font = text; inactive; preserveAspect] Using the MathLink interface is very simple, since the necessary hooks for MathLink are built into MathLive. You need to set a path variable. Consider the Macintosh first - a Windows PC differs only in the setting of the path variable - see below. Suppose that MathLive has been placed in a folder, called "MathLive", within the "Mathematica 2.2" folder, on a disk entitled "programs" The full path is given by appending the name of the application executable file to the folder holding the file. This path is then given the name $LivePath and entered in to Mathematica:. In the following example the application name is actually just "MathLive". Note that the $LivePath string is enclosed in double quotes, and that the path is also enclosed in single quotes (this is necessary to cope with the possibility of spaces within the folder or application names - the single quotes are actually unnecessary if there are no spaces in the names.) The single quotes are both the same - don't use left and right quotation marks. F inally, colons are used to separate the folders and sub-folders. :[font = input; preserveAspect; endGroup] $LivePath = "'programs:Mathematica 2.2:MathLive:MathLive'"; :[font = input; preserveAspect] $LivePath = "C:\\MathLive\\live_fpu.exe"; :[font = text; inactive; preserveAspect] If, instead, and on a Macintosh, you have just placed the MathLive application in the Mathematica kernel directory, you can just say: :[font = input; preserveAspect] $LivePath = "MathLive"; :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Starting MathLive from Mathematica with MathLink :[font = text; inactive; Cclosed; preserveAspect; startGroup] MathLive may be opened automatically from Mathematica . Indeed, this is the preferred way of forming a MathLink connection. We suggest that you give the link a sensible name such as "live", and execute the following: :[font = input; preserveAspect] live = LinkOpen[$LivePath, LinkMode->Launch]; :[font = text; inactive; preserveAspect; endGroup; endGroup] If all is well MathLive will start but remain in the background. If your path is wrong the command will fail. You must ensure the path is correct. (MathLink experts may wish to note that the option LinkMode->Launch is, strictly, unnecessary, since the default setting of LinkMode->Automatic will do the job. However, it is possible, as described in the next section, to establish a connection to an already running copy of MathLive using the variant LinkMode->Connect. In order to avoid accidentally starting two MathLive sessions (e.g. if you have more than one version of the software on your disk, which is NOT recommended), we recommend that you get int o the habit of noting whether MathLive is active, and explicitly using LinkMode->Launch and LinkMode->Connect.) Ignore any strange color schemes in either the MathLive or Mathematica windows. If you are in 8-bit (256 color) mode, the programs have different ideas about system palettes of color, and some strange color effects are normal at both this stage and when one passes graphics over the link. If it bothers you, this switching of palettes can be suppressed at the price of some dithering in Mathematica graphics. If you choose "Colors" from the Mathematica File menu, and set the "Requested number of palette col ors" to "None", Mathematica and MathLive will adopt compatible palettes. :[font = subsection; inactive; preserveAspect] Starting MathLive First and then Connecting with MathLink :[font = text; inactive; preserveAspect] You may wish to start the MathLive application first and establish a MathLink connection from Mathematica later. This is easily done. On a Macintosh, when you start the MathLive application, a dialog box will appear, with the query "Listen on" and then the actual application name of the program as it is stored on your disk. You may change this name to any one you wish. This name is used by MathLink to listen for an attempt by the Mathematica kernel to establish a MathLink connection. On a Windows PC t his is handled automatically. On the Macintosh a connection is established by the following simple command, where we assume that the "Listen On" dialog box has just "MathLive" entered: :[font = input; preserveAspect] live = LinkOpen["MathLive", LinkMode->Connect]; :[font = text; inactive; preserveAspect] IMPORTANT NOTE FOR WINDOWS USERS On a Windows PC you should use LinkMode->Launch whether you wish to actually launch MathLive or whether you wish to connect to an already running copy of MathLive. If MathLive is already running it will drop any link it currently holds and will make use of the new one. :[font = input; preserveAspect] live = LinkOpen["C:\\MathLive\\live_fpu.exe", LinkMode->Launch]; :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Sending Graphics to MathLive with MathLink :[font = text; inactive; Cclosed; preserveAspect; startGroup] Create a graphic with Plot3D and, for convenience, give it a name. You can suppress the display of the plot in Mathematica by using the option DisplayFunction->Identity. :[font = input; preserveAspect] lumpy = Plot3D[Sin[x^2] Sin[y^2], {x,-Pi,Pi}, {y,-Pi,Pi}, PlotPoints -> 30, DisplayFunction->Identity]; :[font = text; inactive; preserveAspect] Having created the plot, we just send it over to MathLive with a LinkWrite statement, using the name "live" to identify the link: :[font = input; preserveAspect] LinkWrite[live, lumpy]; :[font = text; inactive; preserveAspect] When MathLive has drawn the object, its window automatically comes to the front of the screen. You may now proceed as with the file interface. You can at this stage load other files in the usual way. You can also close the link from Mathematica by using: :[font = input; preserveAspect] LinkClose[live] :[font = text; inactive; preserveAspect; endGroup; endGroup] MathLive will remain open and you can use the file interface as before. Please note that once you have closed the connection you will have to close MathLive and re-open it before you can re-establish a connection. Note that the current connection status is shown in the 'About Mathlive' status box. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Cleaning up with DisplayFunction :[font = text; inactive; preserveAspect] It is possible to simplify the means by which graphics are sent to MathLive, by using the DisplayFunction option together with an appropriate pure function. We have already seen how setting DisplayFunction -> Identity can be used to suppress the Mathematica form of a plot. If you are comfortable with pure functions, or if you wish to set up the system for use by people who are uncomfortable with MathLink, then start all your Mathematica sessions with the following commands: :[font = input; preserveAspect] live = LinkOpen[$LivePath, LinkMode -> Launch]; Live = (LinkWrite[live, N[#]]&); Both = (LinkWrite[live, N[#]]; Display[$Display,#])&; :[font = text; inactive; preserveAspect] Of course, at any stage, you can just enter the definitions of "Live" and "Both", assuming the link to MathLive is called "Live": :[font = input; preserveAspect] Live = (LinkWrite[live, N[#]]&); Both = (LinkWrite[live, N[#]]; Display[$Display,#])&; :[font = text; inactive; preserveAspect] To plot a function directly in the MathLive window alone it is then a simple matter of using DisplayFunction to redirect (rather than suppress) the output, using the setting "Live" for DisplayFunction. :[font = input; preserveAspect] Plot3D[x y, {x, -3, 3}, {y, -3, 3}, DisplayFunction -> Live] :[font = text; inactive; preserveAspect] To plot a function in both Mathematica and MathLive you just use the setting "Both" :[font = input; preserveAspect] Plot3D[x y, {x, -3, 3}, {y, -3, 3}, DisplayFunction -> Both] :[font = text; inactive; preserveAspect] For completeness we note that the setting to just display the graphic in Mathematica is DisplayFunction->$DisplayFunction. This is the default setting, we we note the form of $DisplayFunction. :[font = input; Cclosed; preserveAspect; startGroup] $DisplayFunction :[font = output; output; inactive; preserveAspect; endGroup] Display[$Display, #1] & ;[o] Display[$Display, #1] & :[font = text; inactive; preserveAspect; endGroup; endGroup] You should also see the section below on color management for other remarks on automation. :[font = section; inactive; Cclosed; preserveAspect; startGroup] Color Management in MathLive 2.0 :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Use of Graphics3D Conversion :[font = text; inactive; preserveAspect] MathLive 2.0 adds several new features, compared to previous versions of MathLive. In particular, Mathematica color Directives, expressed in terms of RGBColor, Hue and CMYKColor are all managed by MathLive 2.0. To effect this, it is necessary to send graphics in the form of Graphics3D objects. SurfaceGraphics objects with color directives will not be rendered properly by default. You need to do nothing with objects generated by the use of primitives, or, for example, with ParametricPlot3D, since these are already in the form of Graphics3D. However, graphics generated by Plot3D and ListPlot3D will need conversion. The following examples will suffice to show you various ways of getting nice colors. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] 8-bit vs 16-bit Graphics :[font = text; inactive; preserveAspect; endGroup; endGroup] The quality of the color rendering is influenced by the color depth support. Both Macintosh and Windows versions of MathLive support both 8-bit (256 colors) and 16-bit (thousands of colors) color schemes. (4-bit and 24-bit are also supported but are not recommended.) This will resulting in some banding on 8-bit systems, as MathLive chooses the nearest color from its internal palette. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Examples :[font = text; inactive; preserveAspect] Here are some examples of using color directives: :[font = input; preserveAspect] live = LinkOpen["MathLive", LinkMode -> Launch]; :[font = input; preserveAspect] plota = Plot3D[{Sin[x]*Cos[y], Hue[x y]}, {x, -3, 3}, {y, -3, 3}] :[font = input; preserveAspect] LinkWrite[live, Graphics3D[plota]] :[font = text; inactive; preserveAspect] The following example was suggested by Alfred Gray - here no conversion is needed. :[font = input; preserveAspect] cat = ParametricPlot3D[{Cos[u] Cosh[v], Cosh[v] Sin[u], v, Hue[Tanh[v^2]-1]}, {u, 0, 3 Pi/2}, {v, -1.5, 1.5}, PlotPoints -> {10,10}, Lighting -> False, Axes -> None, Boxed -> False] :[font = input; preserveAspect] LinkWrite[live, cat] :[font = text; inactive; preserveAspect] Note that options in the form of ColorFunction directives are also supported: :[font = input; preserveAspect] plotb = Plot3D[Sin[x]*Cos[y], {x, -3, 3}, {y, -3, 3}, ColorFunction -> (RGBColor[#,0,1-#]&)] :[font = input; preserveAspect; endGroup] LinkWrite[live, Graphics3D[plotb]] :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Automation with DisplayFunction :[font = text; inactive; preserveAspect] The conversion to Graphics3D can be automated and combined with the use of DisplayFunction, if we introduce new functions as follows: :[font = input; preserveAspect] LiveC = (LinkWrite[live, Graphics3D[N[#]]]&); BothC = (LinkWrite[live, Graphics3D[N[#]]]; Display[$Display,#])&; :[font = text; inactive; preserveAspect] Now the redirection to MathLive and conversion is handled automatically, as in the following: :[font = input; preserveAspect; endGroup] plotb = Plot3D[Sin[x]*Cos[y], {x, -3, 3}, {y, -3, 3}, ColorFunction -> (RGBColor[#,0,1-#]&), DisplayFunction -> BothC] :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Other Tip! :[font = text; inactive; preserveAspect; endGroup] Remember to send only numerical data to MathLive. This is especially important with using ListPlot3D applied to data created with Table. Use the N function to make all data numerical. This is implemented in our DisplayFunction options. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Grow and Zoom Boxes (Macintosh version) :[font = text; inactive; preserveAspect; endGroup; endGroup] In order to increase the screen area, we have hidden the grow box. It is still available and can be seen and used in the normal way by clicking on the bottom right hand corner of the screen. :[font = section; inactive; Cclosed; preserveAspect; startGroup] Getting Data into Mathematica and MathLive :[font = text; inactive; preserveAspect] It is straightforward to import data into Mathematica and hence to visualize the data in MathLive. We will look first at data stored as simple text, but possibly organized rather haphazardly. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Numbers Stored as Text :[font = text; inactive; preserveAspect] We have created a file "dataone.txt" that contains 16 numbers organized as a 4 by 4 table. You will find this file in the Notebooks folder where MathLive was installed. Copy it to your Mathematica directory. Let us first have a look at it: :[font = input; Cclosed; preserveAspect; startGroup] !! dataone.txt :[font = print; inactive; preserveAspect; endGroup] 1 1.023 2 3 1.5 1.6 2.1 3.1 2 2.5 2.5 4 2.1234 2.5678 2.7 4.000001 :[font = text; inactive; preserveAspect] We can read this into Mathematica with the simplest form of the ReadList command, to obtain the following: :[font = input; Cclosed; preserveAspect; startGroup] dataone = ReadList["dataone.txt", Real] :[font = output; output; inactive; preserveAspect; endGroup] {1., 1.023, 2., 3., 1.5, 1.6, 2.1, 3.1, 2., 2.5, 2.5, 4., 2.1234, 2.5678, 2.7, 4.000001000000001} ;[o] {1., 1.023, 2., 3., 1.5, 1.6, 2.1, 3.1, 2., 2.5, 2.5, 4., 2.1234, 2.5678, 2.7, 4.000001} :[font = text; inactive; preserveAspect] Notice that the second argument of ReadList tells Mathematica what type of data we are reading, in this case, the type is Real. In "dataone.txt", the numbers were stored four per line. By using the simplest form of ReadList we have lost this structure, but it is simple to reorganize our data by using the Partition command, and once we have done so it can be sent straight down the link to MathLive: :[font = input; Cclosed; preserveAspect; startGroup] datatwo = Partition[dataone,4] :[font = output; output; inactive; preserveAspect; endGroup] {{1., 1.023, 2., 3.}, {1.5, 1.6, 2.1, 3.1}, {2., 2.5, 2.5, 4.}, {2.1234, 2.5678, 2.7, 4.000001000000001}} ;[o] {{1., 1.023, 2., 3.}, {1.5, 1.6, 2.1, 3.1}, {2., 2.5, 2.5, 4.}, {2.1234, 2.5678, 2.7, 4.000001}} :[font = input; preserveAspect] datatwoplot = ListPlot3D[datatwo,DisplayFunction -> Identity]; :[font = input; preserveAspect] LinkWrite[live, datatwoplot] :[font = text; inactive; preserveAspect] A better method is to let Mathematica sort out the structure of the file itself, assuming that each line contains a new record entry: :[font = input; Cclosed; preserveAspect; startGroup] datatwo = ReadList["dataone.txt",Real, RecordLists -> True] :[font = output; output; inactive; preserveAspect; endGroup] {{1., 1.023, 2., 3.}, {1.5, 1.6, 2.1, 3.1}, {2., 2.5, 2.5, 4.}, {2.1234, 2.5678, 2.7, 4.000001000000001}} ;[o] {{1., 1.023, 2., 3.}, {1.5, 1.6, 2.1, 3.1}, {2., 2.5, 2.5, 4.}, {2.1234, 2.5678, 2.7, 4.000001}} :[font = text; inactive; preserveAspect] This is fine if each line of your data file corresponds to a sublist. This may not be the case, for example, if each record in your data file contains so many numbers that a record does not fit onto a single line. However, you can use the Table command to do the job for you, and this may be used to impose the appropriate list structure: :[font = input; Cclosed; preserveAspect; startGroup] datatwo = ReadList["dataone.txt", Table[Real, {4}]] :[font = output; output; inactive; preserveAspect; endGroup] {{1., 1.023, 2., 3.}, {1.5, 1.6, 2.1, 3.1}, {2., 2.5, 2.5, 4.}, {2.1234, 2.5678, 2.7, 4.000001000000001}} ;[o] {{1., 1.023, 2., 3.}, {1.5, 1.6, 2.1, 3.1}, {2., 2.5, 2.5, 4.}, {2.1234, 2.5678, 2.7, 4.000001}} :[font = text; inactive; preserveAspect] Indeed, this approach may be used to impose a different organizational structure. Here, for example, we group the data into pairs: :[font = input; Cclosed; preserveAspect; startGroup] datathree = ReadList["dataone.txt", Table[Real, {2}]] :[font = output; output; inactive; preserveAspect; endGroup] {{1., 1.023}, {2., 3.}, {1.5, 1.6}, {2.1, 3.1}, {2., 2.5}, {2.5, 4.}, {2.1234, 2.5678}, {2.7, 4.000001000000001}} ;[o] {{1., 1.023}, {2., 3.}, {1.5, 1.6}, {2.1, 3.1}, {2., 2.5}, {2.5, 4.}, {2.1234, 2.5678}, {2.7, 4.000001}} :[font = text; inactive; preserveAspect; endGroup] In any case, the Mathematica data sets, or lists, datatwo and datathree, may be given to ListPlot3D and thence to MathLive. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Tabs as Separators :[font = text; inactive; preserveAspect; endGroup] Some packages such as spreadsheets separate data items with tab marks. This can also be achieved with languages such as FORTRAN if you use a CHAR(9) (tab) as your field separator. This format presents no problem for ReadList since tabs are treated like one or more spaces. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Commas as Separators (CSV files) :[font = text; inactive; preserveAspect] Sometimes, a file may contain data separated by characters other than spaces or tabs. This is typical of older spreadsheet packages. In the following file, entries on the same line are separated by commas: :[font = input; Cclosed; preserveAspect; startGroup] !!example.csv :[font = print; inactive; preserveAspect; endGroup] 1.2E2, 3.4E2, 433 67.45466E1, 0.003456E5, 12353E-2 123, 456, 789 :[font = text; inactive; preserveAspect] The simplest way to read this file into Mathematica is to use the RecordLists facility, telling Mathematica that records may be separated by either a comma or a newline character ("\n"): :[font = input; Cclosed; preserveAspect; startGroup] datafour = ReadList["example.csv",Real,RecordLists -> True, RecordSeparators->{"\n", ","}] :[font = output; output; inactive; preserveAspect; endGroup] {{120.}, {340.}, {433.}, {674.5466000000001}, {345.5999999999999}, {123.53}, {123.}, {456.0000000000001}, {789.0000000000001}} ;[o] {{120.}, {340.}, {433.}, {674.547}, {345.6}, {123.53}, {123.}, {456.}, {789.}} :[font = text; inactive; preserveAspect] We Flatten this list, to remove the trivial lists of length one, and then regroup the data into triples by using the Partition function: :[font = input; Cclosed; preserveAspect; startGroup] Partition[Flatten[datafour], 3] :[font = output; output; inactive; preserveAspect; endGroup] {{120., 340., 433.}, {674.5466000000001, 345.5999999999999, 123.53}, {123., 456.0000000000001, 789.0000000000001}} ;[o] {{120., 340., 433.}, {674.547, 345.6, 123.53}, {123., 456., 789.}} :[font = text; inactive; preserveAspect; endGroup] A Mathematica convention is that numbers are treated as exact unless they contain a decimal point. Thus, 12353E-2 is treated as 12353/100. You should always use Real (rather than Number) in order to ensure that MathLive always receives purely numerical information rather than structures such as fractions! :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Reading Binary Files :[font = text; inactive; preserveAspect] All the files that we have dealt with in this chapter have been ASCII files; that is, they only contain text characters. Mathematica possesses facilities for both reading in and writing to binary files in the package Utilities`BinaryFiles`. You should consult the package's documentation for further information about how this works. It is loaded with the following command: :[font = input; preserveAspect] Needs["Utilities`BinaryFiles`"] :[font = text; inactive; preserveAspect] We can use a variant of the ReadList command, known as ReadListBinary, to pull binary data into Mathematica. As usual, we must specify the data types that we are reading in. Here is a simple example where we have a rather peculiar file consisting of triples of numbers. The first and third numbers in each triple are 2-byte (signed) integers, which fall into the Mathematica category Int16, whereas the middle number is an 8-byte real number that is categorized as a Mathematica Double: :[font = input; Cclosed; preserveAspect; startGroup] pointdata = ReadListBinary["data.bin", {Int16, Double, Int16}] :[font = output; output; inactive; preserveAspect; endGroup] {{1, 0.841470984807897, 1}, {2, 0.909297426825682, 4}, {3, 0.1411200080598672, 9}, {4, -0.7568024953079283, 16}, {5, -0.958924274663139, 25}} ;[o] {{1, 0.841471, 1}, {2, 0.909297, 4}, {3, 0.14112, 9}, {4, -0.756802, 16}, {5, -0.958924, 25}} :[font = text; inactive; preserveAspect] Having coped with this rather bizarre data set, we can construct a scatter plot very easily. There are several ways of doing this. If you load the "Graphics3D" package, you can just use ScatterPlot3D. Alternatively, if you like using graphics primitives, why not try the following: :[font = input; preserveAspect] pts3d = Map[Point, pointdata]; Show[Graphics3D[pts3d]]; :[font = text; inactive; preserveAspect; endGroup; endGroup] and send the result to MathLive. :[font = section; inactive; Cclosed; preserveAspect; startGroup] Live Miscellanea and Power User Tips :[font = text; inactive; preserveAspect] In this section we present a collection of hints and tips for making the most of MathLive. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Exporting MathLive Graphics :[font = text; inactive; preserveAspect; endGroup] Although MathLive is designed primarily as an on-screen visualization tool, it is straightforward to export graphics from MathLive, by using simple screen capture techniques. The images in the printed manual were created using the Macintosh built-in system screen capture tools. With the MathLive window open and active, use the key sequence SHIFT-COMMAND-3 to capture the screen to a Macintosh PICT file on disk. This may be opened by most graphics applications. It can also be viewed by the TeachText application supplied with Macintosh System 7.x, and sections of the image can be copied to the clipboard and system Scrapbook. In MathLive 1.6 and later, you can copy portions of an image direct to the Macintosh clipboard. Since, in MathLive, the option, command and shift modifier keys are used with the mouse to control the object and camera manipulation functions, activation of the mouse as a region selection tool is obtained by holding down the control (ctrl) key. The scene manipulation functions are then disabled and you can select a rectangular region. The Edit menu (version 1.6 or later only) then allows this portion of the i mage to be copied to the clipboard. On a Windows PC (version 2.0 or later), a region may be selected by holding down 'C' in conjunction with the left mouse button. Use either the Edit menu or Ctrl-C to copy the selected region to the clipboard. As a practical point, if you work in a mixed Macintosh-Windows environment, you may like to know that full window capture under Windows is available by using the key sequence ALT-PRINT-SCREEN to capture the active MathLive window to the Windows clipboard. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Using MathLive with Excel via Mathematica :[font = text; inactive; preserveAspect; endGroup; endGroup] If you have the MathLink for Microsoft Excel kit you can use MathLive to do real-time graphics with Excel spreadsheet data. Your ``Notebook, Shapes & Textures'' disk contains an Excel worksheet and a macrosheet entitled `LIVEDEMO.XLS' and ``LIVEDEMO.XLM' respectively, that illustrate how Excel, Mathematica and MathLive can be used together. We suggest that you place these in the same folder as the demonstration files that came with your MathLink for Microsoft Excel kit. The Excel program replaces the NoteBook front end in this set-up, and we can use Excel macros to start MathLive and to pass Excel data to the Mathematica kernel, and thence to MathLive. Please consult the documentation that came with the \MathLink\ for Microsoft Excel kit and ensure that you have arranged matters so that Excel and the Mathematica kernel are communicating appropriately. In outline, the steps for doing this are 1. Ensure that an alias of the Mathematica kernel, renamed ``MathKernel'', is placed in the Excel ``Macro Library'' Folder, along with ``MathLink.xla''. 2. Start Excel and load ``MathLink.xla''. 3. Loading ``MathLink.xla'' should provide an additional menu entitled ``MathLink''. Choose ``Open MathLink'' from this menu and select the kernel (the default communications should be the correct ones if you are using a local kernel). 4. Open one of the example files supplied with the kit and check that all is well. You are now ready to start using MathLive. Open the macro sheet ``LIVEDEMO.XLM'' and then the worksheet ``LIVEDEMO.XLS''. The top left cell contains the name of an alias of the MathLive program that is available to Mathematica . (You may replace this with a full path to the program if you prefer not to use aliases.) Before starting MathLive itself, you should acquaint yourself with some of the macro buttons in the ``LIVEDEMO.XLS'' worksheet. To make matters simpler, we have used the Mathematica link to d efine some macros that automatically populate the right portion of the worksheet, usingMathematica Table commands to fill the cells down and to the right of F1. This, of course, can be any Excel data array. If you click on the cell B1 you can edit the first of two Table commands that carry out the population of the cells. While you are learning how to proceed, you might consider just changing the range of say x, and follow this be clicking on the button ``CREATE SURFACE DATA''. Note that cells B12 and B13 show you just how many rows and columns of data you have created. Similarly, by editing the cell B7, (which has essentially the same function as B1) you can populate the worksheet with different types of data. Take some time to explore how the B1 or B7 cells, with the buttons in column C, may be used to fill the worksheet with different types of data. You may also wish to consult the macro sheet, to see how the macros associated with B1 and B7 (``FILLARRAY'' and ``COLARRAY'') are constructed. When you are satisfied with the population functions, it is time to start MathLive. Do this by clicking on the button ``START LIVE''. Do not bring MathLive to the foreground yet. Now use the ``CREATE SURFACE DATA'' button to populate the spreadsheet, and follow this with a click on the ``LIVE SURFACE PLOT'' button. After a few moments, the surface will appear in the MathLive window and you may manipulate it in the usual way. If you wish to kill the link to MathLive at any time, bring the ``LIVEDEMO.XLS'' to the foreground, and click on the ``CLOSE LINK'' button. Then go to the MathLive window and choose ``Quit'' from the file menu. You may restart MathLive and re-establish the link with the ``START LIVE'' button later. This system may be used in conjunction with Mathematica programs to define custom graphics. As an illustration, we have created a simple program in the file ``colplot.ma'', that takes an array and converts it into a 3-dimensional bar chart using polygon primitives. This may be activated with the ``LIVE COLUMN PLOT'' button. Make sure the ``colplot.ma'' file can be found by the kernel, for example by placing the file in the same directory as the kernel. This is only a brief introduction to what is possible using multiple MathLink processes, such as the Excel-Mathematica -MathLive set-up. :[font = section; inactive; Cclosed; preserveAspect; startGroup] Graphics Workshop :[font = text; inactive; preserveAspect] Here we will suggest a few examples to try out with MathLive.The first examples concern the theory of minimal surfaces, soap bubbles. Such surfaces may be generated very simply by writing down a (holomorphic) function of a complex variable. Knots also benefit greatly from the use of MathLive, since the ability of do real-time rotations gives a much better sense of the connectivity or "knotting" properties. Next we will consider the visualization of some "pathological" functions used to show how some co mmon theorems (or indeed common sense!) may be violated. In all of the following examples, where MathLink support is assumed, we assume that a link entitled live has been opened. All these examples work equally well whether they are passed down a link or sent to MathLive via a file. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Minimal Surfaces :[font = text; inactive; preserveAspect] Minimal surfaces, or soap bubbles, are surfaces of least area amongst all those satisfying some boundary condition (such as that the edge of the bubble is given by the shape of a wire frame that is dipped in the soap). Locally, all such surfaces may be parameterized in terms of functions of a complex variable. If f(z) is our function, the coordinates of our surface are given parametrically in terms of the real variables u, v , where z = u + iv, by x(u, v) = Re[(w^2 - 1) f''[w] - 2wf'[w] + 2f] y(u,v) = Re[i((w^2 + 1)f''[w] - 2wf'[w] + 2f)] z(u,v) = Re[2wf''[w] - 2f'[w]] It is a relatively straightforward matter to get Mathematica to work out the equation of the surface, parameterized by coordinates u, v. The following module defines a function MiniCartPlot[f, {a, b}, {c, d}, n], where f is the complex function to be used (expressed in terms of w), {a, b}, {c, d} give the ranges of u and v respectively, and the optional parameter n, which defaults to 15, is the number of plot points to be used. :[font = input; preserveAspect] MiniCartPlot[f_, {a_, b_}, {c_, d_}, n_:15] := Module[{x, y, z, u, v, comppoint, paracomppoint, realpoint}, x[w_] := (w^2 - 1) D[f, {w, 2}] - 2 w D[f, w] + 2 f; y[w_] := I ((w^2 + 1) D[f, {w, 2}] - 2 w D[f, w] + 2 f); z[w_] := 2 w D[f, {w, 2}] - 2D[f, w]; comppoint = Evaluate[{x[w], y[w], z[w]}]; paracomppoint = comppoint /. w -> u + I v; realpoint[u_, v_] = Expand[ComplexExpand[Re[paracomppoint]]]; ParametricPlot3D[Evaluate[ realpoint[u, v]], {u, a, b}, {v, c, d}, PlotPoints -> n, Axes -> False] ] :[font = input; preserveAspect] enneper = MiniCartPlot[w^3, {-4, 4}, {-4, 4}] :[font = input; preserveAspect] LinkWrite[live, enneper] :[font = text; inactive; preserveAspect] (or) :[font = input; preserveAspect] ThreeScript["enneper.ts", enneper] :[font = text; inactive; preserveAspect] In our first example we used Cartesian coordinates. In other cases it may be more useful to use polar coordinates. The following defines a Mathematica module that uses (stretched) polar coordinates. :[font = input; preserveAspect] MiniPolarPlot[f_, {a_, b_}, {c_, d_}, n_:15] := Module[{x, y, z, u, v, comppoint, paracomppoint, realpoint}, x[w_] := (w^2 - 1) D[f, {w, 2}] - 2 w D[f, w] + 2f; y[w_] := I ((w^2 + 1) D[f, {w, 2}] - 2 w D[f, w] + 2 f); z[w_] := 2 w D[f, {w, 2}] - 2D[f, w]; comppoint = Evaluate[{x[w], y[w],z[w]}]; paracomppoint = comppoint /. w -> Exp[u + I v]; realpoint[u_, v_] = Expand[ComplexExpand[Re[paracomppoint]]]; ParametricPlot3D[Evaluate[realpoint[u, v]], {u,a,b},{v,c,d}, PlotPoints -> n, Axes -> False] ] :[font = input; preserveAspect] catenoid = MiniPolarPlot[w*Log[w], {-2, 2}, {0, 2 Pi}] :[font = input; preserveAspect] LinkWrite[live, catenoid] :[font = text; inactive; preserveAspect] (or) :[font = input; preserveAspect] ThreeScript["catenoid.ts" catenoid] :[font = text; inactive; preserveAspect; endGroup] Many interesting surfaces may be generated in this way. You should consider choosing other functions, such as w^ n, n >= 4, and transcendental functions, and explore the resulting geometry with MathLive. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Knots :[font = text; inactive; preserveAspect] The generation of various types of knot is covered in a delightful NoteBook that is supplied with recent versions of Mathematica. If you look in the folder entitled "Notebooks" (if you did not install this, the file is on one of your Mathematica master disks) you should find a file "knot.ma" containing various definitions of functions that generate knots. Here we just give one example, that makes use of the tube function defined in that notebook. We have reproduced this below for your convenience. Make s ure that you have entered the definition of tube before attempting the following: :[font = input; preserveAspect] plotknot[p_, q_, col_:.5] := Show[tube[ {Cos[t] (1 + .5 Cos[(q/p) t]), Sin[t] (1 + .5 Cos[(q/p) t]), .5 Sin[(q/p) t]}, {t, 0, 2 Pi p, 50}, 8, .1], ViewPoint -> {0, 0, 1}, Boxed -> False, LightSources -> {{{0, 0, 1}, RGBColor[col, 1-col, col/2]}}] :[font = input; preserveAspect] myknot = plotknot[2, 5] :[font = input; preserveAspect] LinkWrite[live, myknot] :[font = text; inactive; preserveAspect] (or) :[font = input; preserveAspect; endGroup] ThreeScript["myknot.ts", myknot] :[font = section; inactive; Cclosed; preserveAspect; startGroup] Implementation of Tube :[font = input; preserveAspect] Off[General::spell1] :[font = input; preserveAspect] tube::usage = "tube[function, {t, tmin, tmax, tnum}, circnum, radius, options] generates a tube with given radius about the curve defined by the given function of t. The mesh of the tube has circum vertices in the meridian direction and tnum vertices in the longitudinal direction."; :[font = input; preserveAspect] Unitize[a_] := N[a / Sqrt[a.a]] :[font = input; preserveAspect] Angle[A_List, B_List] := ArcCos[Unitize[A] . Unitize[B]] :[font = input; preserveAspect] Cross[v1_?VectorQ, v2_?VectorQ] := Module[{m=Minors[{v1,v2},2][[1]]}, {m[[3]], -m[[2]], m[[1]]} ] /; Length[v1]==Length[v2]==3 :[font = input; preserveAspect] MakePolygons[vl_List] := Block[{l = vl, l1 = Map[RotateLeft, vl], numesh}, numesh = {l, RotateLeft[l], RotateLeft[l1], l1}; numesh = Map[Drop[#, -1]&, numesh, {1}]; numesh = Map[Drop[#, -1]&, numesh, {2}]; Polygon /@ Transpose[ Map[Flatten[#, 1]&, numesh] ] ] :[font = input; preserveAspect] tube[function_, {t_, tmin_, tmax_, tnum_}, cnum_, radius_, options___] := Block[ {tpoints, npoints, gvec = N[(1/Sqrt[3]) {1.0, 1.0, 1.0}], vpoints, xpoints, error, scpoints, mesh}, tpoints = Table[N[function], {t, tmin, tmax, (tmax - tmin)/tnum}]; If[closed, tpoints[[-1]] = tpoints[[1]]]; npoints = Map[Unitize, Table[Evaluate[D[function, t]], {t, tmin, tmax, (tmax - tmin)/tnum}]//N ]; If[closed, npoints[[-1]] = npoints[[1]]]; vpoints = Map[Unitize, Map[ (gvec -= (gvec . #) #)&, npoints ] ]; xpoints = Map[Unitize, Map[ Apply[Cross, #]&, Transpose[{npoints, vpoints}] ] ]; error = Angle[vpoints[[1]], vpoints[[-1]]]; Do[ {vpoints[[i]], xpoints[[i]]} = N[ ({{#1,#2},{-#2,#1}} . {vpoints[[i]], xpoints[[i]]})& [Cos[error(i-1)/tnum], Sin[error(i-1)/tnum]] ], {i, 1, tnum+1} ]; If[closed, vpoints[[-1]] = vpoints[[1]]; xpoints[[-1]] = xpoints[[1]]]; scpoints = Table[N[{Cos[t], Sin[t]} radius], {t, 0, 2Pi, 2Pi/cnum}]; mesh = Table[ tpoints[[i]] + scpoints[[j]] . {vpoints[[i]], xpoints[[i]]}, {j, 1, cnum+1}, {i, 1, tnum+1} ]; shape = MakePolygons[mesh] //Graphics3D ] :[font = input; preserveAspect] Options[tube] = {closed->True}; :[font = input; preserveAspect] On[General::spell1] :[font = input; preserveAspect; endGroup] :[font = section; inactive; Cclosed; preserveAspect; startGroup] Credits :[font = text; inactive; preserveAspect] By P. Boyland and S. Dickson :[font = smalltext; inactive; preserveAspect; backColorRed = 32768; backColorGreen = 32768; backColorBlue = 32768; fontSize = 9; endGroup] Copyright 1991-93 Wolfram Research, Inc. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Pathological Functions :[font = text; inactive; preserveAspect] MathLive can be used to gain a better understanding of the geometry of functions of two variables. We have already explored some functions of a complex variable, considered parametrically as functions of two real variables. In courses on analysis we are often interested in functions that fail to satisfy certain conditions of continuity and differentiability at isolated points. MathLive is an excellent tool for understanding such functions. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] A Function Discontinuous at One Point :[font = text; inactive; preserveAspect] The function given by z(0, 0) = 0 and elsewhere z( x, y) = xy / (x^2 + y^2) can easily be written down in Mathematica, and we can use this to do plots. :[font = input; preserveAspect] z[x_, y_] := x y/( x^2 + y^2) /; x != 0 && y != 0; z[x_, y_] := 0 /; x = 0 && y =0; :[font = text; inactive; preserveAspect] In fact, the use of polar coordinates is recommended for creating smooth plots, and for plotting we introduce the following form (the threshold value of 0.0001 can be adjusted downwards if necessary): :[font = input; preserveAspect] Z[r_, t_] := Which[r <= 0.0001, 0, True, Sin[2 t]/2]; :[font = text; inactive; preserveAspect] This is followed by a parametric plot and a visit to MathLive. :[font = input; preserveAspect] discont = ParametricPlot3D[{r Cos[t], r Sin[t], 2*Z[r, t]}, {r, 0, 2}, {t, 0, 2 Pi}, PlotPoints -> {20, 30}] :[font = input; preserveAspect] LinkWrite[live, discont] :[font = text; inactive; preserveAspect] (or) :[font = input; preserveAspect; endGroup] ThreeScript["discont.ts", discont] :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] A Function Not Differentiable at One Point :[font = text; inactive; preserveAspect] The following function has the property that it is not differentiable at the origin, but nevertheless both partial derivatives exist there, and furthermore it is differentiable along any line through the origin! :[font = text; inactive; preserveAspect] w(x,y) = x^3 / (x^2 + y^2) :[font = input; preserveAspect] W[r_, t_] := Which[r <= 0.0001, 0, True, r Cos[t]^3]; nondiff = ParametricPlot3D[{r Cos[t], r Sin[t],W[r, t]}, {r, 0, 2}, {t, 0, 2 Pi}, PlotPoints -> {20, 30}] :[font = text; inactive; preserveAspect] When we send the results to MathLive, it becomes straightforward, by adjusting the orientation of the surface, to see that the surface fails to have a tangent plane at the origin, in spite of the fact that the surface has a linear appearance along any line through the origin. :[font = input; preserveAspect] LinkWrite[live, nondiff] :[font = text; inactive; preserveAspect] (or) :[font = input; preserveAspect; endGroup; endGroup; endGroup] ThreeScript["nondiff.ts", nondiff] :[font = section; inactive; preserveAspect; startGroup] Product Support :[font = text; inactive; preserveAspect; cellOutline; endGroup] If you have experienced any problems or have any comments or suggestions regarding MathLive, please feel at liberty to contact us. MathLive is under constant development and we are always happy to receive constructive feedback from our users. Milo Hedge Limited 6 The Isis Business Centre Pony Road Oxford OX4 2RD UK Tel: +44 1865 771836 Fax: +44 1865 771853 email: support@milohedge.com :[font = section; inactive; Cclosed; preserveAspect; startGroup] Terms and footnotes :[font = text; inactive; initialization; preserveAspect; endGroup; endGroup] Terms 3Script. A proprietary file format used by Mathematica to save object information. Diffuse. The degree of 'dullness' or 'mattness' of an object. Specular. The degree of 'shininess' of an object. Ambient. A constant background level of white light. Textures. A 2D image which can be used to cover the surface of a 3D object. Shading. Objects may be shaded so that you can see the facets (flat) or not (smooth). Surfacecolor. Surface color can be set to to a solid color or to a multicolored patchwork (zippy). Opacity. The degree of opaqueness of an object, the higher the value the more opaque the object. Mathlink. A proprietary process-to-process protocol created by Wolfram Research Inc. Clipboard. The temporary 'holding place' by which information may be passed between processes running on the Macintosh. Camera. An abstract device used to represent the observer's viewpoint. Light. The light may be positioned anywhere on a sphere surrounding the scene. FootNotes The scene contains a single directional white light source. It behaves like a sun (i.e., a bright point source a very large distance away). The object may be rotated with the mouse along any axis parallel with the screen. The object has momentum and will continue to rotate once the button has been released. Note that only the selected object has this behaviour. The object can be dragged aound the scene parallel to the plane of the display screen. Vertical motion of the mouse will move the object towards or away from the display screen. Moving the mouse downwards will bring the object nearer the screen. Horizontal motion of the mouse will pan the camera around the scene. The camera is moved in a circle and always faces the origin. Vertical motion of the mouse will move the camera forwards or backwards. Moving the mouse downwards will move the camera forwards. ^*)