plottools
vrml
three-dimensional plotting in VRML
Calling Sequence
Parameters
Description
Options
Examples
References
vrml(plotstruct, file, options)
plotstruct
-
PLOT or PLOT3D data structure
file
valid file name to write the resulting vrml code
options
(optional) equations of the form option=value where option is one of anchor, background_color, camera, directional_light, emissive_color, material_binding, point_light, scene_info, shininess, smooth_shading, specular_color, spot_light, texture, tickback_color, tickfore_color, or transparency
Important: The plottools[vrml] command has been deprecated. It may not support all possible plot structures. Use the export tools from the Standard GUI to export to the X3D format instead.
The special file name 'default' writes the VRML data to the standard output. This is useful in conjunction with a POST command to a CGI script on a web server.
Any additional arguments are interpreted as plot options specific to vrml. Options are specified as equations of the form option = value. The following options are supported.
In the following discussion 'Color' is referred to numerous times. 'Color' is a color as defined in plot[color] (that is, red, blue, green, orange, white...), or 'Color' is an RGB color definition (that is, COLOR(RGB, 1, 1, 1) -> white) or 'Color' is a HUE color definition (that is, COLOR(HUE, 0.9) -> violet) or 'Color' is an HSV color definition (that is COLOR(HSV, 0.1, 0.9, 1.0) -> red).
anchor=[obj_no_1=filename_1,...,obj_no_n=filename_n]
This option links VRML worlds together on the World Wide Web. Using links, one can connect a door in one's world to another VRML world described elsewhere on the web. obj_no_i where 1<=i<=n is the ith argument of plot. filename_i is the location of the VRML format file to be linked to obj_no_i.
background_color=Color
This option sets background color. If no background color is specified, the default is black. This option may be specified only once.
camera=name,xpos,ypos,zpos,xfrac,yfrac,zfrac,angle
This option specifies a camera view point to view the VRML world. The first camera defined is the default view point when the browser first loads the world. Subsequent camera definitions can be selected by the user from the browser. name is a string containing no spaces and will appear as a name in the browser for selecting this camera. xpos, ypos, and zpos are the coordinates of the camera's position. xfrac, yfrac, and zfrac compose a vector over which the camera is rotated by angle radians.
directional_light=intensity,Color,xdir,ydir,zdir
Directional lights allow users to specify lights, which are positioned infinitely far away. All light rays coming from the light source are parallel and point in the same direction. In the real world, the sun is a directional light. intensity is a numeric which ranges from -1 to 1. Negative values pull light from the scene. The more negative the value, the more light is pulled from the world. The more positive the value, the greater the intensity of the light source. xdir, ydir, and zdir compose a vector that specifies the direction in which the light rays are pointed. This option may be specified multiple times.
emissive_color=Color
This option sets the color that the objects will radiate. emissive_color is useful for creating objects that appear to glow. This option can be specified only once.
material_binding=binding
This option specifies how materials (colors) are bound to objects. binding takes two values: PER_VERTEX and PER_FACE. PER_VERTEX means that each individual vertex has a color associated with it and polygons formed by these vertices have a color gradation that smoothly varies from one vertex to the next. PER_VERTEX produces VRML files that are larger, more complex, but have better detail. PER_FACE means that each polygon is given a solid color. If material_binding is not specified, the default is PER_FACE. This option can be specified only once.
point_light=intensity,Color,x,y,z
A point light is a light emanating from a point source in the world from which light is radiated in all directions. The intensity is a numeric ranging from -1 to 1. Negative values let you pull light out of the world and make it look darker. The more negative the value, the darker the scene becomes. The more positive the value of the intensity is, the brighter the point light is. x, y, and z specify the point in the world which the point light is positioned. This option may be specified multiple times.
scene_info=string
This option specifies a string that the VRML browser will display when the user asks for information on the vrml file. This option can be specified only once.
shininess=value
This option specifies the level at which objects reflect their light sources. value must be a numeric value in the range 0 to 1. A 0 value means objects appear as dull and matte. Higher values mean that objects appear more and more shiny. If this option is not specified, the default is 0. This option can be specified only once.
smooth_shading=value
When value is set to true, this option creates normals for each vertex of each face on a 3-D shape. By intentionally computing normals differently than those automatically computed by the VRML browser, one can make a faceted shape appear smooth. value is a boolean value, that is, true or false (the default is false). Note that this will take much more time and space when value is true.
specular_color=Color
This option specifies the color that objects reflect by specular reflection. This controls the color of the highlight on shiny shapes. This option can be specified only once. If this option is not specified the default is white.
spot_light=intensity,Color,xpos,ypos,zpos,xdir,ydir,zdir,dr,co
A spotlight defines a cone of light. Objects within the cone are illuminated, while objects not inside the cone of light are not affected. intensity is a numeric that ranges from -1 to 1. Negative values pull light out of the world while positive values illuminate the world. The greater the magnitude of the intensity, the more effect it has. xpos, ypos, and zpos are coordinates that specify the position of the tip of the cone in the world. xdir, ydir, and zdir form a vector specifying the direction in which the cone radiates from the point. dr, the drop off rate, is a numeric in the range 0 to 1 that specifies the rate at which the intensity drops as we move from the center of the cone to an edge. A value of 0 for dr means that objects in the middle of the cone and objects at the edge of the cone are illuminated with equal intensities of light. A value of 1 for dr means that objects in the middle of the cone are illuminated with full intensity, but objects near the edge of the cone are hardly illuminated at all. co, the cut off angle, gives the spread angle in radians of the cone of light. co must be a numeric in the range 0..2*Pi. This option can be specified multiple times.
texture=[image=filename,coords=[[x1,y1],[x2,y2],[x3,y3],...],transform=translate⁡x,y,rotate⁡alpha,scalefactor⁡S,T,center⁡x,y]
This option allows texture-mapping on the object. filename is the location of the image texture (for example, gif file); coords specifies a shape using a list of 2-D coordinates; translate, rotate, and scalefactor specify the transformations that are going to be applied to the image texture with respect to center (for rotate and scalefactor).
tickback_color=Color
Tickmarks in VRML are presented as cubes with the value of the tickmark written on all six sides. This option specifies the color of the cube. The default is off-white. This option can be specified only once.
tickfore_color=Color
This option specifies the color of the text used to inscribe the value of the tickmark on the cube. The default is dark green. This option can be specified only once.
transparency=value
This option specifies the transparency of objects. value must be a numeric in the range 0 to 1. 0 means the objects will be opaque. 1 means objects will be transparent. Values between 0 and 1 cause objects to appear translucent. This option can be specified only once.
Note: The transparency option is not available in all interfaces.
The standard file extension for VRML data files is '.wrl'
with⁡plottools:
vrml⁡plot3d⁡sin⁡x⁢y⋅2,x=−π..π,y=−π..π,axes=NORMAL,lightmodel=light2,`plot1.wrl`
vrml⁡plot⁡x2,x=−2..2,`plot2.wrl`,scene_info=`x^2`
vrml⁡plot3d⁡sin⁡x2⁢y2,x=−π2..π2,y=−π2..π2,`plot3.wrl`,background_color=COLOR⁡RGB,1,1,1
3-D geometry objects are particularly interesting viewed from VRML
geom3dpoint⁡o,0,0,0:r≔1.:
geom3dGreatRhombiicosidodecahedron⁡p1,o,r:
geom3dduality⁡dp1,p1,geom3dsphere⁡s1,o,geom3dMidRadius⁡p1
dp1
c1≔COLOR⁡RGB,1.00,0.50,0.50:c2≔COLOR⁡RGB,0.50,0.,0.05:
pic≔geom3ddraw⁡p1⁡color=c1,dp1⁡color=c2,cutout=78,lightmodel=light2,orientation=0,31:
vrml⁡pic,`Rhombii.wrl`,shininess=0.5,specular_color=COLOR⁡RGB,1,1,1:
3-D Parametric plot
c1≔cos⁡x−2⁢cos⁡0.4⁢y,sin⁡x−2⁢sin⁡0.4⁢y,y:
c2≔cos⁡x+2⁢cos⁡0.4⁢y,sin⁡x+2⁢sin⁡0.4⁢y,y:
c3≔cos⁡x+2⁢sin⁡0.4⁢y,sin⁡x−2⁢cos⁡0.4⁢y,y:
c4≔cos⁡x−2⁢sin⁡0.4⁢y,sin⁡x+2⁢cos⁡0.4⁢y,y:
pic≔plot3d⁡c1,c2,c3,c4,x=0..2⁢π,y=0..10,grid=25,15,style=patch,lightmodel=light4:
vrml⁡pic,`Tubes.wrl`,transparency=0.5
plottools objects colored with lightsources
with⁡plots:
midpoint := proc(x) local v, n, g, i; v := [op(x),x[1] ]; n := nops( x ); g := ( a, b) -> 1/2*( a + b ) : [ seq( g( v[i], v[i+1] ), i=1..n)]; end proc:
Conchoid≔tubeplot⁡t−5⁢π⁢sin⁡t3,t−5⁢π⁢cos⁡t3,t−5⁢π⋅0.9,t=0..5⁢π,radius=t−5⁢π⋅0.2,tubepoints=25:
ConchoidPolys≔convert⁡op⁡1,Conchoid,POLYGONS:
vrml⁡display⁡map⁡midpoint,ConchoidPolys,scaling=constrained,style=patchnogrid,color=COLOR⁡RGB,1,1,1,`conchoid.wrl`,point_light=1.0,COLOR⁡RGB,0,0,1,0,0,20,spot_light=1.0,COLOR⁡RGB,1,1,0,−40,0,−7.5,1,0,0,0.8,1.57,spot_light=1.0,COLOR⁡RGB,0,1,1,20.07,34.6,−7.5,−20.07,−34.6,0,0.8,1.57,spot_light=1.0,COLOR⁡RGB,0,1,0,20.07,−34.6,−7.5,−20.07,34.6,0,0.8,1.57,directional_light=1.0,COLOR⁡RGB,1,0,0,0,0,1
Apply smooth shading to the object
vrml⁡plot3d⁡sin⁡x⁢y,x=−π..π,y=−π..π,color=blue,`sin.wrl`,smooth_shading=true
Anchor option
Create a link
geom3dtetrahedron⁡t1,geom3dpoint⁡o,0,0,0,1.:
geom3dtetrahedron⁡t2,o,1.0001:
vrml⁡geom3ddraw⁡t2,t1,tickmarks=3,3,3,axes=frame,`link.wrl`,tickback_color=brown,tickfore_color=yellow
Create the VRML world for the tetrahedron t with center (-2,2,1), radius of the circum-sphere 1., and link t1 to "link.wrl"
vrml⁡geom3ddraw⁡geom3dtetrahedron⁡t,geom3dpoint⁡o1,−2,2,1,1.,orientation=−109,52,color=COLOR⁡RGB,0.9335294125,0.9129411760,0.5205882350,`main.wrl`,anchor=1=link.wrl
The VRML Sourcebook. New York: John Wiley & Sons, 1996.
See Also
examples/geometry
exportplot
geometry
geometry[draw]
plot
plot3d
plot3d[coords]
plot3d[option]
plot3d[structure]
plot[color]
plots
Download Help Document