Spin`Algebra

Spin`Algebra — Magnetic Resonance with Mathematica
 

ViewPointSelect Guide

About

The realization of three-dimensional graphics in Mathematica doesn't support free rotation and high quality rendering the picture simultaneously. One has to change either manually the option ViewPoint and repeat rendering the graphics or to use the package RealTime3D` which supports library OpenGL and has some limitations. The package ViewPointSelect` combines these two alternatives. It provides an easy way to choose interactively view point of 3D graphics in Mathematica and redraw the result by standard Mathematica functions. The package supports graphical objects SurfaceGraphics and Graphics3D and functions Plot3D and ListPlot3D, ParametricPlot3D, etc.

© Yuri E. Kandrashkin, 2006

Credits

This package was greatly improved based on the comments by David Park and Ingolf Dahl.

The package uses the algorithm of intercommunications between the Kernel and FrontEnd initially realized in the package Replot.

Highlights

• Interactive selection of ViewPoint of the chosen 3D graphics by real time rotation
• Support graphics objects SurfaceGraphics and Graphics3D
• User expandable list of supported plot functions
• Toggle to copy the picked value of ViewPoint to clipboard
• Selection of ViewPoint on the stage of the editing by menu or keyboard shortcut command

ViewPointSelect as a function

In the following it is assumed that the package is intalled as it described in the file Intallation.nb.

This loads the package if it has not been loaded

[Graphics:img/guide_1.gif]

The main function of the the package is ViewPointSelect. The following gives the information:

[Graphics:img/guide_2.gif]

[Graphics:img/guide_3.gif]

Execution of an example opens a new notebook ViewPointSelect Window with 3D graphics. Choose a new ViewPoint by dragging any point within the graphics.

[Graphics:img/guide_4.gif]

[Graphics:img/guide_5.gif]

There are three buttons to return to the initial notebook:
[ViewPoint] – returns the chosen ViewPoint
[Ok] – plots the current version of the graphics
[Cancel] – plots graphics with default ViewPoint.

It is important to mention that the function ViewPointSelect is interactive and it interrupts temporally the computation. If there is no action (changes of position of graphics) within 60 seconds, it would automatically close the opened window and return the control to the main notebook.

There is special feature which allows copying the final version of ViewPoint to the clipboard. The property is controlled by option CopyToClipboard. To activate it press on the box in the upper-right corner of window. This action equivalent to evaluation of the expression:

[Graphics:img/guide_6.gif]

This button has two values so to reactivate option CopyToClipboard press on this box again.

The parameter $PlotFunctions fixes the plot functions which can be used as arguments of ViewPointSelect.

[Graphics:img/guide_7.gif]

The expression Show[Graphics3D[...]] is supported in addition to this list. $PlotFunctions can be expanded. Next cell demonstartes how new function can be included and used:

[Graphics:img/guide_8.gif]

[Graphics:img/guide_9.gif]

[Graphics:img/guide_10.gif]

[Graphics:img/guide_11.gif]

[Graphics:img/guide_12.gif]

In general the function ViewPointSelect acts as any standard Mathematica function. Thus buttons [Ok] and [Cancel] return graphic objects and button [ViewPoint] returns the value of option as typical output. Another example, if the option ViewPoint is applied the resulting graphics would alwais use this value:

[Graphics:img/guide_13.gif]

Action via menu or keyboard shortcut command

The different approach is used if ViewPointSelect is called via menu or keyboard shortcut command. In this case ViewPointSelect doesn't generate an output cell but changes the input cell.

To launch ViewPointSelect select a function producing 3D graphics (Plot3D, ListPlot3D, ParametricPlot3D, etc. ) or place coursor just after it and apply the menu command or the key combination ([CTRL]-[ALT]-[v] for Windows). (Note that this will work only if the cursor will remain in the same position of the editing notebook while the dialog window is open.) For example, if the cursor is placed at the end of the following expression:

[Graphics:img/guide_14.gif]

the described action opens the new window

[Graphics:img/guide_15.gif]

The main buttons have different meaning  now:
[Copy] – copies the ViewPoint to the clipboard
[Ok] – insert the chosen ViewPoint value into the plot expression
[Cancel] – closes ViewPointSelect window without any additional action

The selected option will be placed at the end of expression:

[Graphics:img/guide_16.gif]

Note, the menu and shortcut command doesn't work in cells with format type InputForm.

Shortcut command can be applied directly to Show[Graphics3D[...]] expression if graphics object is defined in the function Show or evaluated before the application of the command. For example the ViewPointSelect command can be applied to selected expression Show[gr,Boxed→False] of the following cell only if gr has been defined in the current Mathematica session as Graphics3D object:

[Graphics:img/guide_17.gif]

[Graphics:img/guide_18.gif]

[Graphics:img/guide_19.gif]

One final remark, in the cases when Graphics3D primitive Polygon has two identical points or when some points lay in the area restricted by other points the rendering in RealTime3D mode might lead to crutial error. For more information refer to the package TaggedCells by Ingolf Dahl.



   Last modified: August 10, 2006