Maxima 5.44.0 Manual: Visualization with VTK

Previous: Graphical analysis of discrete dynamical systems, Up: dynamics-pkg [Contents][Index]

### 55.3 Visualization with VTK

Function scene creates 3D images and animations using the Visualization ToolKit (VTK) software. In order to use that function, Xmaxima and VTK should be installed in your system (including the TCL bindings of VTK, which in some system might come in a separate package).

Function: scene (objects, …, options, …);

  Accepts an empty list or a list of several `objects` and `options`. The program launches Xmaxima, which opens an external window representing the given objects in a 3-dimensional space and applying the options given. Each object must belong to one of the following 4 classes: sphere, cube, cylinder or cone (see `Scene objects`). Objects are identified by giving their name or by a list in which the first element is the class name and the following elements are options for that object.

  Example. A hexagonal pyramid with a blue background:

      (%i1) scene(cone, [background,"#9980e5"])$

  By holding down the left button of the mouse while it is moved on the graphics window, the camera can be rotated showing different views of the pyramid. The two plot options `elevation` and `azimuth` can also be used to change the initial orientation of the viewing camera. The camera can be moved by holding the middle mouse button while moving it and holding the right-side mouse button while moving it up or down will zoom in or out.

  Each object option should be a list starting with the option name, followed by its value. The list of allowed options can be found in the `Scene object's options` section.

  Example. This will show a sphere falling to the ground and bouncing off without losing any energy. To start or pause the animation, press the play/pause button.

      (%i1) p: makelist ([0,0,2.1- 9.8*t^2/2], t, 0, 0.64, 0.01)$

      (%i2) p: append (p, reverse(p))$

      (%i3) ball: [sphere, [radius,0.1], [thetaresolution,20],
        [phiresolution,20], [position,0,0,2.1], [color,red],
        [animate,position,p]]$

      (%i4) ground: [cube, [xlength,2], [ylength,2], [zlength,0.2],
        [position,0,0,-0.1],[color,violet]]$

      (%i5) scene (ball, ground, restart)$

  The restart option was used to make the animation restart automatically every time the last point in the position list is reached. The accepted values for the colors are the same as for the `color` option of plot2d.

  ·

  Categories: Package dynamics ·Plotting

#### 55.3.1 Scene options

Scene option: azimuth [azimuth, angle]

  Default value: `135`

  The rotation of the camera on the horizontal (x, y) plane. angle must be a real number; an angle of 0 means that the camera points in the direction of the y axis and the x axis will appear on the right.

  ·

  Categories: Package dynamics ·Plotting

Scene option: background [background, color]

  Default value: `black`

  The color of the graphics window’s background. It accepts color names or hexadecimal red-green-blue strings (see the `color` option of plot2d).

  ·

  Categories: Package dynamics ·Plotting

Scene option: elevation [elevation, angle]

  Default value: `30`

  The vertical rotation of the camera. The angle must be a real number; an angle of 0 means that the camera points on the horizontal, and the default angle of 30 means that the camera is pointing 30 degrees down from the horizontal.

  ·

  Categories: Package dynamics ·Plotting

Scene option: height [height, pixels]

  Default value: `500`

  The height, in pixels, of the graphics window. pixels must be a positive integer number.

  ·

  Categories: Package dynamics ·Plotting

Scene option: restart [restart, value]

  Default value: `false`

  A true value means that animations will restart automatically when the end of the list is reached. Writing just “restart” is equivalent to [restart, true].

  ·

  Categories: Package dynamics ·Plotting

Scene option: tstep [tstep, time]

  Default value: `10`

  The amount of time, in mili-seconds, between iterations among consecutive animation frames. time must be a real number.

  ·

  Categories: Package dynamics ·Plotting

Scene option: width [width, pixels]

  Default value: `500`

  The width, in pixels, of the graphics window. pixels must be a positive integer number.

  ·

  Categories: Package dynamics ·Plotting

Scene option: windowname [windowtitle, name]

  Default value: `.scene`

  name must be a string that can be used as the name of the Tk window created by Xmaxima for the `scene` graphics. The default value `.scene` implies that a new top level window will be created.

  ·

  Categories: Package dynamics ·Plotting

Scene option: windowtitle [windowtitle, name]

  Default value: `Xmaxima: scene`

  name must be a string that will be written in the title of the window created by `scene`.

  ·

  Categories: Package dynamics ·Plotting

#### 55.3.2 Scene objects

Scene object: cone [cone, options]

  Creates a regular pyramid with height equal to 1 and a hexagonal base with vertices 0.5 units away from the axis. Options `height` and `radius` can be used to change those defaults and option `resolution` can be used to change the number of edges of the base; higher values will make it look like a cone. By default, the axis will be along the x axis, the middle point of the axis will be at the origin and the vertex on the positive side of the x axis; use options `orientation` and `center` to change those defaults.

  Example. This shows a pyramid that starts rotating around the z axis when the play button is pressed.

      (%i1) scene([cone, [orientation,0,30,0], [tstep,100],
         [animate,orientation,makelist([0,30,i],i,5,360,5)]], restart)$

  ·

  Categories: Package dynamics ·Plotting

