We now describe some functions that create VRML objects, starting
by those used in the first example, Figure 1
(left). The displayed scene consists of four elements :
- A surface, obtained with the vrml_surf () command,
which is the object of interest.
- A reference frame, obtained with the vrml_frame ()
command, which indicates the orientation in which the data considered.
- Some lights , obtained with the vrml_PointLight ()
command, in order to light the scene.
- A background, obtained with the vrml_Background ()
command, to specify the grayish-blue color, rather than the browser's
default black.
We now describe each function in turn :
- [s = vrml_surf (z,...)]or
- [s = vrml_surf (x,y,z,...)]returns a VRML representation
of a surface composed of triangular facets whose vertices. The arguments
are
- [z]Matrix of dimension
representing
the height of the vertices.
- [x]Matrix with dimensions
or vector of length
, containing the abscissa of the vertices. If omitted, the
value linspace (-1,1,C) is assumed.
- [y]Matrix with dimensions
or vector of length
, containing the ordinate of the vertices. If omitted, the
value linspace (-1,1,R) is assumed.
- [ ]extra options can be passed as a key-value pair :
- ["tran", tran]Transparency of the surface
: tran should be a number between 0 and 1.
- ["col", col]Color of the surface. The
effect of this option depends on the size of col :
- [
]The RGB color of the surface is uniform and specified
by col.
- [
]The RGB color of vertex
of the surface is specified by col(:,i+R*j) and the color
changes smoothly from vertex to vertex.
- [
]The RGB color of face
(
,
) is specified by col(:,i+(R-1)*j)
and the color change between faces is crisp.
- ["checker", sz]Colors the surface as a
checker. If sz is positive, it is the number of and columns
of the checker. If negative, it is the opposite of the number of facets
per square of the checker. Moreover, sz may have length two,
in which case the number of rows and columns are defined separately.
If the "col" option is used, the first
6 elements (or 2) are the RGB (greylevel) components of the color
of the squares. Figure 2, left. Shows the effect of
this option.
- [ ]The options "col" and "checker"
can be passed to the vmesh function too. Other options are
documented by doing help vrml_surf. For building more 3D
surfaces consisting of facets, see the function vrml_faces ().
- [s = vrml_frame (pos,]rot, ...) returns a VRML
representation of a XYZ frame.
- pos
is the position of
the frame. If not provided,
is assumed
and a NaN is ignored.
- rot
orientation of the
frame. Default is
and a NaN
is ignored.
-
- Translations -or positions- will always be represented
by a vector of 3 elements. Orientations -or rotations-
are also represented by a 3-element vector whose direction defines
the axis of the rotation and whose norm (as returned by norm(rot))
defines the angle, in radians.
-
- Extra options can be passed as a key-value pair :
- ["col", col]
:
RGB color of the frame, or of each branch (stacked vertically). Default
is
.
- ["hcol", col]
:
RGB color of the heads of the arrows that compose the frame, or of
each branch (stacked vertically). Default is
.
- ["scale", scl]
:
Length of the branches of the frame, or of each branch individually.
Default is
.
- s = vrml_PointLight (...)
- and
- s = vrml_Background (...)
- are low level functions
that return simple VRML objects (``nodes'', in VRML lingo). All
the VRML characteristics (``fields'') can be set by using key-value
pairs. We describe some of the options that can be passed to vrml_Background();
the others are displayed by doing help vrml_Background().
- "skyColor", RGB
and
- "groundColor", RGB
specify the RGB color of the sky and ground, respectively.
Figure 2:
Left: A checkered surface obtained by the
variant of Listing 1.
Middle: An XYZ frame with axes colored red, blue and green,
obtained by running Listing 3.
Right: A set of points connected by black and white cylinders
and the same set of points, scaled down by half along the Y and Z
axes (Listing 4).
|
The following listing and Figure 2, middle, show an
example of the usage of vrml_frame(), vrml_Background(),
and vrml_browse().
Subsections
Søren Hauberg
2009-06-07