Scene object: cube [cube, options]

  A cube with edges of 1 unit and faces parallel to the xy, xz and yz planes. The lengths of the three edges can be changed with options `xlength`, `ylength` and `zlength`, turning it into a rectangular box and the faces can be rotated with option `orientation`.

  ·

  Categories: Package dynamics ·Plotting

Scene object: cylinder [cylinder, options]

  Creates a regular prism with height equal to 1 and a hexagonal base with vertices 0.5 units away from the axis. Options `height` and `radius` can be used to change those defaults and option `resolution` can be used to change the number of edges of the base; higher values will make it look like a cylinder. The default height can be changed with the option `height`. By default, the axis will be along the x axis and the middle point of the axis will be at the origin; use options `orientation` and `center` to change those defaults.

  ·

  Categories: Package dynamics ·Plotting

Scene object: sphere [sphere, options]

  A sphere with default radius of 0.5 units and center at the origin.

  ·

  Categories: Package dynamics ·Plotting

#### 55.3.3 Scene object’s options

Object option: animation [animation, property, positions]

  property should be one of the following 4 object’s properties: `origin`, `scale`, `position` or `orientation` and positions should be a list of points. When the play button is pressed, the object property will be changed sequentially through all the values in the list, at intervals of time given by the option `tstep`. The rewind button can be used to point at the start of the sequence making the animation restart after the play button is pressed again.

  See also `track`.

  ·

  Categories: Package dynamics ·Plotting

Object option: capping [capping, number]

  Default value: `1`

  In a cone or a cylinder, it defines whether the base (or bases) will be shown. A value of 1 for number makes the base visible and a value of 0 makes it invisible.

  ·

  Categories: Package dynamics ·Plotting

Object option: center [center, point]

  Default value: `[0, 0, 0]`

  The coordinates of the object’s geometric center, with respect to its `position`. point can be a list with 3 real numbers, or 3 real numbers separated by commas. In a cylinder, cone or cube it will be at half its height and in a sphere at its center.

  ·

  Categories: Package dynamics ·Plotting

Object option: color [color, colorname]

  Default value: `white`

  The color of the object. It accepts color names or hexadecimal red-green-blue strings (see the `color` option of plot2d).

  ·

  Categories: Package dynamics ·Plotting

Object option: endphi [endphi, angle]

  Default value: `180`

  In a sphere phi is the angle on the vertical plane that passes through the z axis, measured from the positive part of the z axis. angle must be a number between 0 and 180 that sets the final value of phi at which the surface will end. A value smaller than 180 will eliminate a part of the sphere’s surface.

  See also `startphi` and `phiresolution`.

  ·

  Categories: Package dynamics ·Plotting

Object option: endtheta [endtheta, angle]

  Default value: `360`

  In a sphere theta is the angle on the horizontal plane (longitude), measured from the positive part of the x axis. angle must be a number between 0 and 360 that sets the final value of theta at which the surface will end. A value smaller than 360 will eliminate a part of the sphere’s surface.

  See also `starttheta` and `thetaresolution`.

  ·

  Categories: Package dynamics ·Plotting

Object option: height [height, value]

  Default value: `1`

  value must be a positive number which sets the height of a cone or a cylinder.

  ·

  Categories: Package dynamics ·Plotting

Object option: linewidth [linewidth, value]

  Default value: `1`

  The width of the lines, when option `wireframe` is used. value must be a positive number.

  ·

  Categories: Package dynamics ·Plotting

Object option: opacity [opacity, value]

  Default value: `1`

  value must be a number between 0 and 1. The lower the number, the more transparent the object will become. The default value of 1 means a completely opaque object.

  ·

  Categories: Package dynamics ·Plotting

Object option: orientation [orientation, angles]

  Default value: `[0, 0, 0]`

  Three angles by which the object will be rotated with respect to the three axis. angles can be a list with 3 real numbers, or 3 real numbers separated by commas. Example: `[0, 0, 90]` rotates the x axis of the object to the y axis of the reference frame.

  ·

  Categories: Package dynamics ·Plotting

Object option: origin [origin, point]

  Default value: `[0, 0, 0]`

  The coordinates of the object’s origin, with respect to which its other dimensions are defined. point can be a list with 3 real numbers, or 3 real numbers separated by commas.

  ·

  Categories: Package dynamics ·Plotting

Object option: phiresolution [phiresolution, num]

  Default value: ``

  The number of sub-intervals into which the phi angle interval from `startphi` to `endphi` will be divided. num must be a positive integer.

  See also `startphi` and `endphi`.

  ·

  Categories: Package dynamics ·Plotting

Object option: points [points]

  Only the vertices of the triangulation used to render the surface will be shown. Example: `[sphere, [points]]`

  See also `surface` and `wireframe`.

  ·

  Categories: Package dynamics ·Plotting

Object option: pointsize [pointsize, value]

  Default value: `1`

  The size of the points, when option `points` is used. value must be a positive number.

  ·

  Categories: Package dynamics ·Plotting

Object option: position [position, point]

  Default value: `[0, 0, 0]`

  The coordinates of the object’s position. point can be a list with 3 real numbers, or 3 real numbers separated by commas.

  ·

  Categories: Package dynamics ·Plotting

Object option: radius [radius, value]

  Default value: `0.5`

  The radius or a sphere or the distance from the axis to the base’s vertices in a cylinder or a cone. value must be a positive number.

  ·

  Categories: Package dynamics ·Plotting

Object option: resolution [resolution, number]

  Default value: `6`

  number must be an integer greater than 2 that sets the number of edges in the base of a cone or a cylinder.

  ·

  Categories: Package dynamics ·Plotting

Object option: scale [scale, factors]

  Default value: `[1, 1, 1]`

  Three numbers by which the object will be scaled with respect to the three axis. factors can be a list with 3 real numbers, or 3 real numbers separated by commas. Example: `[2, 0.5, 1]` enlarges the object to twice its size in the x direction, reduces the dimensions in the y direction to half and leaves the z dimensions unchanged.

  ·

  Categories: Package dynamics ·Plotting

Object option: startphi [startphi, angle]

  Default value: `0`

  In a sphere phi is the angle on the vertical plane that passes through the z axis, measured from the positive part of the z axis. angle must be a number between 0 and 180 that sets the initial value of phi at which the surface will start. A value bigger than 0 will eliminate a part of the sphere’s surface.

  See also `endphi` and `phiresolution`.

  ·

  Categories: Package dynamics ·Plotting

Object option: starttheta [starttheta, angle]

  Default value: `0`

  In a sphere theta is the angle on the horizontal plane (longitude), measured from the positive part of the x axis. angle must be a number between 0 and 360 that sets the initial value of theta at which the surface will start. A value bigger than 0 will eliminate a part of the sphere’s surface.

  See also `endtheta` and `thetaresolution`.

  ·

  Categories: Package dynamics ·Plotting

Object option: surface [surface]

  The surfaces of the object will be rendered and the lines and points of the triangulation used to build the surface will not be shown. This is the default behavior, which can be changed using either the option `points` or `wireframe`.

  ·

  Categories: Package dynamics ·Plotting

Object option: thetaresolution [thetaresolution, num]

  Default value: ``

  The number of sub-intervals into which the theta angle interval from `starttheta` to `endtheta` will be divided. num must be a positive integer.

  See also `starttheta` and `endtheta`.

  ·

  Categories: Package dynamics ·Plotting

Object option: track [track, positions]

  positions should be a list of points. When the play button is pressed, the object position will be changed sequentially through all the points in the list, at intervals of time given by the option `tstep`, leaving behind a track of the object’s trajectory. The rewind button can be used to point at the start of the sequence making the animation restart after the play button is pressed again.

  Example. This will show the trajectory of a ball thrown with speed of 5 m/s, at an angle of 45 degrees, when the air resistance can be neglected:

      (%i1) p: makelist ([0,4*t,4*t- 9.8*t^2/2], t, 0, 0.82, 0.01)$

      (%i2) ball: [sphere, [radius,0.1], [color,red], [track,p]]$

      (%i3) ground: [cube, [xlength,2], [ylength,4], [zlength,0.2],
            [position,0,1.5,-0.2],[color,green]]$

      (%i4) scene (ball, ground)$

  See also `animation`.

  ·

  Categories: Package dynamics ·Plotting

Object option: xlength [xlength, length]

  Default value: `1`

  The height of a cube in the x direction. length must be a positive number. See also `ylength` and `zlength`.

  ·

  Categories: Package dynamics ·Plotting

Object option: ylength [ylength, length]

  Default value: `1`

  The height of a cube in the y direction. length must be a positive number. See also `xlength` and `zlength`.

  ·

  Categories: Package dynamics ·Plotting

Object option: zlength [zlength, length]

  Default value: `1`

  The height of a cube in z the direction. length must be a positive number. See also `xlength` and `ylength`.

  ·

  Categories: Package dynamics ·Plotting

Object option: wireframe [wireframe]

  Only the edges of the triangulation used to render the surface will be shown. Example: `[cube, [wireframe]]`

  See also `surface` and `points`.

  ·

  Categories: Package dynamics ·Plotting

Previous: Graphical analysis of discrete dynamical systems, Up: dynamics-pkg [Contents][Index]