#LyX 1.3 created this file. For more info see http://www.lyx.org/
\lyxformat 221
\textclass article
\begin_preamble
% \usepackage{dsfont}

% No date please
\date{}
\fontfamily{cmss}
\selectfont
\renewcommand{\rmdefault}{cmss}
\end_preamble
\language english
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize default
\spacing single 
\papersize Default
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\use_natbib 0
\use_numerical_citations 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle default

\layout Standard


\begin_inset ERT
status Collapsed

\layout Standard
% This is for 
\backslash 
LyX
\end_inset 


\layout Standard


\begin_inset FormulaMacro 
\newcommand{\bfrac}[2]{\frac{#1 }{#2 }}
\end_inset 


\layout Standard


\begin_inset FormulaMacro 
\newcommand{\nth}{^{\textrm{th}}}
\end_inset 


\layout Standard


\begin_inset FormulaMacro 
\newcommand{\R}{R}
\end_inset 


\layout Standard


\begin_inset FormulaMacro 
\newcommand{\N}{N}
\end_inset 


\layout Standard


\begin_inset FormulaMacro 
\newcommand{\Z}{Z}
\end_inset 


\layout Standard


\begin_inset FormulaMacro 
\newcommand{\tra}{^{T}}
\end_inset 


\layout Standard


\begin_inset FormulaMacro 
\newcommand{\xx}{\mathbf{x}}
\end_inset 


\layout Standard


\begin_inset ERT
status Open

\layout Standard
% This is for 
\backslash 
LaTeX
\layout Standard

\backslash 
renewcommand{
\backslash 
R}{{
\backslash 
mathds{R}}} 
\layout Standard

\backslash 
renewcommand{
\backslash 
N}{{
\backslash 
mathds{N}}}
\layout Standard

\backslash 
renewcommand{
\backslash 
Z}{{
\backslash 
mathds{Z}}}
\layout Standard

\backslash 
renewcommand{
\backslash 
tra}{^{
\backslash 
top}}
\layout Standard

\backslash 
renewcommand{
\backslash 
bfrac}[2]{
\backslash 
frac{{
\backslash 
textstyle #1 }}{{
\backslash 
textstyle #2 }}}
\layout Standard

\end_inset 


\layout Title

Mini-HOWTO : visualizing 3D data using Octave, VRML and FreeWRL
\begin_inset Foot
collapsed true

\layout Standard

Author : Etienne Grossmann 
\family typewriter 
<etienne@egdn.net>
\family default 
 (soon replaced by 
\begin_inset Quotes eld
\end_inset 

Octave-Forge developers
\begin_inset Quotes erd
\end_inset 

?).
 This document is free documentation; you can redistribute it and/or modify
 it under the terms of the GNU Free Documentation License as published by
 the Free Software Foundation.
\newline 
.\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
This is distributed in the hope that it will be useful, but WITHOUT ANY
 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.
\end_inset 


\layout Comment

Keywords: octave, tutorial, 3D visualization, VRML
\layout Abstract

This document shows how to visualize sets of 3D points, 3D curves, surfaces
 etc using the numerical language Octave, in conjunction with the VRML browser
 FreeWRL.
 The basic functionalities and principles are presented here with examples,
 while the detailed synopsis can be obtained from the online help system.
\layout Standard

\SpecialChar ~

\begin_inset Float figure
wide false
collapsed false

\layout Standard
\align center 

\begin_inset Graphics
	filename figures/freewrl-octave-snap-2.eps2
	display color
	width 38text%

\end_inset 

\SpecialChar ~

\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
raisebox{5mm}{
\end_inset 


\begin_inset Graphics
	filename figures/freewrl-select-points-2.eps2
	display color
	width 55text%

\end_inset 


\begin_inset ERT
status Collapsed

\layout Standard
}
\end_inset 


\layout Caption


\begin_inset LatexCommand \label{fig:freewrloctave}

\end_inset 

FreeWRL window and octave running in a terminal.
 The red and green vectors of the frame represent the 
\begin_inset Quotes eld
\end_inset 

X
\begin_inset Quotes erd
\end_inset 

 and 
\begin_inset Quotes eld
\end_inset 

Y
\begin_inset Quotes erd
\end_inset 

 axes.
 
\series bold 
Left:
\series default 
 Displaying the surface of a 2-variable function.
 
\series bold 
Right:
\series default 
 Viewing a set of 3D points and selecting a subset.
\end_inset 

\SpecialChar ~

\layout Paragraph

Prerequisites:
\layout Standard

It is assumed that you have installed Octave 2.1.35 (
\begin_inset LatexCommand \url{http://www.octave.org}

\end_inset 

) or more, FreeWRL (
\begin_inset LatexCommand \url{http://www.crc.ca/FreeWRL}

\end_inset 

) 0.34 or more (versions between 0.27 and 0.31 may work too) and the Octave-Forge
 (
\begin_inset LatexCommand \url{http://octave.sourceforge.net}

\end_inset 

) package.
 Each one is available from the indicated URL.
 Rudimentary knowledge of Octave is also assumed.
\layout Section

Basics
\begin_inset LatexCommand \label{sec:basics}

\end_inset 


\layout Standard

This document describes some 3D visualization functions from the Octave-Forge
 package.
 First, examples are given on how to visualize a surface with the 
\family typewriter 
vmesh()
\family default 
 function and how to visualize a set of 3D points and select a subset with
 the mouse.
 The basic usage of FreeWRL, the program that does the 3D visualization
 are introduced at the same time.
\layout Standard

The second section explains more in detail how the VRML package works, presents
 other functions and shows how to assemble various 3D objects.
 Finally, a brief summary and plans for the future are given in Section\SpecialChar ~

\begin_inset LatexCommand \ref{sec:conclusions}

\end_inset 

.
\layout Subsection

Viewing a surface from the Octave prompt
\layout Standard

Consider the following Octave commands\SpecialChar ~
:
\layout Subparagraph

Listing 1
\layout LyX-Code

x = linspace (-1,1,31);
\layout LyX-Code

[xx,yy] = meshgrid (x,x);
\layout LyX-Code

zz = xx.^2 + yy.^2;
\layout LyX-Code

vmesh (zz);
\layout Standard

The first three lines define a 
\begin_inset Formula $31\times31$
\end_inset 

 matrix 
\family typewriter 
zz
\family default 
 containing values of 
\begin_inset Formula $x^{2}+y^{2}$
\end_inset 

 for values of 
\begin_inset Formula $x$
\end_inset 

 and 
\begin_inset Formula $y$
\end_inset 

 regularly sampled in the interval 
\begin_inset Formula $\left[-1,1\right]$
\end_inset 

.
 The fourth line visualizes in a separate window a surface representing
 
\family typewriter 
zz
\begin_inset Foot
collapsed true

\layout Standard

If nothing happened when you executed the 
\family typewriter 
vmesh()
\family default 
 command, or if an error message was issued, this indicates a problem.
 Make sure that you are running under X11 and that FreeWRL is installed
 and functions properly.
\end_inset 


\family default 
.
 By click and dragging the mouse in that new window, you should be able
 to rotate the object and obtain something as in Figure\SpecialChar ~

\begin_inset LatexCommand \ref{fig:freewrloctave}

\end_inset 

.
\layout Standard

The variant\SpecialChar ~
:
\layout LyX-Code

vmesh (zz,"checker",[5,-2],"col",[1 0 0;0.7 0.7 0.7]');
\layout Standard

displays (Figure\SpecialChar ~

\begin_inset LatexCommand \ref{fig:misc}

\end_inset 

, left) a checkered surface with 5 squares along the X direction squares
 that are two facets wide along the Y direction.
 This listing can be run with the command 
\family typewriter 
\series bold 
vrml_demo_tutorial_1
\family default 
\series default 
.
 Subsequent in this document listings can be called in a similar fashion.
\layout Subsection

Basic 3D visualization with FreeWRL
\layout Standard

What happened when this last command was executed is that the program FreeWRL
 was launched and asked to visualize some data that represents the 3D surface.
 Interaction with FreeWRL is done through the mouse and keyboard\SpecialChar ~
:
\layout Standard

When in 
\begin_inset Quotes eld
\end_inset 


\series bold 
examine mode
\series default 

\begin_inset Quotes erd
\end_inset 

 (the default), dragging with the left button rotates the object, while
 dragging up and down with the left button zooms out and zooms in.
\layout Standard

When the 
\family typewriter 
'w'
\family default 
 key is hit, FreeWRL switches to 
\begin_inset Quotes eld
\end_inset 


\series bold 
walk mode
\series default 

\begin_inset Quotes erd
\end_inset 

 , in which left-dragging up or downwards will move the viewpoint forward
 or backward.
 Left-or-right-dragging to the left or right directions will move the viewpoint
 left or right, respectively.
 Finally, right-dragging up or down moves the viewpoint up and down.
 You may switch back to the 
\begin_inset Quotes eld
\end_inset 

examine
\begin_inset Quotes erd
\end_inset 

 mode by hitting the 
\family typewriter 
'e'
\family default 
 key.
\layout Standard

Hitting '
\family typewriter 
s
\family default 
' saves a 
\series bold 
snapshot
\series default 
 
\family typewriter 
freewrl.snap.0001.ppm
\family default 
 in the current directory; subsequent snapshots will be numbered 
\family typewriter 
0002
\family default 
, etc.
 Each time FreeWRL is launched, the count is restarted so beware that previous
 snapshots may be overwritten.
\layout Standard

Last but important, the 
\family typewriter 
'q'
\family default 
 key will 
\series bold 
exit
\series default 
 FreeWRL.
\layout Subsection

Viewing a set of 3D points
\layout Standard

Going back to Octave, let's create a set of 3D points\SpecialChar ~
:
\layout Subparagraph

Listing 2
\layout LyX-Code

N = 30;
\layout LyX-Code

x = [randn (3,N) .* ([1,3,6]'*ones(1,N)), [5 5;-1 1;0 0]];
\layout LyX-Code

select_3D_points (x)
\layout Standard

The first two commands create a variable 
\family typewriter 
xx
\family default 
 that holds 32 3D points, 30 of which are randomly distributed and two,
 with coordinates 
\begin_inset Formula $\left[5,\,\pm1,\,0\right]$
\end_inset 

, which are 
\begin_inset Quotes eld
\end_inset 

outliers
\begin_inset Quotes erd
\end_inset 

 .
 The last command launches FreeWRL in such a way that it is not only possible
 to examine the 3D points, represented by boxes, but also select a subset
 of them, by clicking on them\SpecialChar ~
: a selected box is bright green instead of
 blue.
 On the snapshot in Figure\SpecialChar ~

\begin_inset LatexCommand \ref{fig:freewrloctave}

\end_inset 

 (right), the two outliers have been selected.
\layout Standard

Having selected these points, let's go back to the Octave window, where
 
\family typewriter 
select_3D_points()
\family default 
 has produced the output\SpecialChar ~
:
\layout LyX-Code

Menu: (R)estart browser.
 Other key : done
\layout Standard


\family typewriter 
select_3D_points()
\family default 
 is now waiting for a key to be hit, either '
\family typewriter 
r
\family default 
' , in which case FreeWRL will be restarted, or any other key, in which
 case 
\family typewriter 
select_3D_points()
\family default 
 finishes and returns the indices of the 3D points that have been output,
 in the form of a 0-1 matrix\SpecialChar ~
:
\layout LyX-Code
\align center 

\size footnotesize 
ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1.
\layout Section

More in detail
\begin_inset LatexCommand \label{sec:details}

\end_inset 


\layout Standard

VRML is a language that allows to describe a 3D setup by specifying shapes,
 colors, positions etc.
 Given a VRML document, a VRML browser -FreeWRL in our case- will render
 it and allow a user to navigate in it.
 Examining 3D objects is just one of the possibilities of VRML, the only
 one we use in this document.
\layout Paragraph

Communication between Octave and FreeWRL
\layout Standard

Octave communicates with FreeWRL by writing VRML code to a temporary file
 
\layout LyX-Code

/tmp/octave_vrml_output.wrl
\layout Standard

and sending a signal so that FreeWRL reads the file and raises its window.
 The Octave function that takes care of this is 
\layout LyX-Code

vrml_browse (str)
\family roman 
,
\layout Standard

which takes as argument a single string that contains the VRML code.
 Another function unfortunately is useful\SpecialChar ~
:
\layout LyX-Code

vrml_kill ()
\family roman 
.
\layout Standard

This kills the current browser.
 Unfortunately, the browser sometimes hangs and it is on that occasion that
 this function is useful.
\layout Paragraph

Functions for building objects from scratch
\layout Standard

We now describe some functions that create VRML objects, starting by those
 used in the first example, Figure\SpecialChar ~

\begin_inset LatexCommand \ref{fig:freewrloctave}

\end_inset 

 (left).
 The displayed scene consists of four elements\SpecialChar ~
:
\layout Enumerate

A surface, obtained with the 
\family typewriter 
vrml_surf
\family default 
 
\family typewriter 
()
\family default 
 command, which is the object of interest.
\layout Enumerate

A reference frame, obtained with the 
\family typewriter 
vrml_frame
\family default 
 
\family typewriter 
()
\family default 
 command, which indicates the orientation in which the data considered.
\layout Enumerate

Some lights , obtained with the 
\family typewriter 
vrml_PointLight
\family default 
 
\family typewriter 
()
\family default 
 command, in order to light the scene.
\layout Enumerate

A background, obtained with the 
\family typewriter 
vrml_Background
\family default 
 
\family typewriter 
()
\family default 
 command, to specify the grayish-blue color, rather than the browser's default
 black.
\layout Standard

We now describe each function in turn\SpecialChar ~
:
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
s\SpecialChar ~
=\SpecialChar ~

\series medium 
vrml_surf
\series default 
\SpecialChar ~
(z,...) 
\family default 
or
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
s\SpecialChar ~
=\SpecialChar ~

\series medium 
vrml_surf
\series default 
\SpecialChar ~
(x,y,z,...) 
\family default 
returns a VRML representation of a surface composed of triangular facets
 whose vertices.
 The arguments are
\begin_deeper 
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
z 
\family default 
Matrix of dimension 
\family typewriter 

\begin_inset Formula $R\times C$
\end_inset 


\family default 
 representing the height of the vertices.
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
x 
\family default 
Matrix with dimensions 
\begin_inset Formula $R\times C$
\end_inset 

 or vector of length 
\begin_inset Formula $C$
\end_inset 

, containing the abscissa of the vertices.
 If omitted, the value 
\family typewriter 
linspace\SpecialChar ~
(-1,1,C)
\family default 
 is assumed.
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
y 
\family default 
Matrix with dimensions 
\begin_inset Formula $R\times C$
\end_inset 

 or vector of length 
\begin_inset Formula $R$
\end_inset 

, containing the ordinate of the vertices.
 If omitted, the value 
\family typewriter 
linspace\SpecialChar ~
(-1,1,R)
\family default 
 is assumed.
\end_deeper 
\layout List
\labelwidthstring 00.00.0000

\SpecialChar ~
 extra options can be passed as a key-value pair\SpecialChar ~
:
\begin_deeper 
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
"tran",\SpecialChar ~
tran
\family default 
 Transparency of the surface : 
\family typewriter 
tran
\family default 
 should be a number between 0 and 1.
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
"col",\SpecialChar ~
col 
\family default 
Color of the surface.
 The effect of this option depends on the size of 
\family typewriter 
col\SpecialChar ~

\family default 
:
\begin_deeper 
\layout List
\labelwidthstring 00.00.0000


\begin_inset Formula $3\times1$
\end_inset 

 The RGB color of the surface is uniform and specified by 
\family typewriter 
col
\family default 
.
\layout List
\labelwidthstring 00.00.0000


\begin_inset Formula $3\times RC$
\end_inset 

 The RGB color of 
\emph on 
vertex
\emph default 
 
\begin_inset Formula $\left(i,j\right)$
\end_inset 

 of the surface is specified by 
\family typewriter 
col(:,i+R*j)
\family default 
 and the color changes smoothly from vertex to vertex.
\layout List
\labelwidthstring 00.00.0000


\begin_inset Formula $3\times(R-1)(C-1)$
\end_inset 

 The RGB color of 
\emph on 
face
\emph default 
 
\begin_inset Formula $\left(i,j\right)$
\end_inset 

 (
\begin_inset Formula $1\leq i\leq R-1$
\end_inset 

, 
\begin_inset Formula $1\leq j\leq C-1$
\end_inset 

) is specified by 
\family typewriter 
col(:,i+(R-1)*j)
\family default 
 and the color change between faces is crisp.
\end_deeper 
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
"checker",\SpecialChar ~
sz 
\family default 
Colors the surface as a checker.
 If 
\family typewriter 
sz
\family default 
 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, 
\family typewriter 
sz
\family default 
 may have length two, in which case the number of rows and columns are defined
 separately.
 If the 
\family typewriter 
"col"
\family default 
 option is used, the first 6 elements (or 2) are the RGB (greylevel) components
 of the color of the squares.
 Figure\SpecialChar ~

\begin_inset LatexCommand \ref{fig:misc}

\end_inset 

, left.
 Shows the effect of this option.
\end_deeper 
\layout List
\labelwidthstring 00.00.0000

\SpecialChar ~
 The options 
\family typewriter 
"col"
\family default 
 and 
\family typewriter 
"checker"
\family default 
 can be passed to the 
\family typewriter 
vmesh
\family default 
 function too.
 Other options are documented by doing 
\family typewriter 
help vrml_surf
\family default 
.
 For building more 3D surfaces consisting of 
\series bold 
facets
\series default 
, see the function 
\family typewriter 
vrml_faces\SpecialChar ~
()
\family default 
.
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
s\SpecialChar ~
=\SpecialChar ~
vrml_frame\SpecialChar ~
(pos, rot, ...)
\family default 
 returns a VRML representation of a XYZ frame.
\begin_deeper 
\layout Description


\family typewriter 
\series medium 
pos 
\series default 

\begin_inset Formula $3\times1$
\end_inset 


\family default 
 is the position of the frame.
 If not provided, 
\begin_inset Formula $\left[0\,0\,0\right]$
\end_inset 

 is assumed and a 
\family typewriter 
NaN
\family default 
 is ignored.
\layout Description


\family typewriter 
\series medium 
rot 
\series default 

\begin_inset Formula $3\times1$
\end_inset 


\family default 
 orientation of the frame.
 Default is 
\begin_inset Formula $\left[0\,0\,0\right]$
\end_inset 

 and a 
\family typewriter 
NaN
\family default 
 is ignored.
\end_deeper 
\layout Description

\SpecialChar ~
 
\series bold 
Translations
\series default 
 -or 
\series bold 
positions
\series default 
- will always be represented by a vector of 3 elements.
 
\series bold 
Orientations
\series default 
 -or 
\series bold 
rotations
\series default 
- are also represented by a 3-element vector whose direction defines the
 axis of the rotation and whose norm (as returned by 
\family typewriter 
norm(rot)
\family default 
) defines the angle, 
\series bold 
in radians
\series default 
.
\layout Description

\SpecialChar ~
 Extra options can be passed as a key-value pair\SpecialChar ~
:
\begin_deeper 
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
"col",\SpecialChar ~
col 
\begin_inset Formula $1\times3\,\textrm{or}\,3\times3$
\end_inset 

\SpecialChar ~
:
\family default 
 RGB color of the frame, or of each branch (stacked vertically).
 Default is 
\begin_inset Formula $\left[0.3\,0.4\,0.9\right]$
\end_inset 

.
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
"hcol",\SpecialChar ~
col 
\begin_inset Formula $1\times3\,\textrm{or}\,3\times3$
\end_inset 

\SpecialChar ~
:
\family default 
 RGB color of the heads of the arrows that compose the frame, or of each
 branch (stacked vertically).
 Default is 
\begin_inset Formula $\left[0.3\,0.4\,0.9\right]$
\end_inset 

.
\layout List
\labelwidthstring 00.00.0000


\family typewriter 
"scale",\SpecialChar ~
scl 
\begin_inset Formula $1\times1\,\textrm{or}\,1\times3$
\end_inset 

\SpecialChar ~
:
\family default 
 Length of the branches of the frame, or of each branch individually.
 Default is 
\begin_inset Formula $1$
\end_inset 

.
\end_deeper 
\layout Description


\family typewriter 
\series medium 
s\SpecialChar ~
=\SpecialChar ~
vrml_PointLight\SpecialChar ~
(...) 
\family default 
\series default 
and
\layout Description


\family typewriter 
\series medium 
s\SpecialChar ~
=\SpecialChar ~
vrml_Background\SpecialChar ~
(...) 
\family default 
\series default 
are low level functions that return simple VRML objects (
\begin_inset Quotes eld
\end_inset 

nodes
\begin_inset Quotes erd
\end_inset 

, in VRML lingo).
 All the VRML characteristics (
\begin_inset Quotes eld
\end_inset 

fields
\begin_inset Quotes erd
\end_inset 

) can be set by using key-value pairs.
 We describe some of the options that can be passed to 
\family typewriter 
vrml_Background()
\family default 
; the others are displayed by doing 
\family typewriter 
help vrml_Background()
\family default 
.
\begin_deeper 
\layout Description


\family typewriter 
\series medium 
"skyColor",\SpecialChar ~
RGB 
\family default 
\series default 

\begin_inset Formula $3\times1$
\end_inset 

 and
\layout Description


\family typewriter 
\series medium 
"groundColor",\SpecialChar ~
RGB 
\family default 
\series default 

\begin_inset Formula $3\times1$
\end_inset 

 specify the RGB color of the sky and ground, respectively.
\end_deeper 
\layout Standard


\begin_inset Float figure
wide false
collapsed false

\layout Standard
\align center 

\begin_inset Graphics
	filename figures/freewrl-checker-snap-3.eps2
	display color
	width 30text%

\end_inset 

\SpecialChar ~

\begin_inset Graphics
	filename figures/frame-sky-snap.eps2
	display color
	width 30text%

\end_inset 

\SpecialChar ~

\begin_inset Graphics
	filename figures/cyl-balls-snap-2.eps2
	display color
	width 30text%

\end_inset 


\layout Caption


\series bold 

\begin_inset LatexCommand \label{fig:misc}

\end_inset 

Left:
\series default 
 A checkered surface obtained by the variant of Listing\SpecialChar ~
1.
\newline 

\series bold 
Middle:
\series default 
 An XYZ frame with axes colored red, blue and green, obtained by running
 Listing\SpecialChar ~
3.
\newline 

\series bold 
Right:
\series default 
 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\SpecialChar ~
4).
\end_inset 

The following listing and Figure\SpecialChar ~

\begin_inset LatexCommand \ref{fig:misc}

\end_inset 

, middle, show an example of the usage of 
\family typewriter 
vrml_frame()
\family default 
, 
\family typewriter 
vrml_Background()
\family default 
, and 
\family typewriter 
vrml_browse()
\family default 
.
\layout Subparagraph

Listing 3
\layout LyX-Code

s1 = vrml_frame ("scale",[1 2 3],"col",eye (3), "hcol",0.5*[1 1 1]);
\newline 
s2 = vrml_Background ("skyColor",[3 3 9]/10,"groundColor",[3 8 3]/10);
\newline 
vrml_browse ([s1,s2]);
\layout Standard

We now describe the function
\layout Description


\family typewriter 
\series medium 
s\SpecialChar ~
=\SpecialChar ~
vrml_cyl\SpecialChar ~
(x,...)
\family default 
\series default 
 that returns VRML code representing 3D 
\series bold 
line segments
\series default 
 (in fact, cylinders) whose extremities are 
\family typewriter 
[x(:,i),x(:,i+1)
\family default 
], for 
\family typewriter 
i
\family default 
 in 
\begin_inset Formula $\left\{ 1,..,N\right\} $
\end_inset 

 (
\family typewriter 
x
\family default 
 is a a 
\begin_inset Formula $3\times N$
\end_inset 

 matrix).
 Amongst other things, the radius, color and transparency can be set.
 Also, spheres centered at each 
\family typewriter 
x(:,i)
\family default 
 can be added, and an arrow can be used to indicate the last segment.
 The corresponding options are\SpecialChar ~
:
\begin_deeper 
\layout Description


\family typewriter 
\series medium 
"rad",\SpecialChar ~
rad 
\family default 
\series default 
The radius of the cylinders linking each pair of consecutive points.
\layout Description


\family typewriter 
\series medium 
"col",\SpecialChar ~
col 
\family default 
\series default 

\begin_inset Formula $3\times1$
\end_inset 

 or 
\begin_inset Formula $3\times N$
\end_inset 

 The RGB color(s) of the cylinders.
\layout Description


\family typewriter 
\series medium 
"tran",\SpecialChar ~
col 
\family default 
\series default 
The transparency of the cylinders.
\layout Description


\family typewriter 
\series medium 
"balls" 
\family default 
\series default 
Add a spheres around each 
\family typewriter 
x(:,i)
\family default 
.
\layout Description


\family typewriter 
\series medium 
"arrow" 
\family default 
\series default 
Represent the last segment as an arrow.
\end_deeper 
\layout Paragraph

Positioning, orienting and scaling objects
\layout Standard

Finally, we present a function that allows to translate, rotate and scale
 an arbitrary VRML object and is useful for composing 3D setups consisting
 of many object.
\layout Description


\family typewriter 
\series medium 
s\SpecialChar ~
=\SpecialChar ~
vrml_transfo\SpecialChar ~
(str,pos,rot,scale)
\family default 
\series default 
 translates, rotates and scales the object defined in the string 
\family typewriter 
str
\family default 
.
 The arguments 
\family typewriter 
pos
\family default 
 and 
\family typewriter 
rot
\family default 
 represent a translation and rotation respectively, just as in the 
\family typewriter 
vrml_frame()
\family default 
 function.
 If 
\family typewriter 
scale
\family default 
 is a scalar, the object 
\family typewriter 
str
\family default 
 will be scaled by that amount, while if 
\family typewriter 
scale 
\family default 
is a 
\begin_inset Formula $3\times1$
\end_inset 

 vector, it represents the scaling of the X, Y and Z axes independently.
\layout Standard

Listing\SpecialChar ~
4 below and Figure\SpecialChar ~

\begin_inset LatexCommand \ref{fig:misc}

\end_inset 

 (right) illustrate how the two functions introduced above can be used.
\layout Subparagraph

Listing 4
\layout LyX-Code

x = linspace (0,4*pi,50);
\layout LyX-Code

                           # Points on a helix
\layout LyX-Code

xx1 = [x/6; sin (x); cos (x)];
\layout LyX-Code

\layout LyX-Code

                           # Linked by segments
\layout LyX-Code

s1 = vrml_cyl (xx1, "col",kron (ones (3,25),[0.7 0.3]));
\layout LyX-Code

\layout LyX-Code

                           # Scaled and represented by spheres
\layout LyX-Code

s2 = vrml_points (xx1,"balls");
\layout LyX-Code

s2 = vrml_transfo (s2,nan,[pi/2,0,0],[1 0.5 0.5]);
\layout LyX-Code

s3 = vrml_Background ("skyColor",[0 0 1]);
\layout LyX-Code

vrml_browse ([s1, s2, s3]);
\layout Section

Summary and future plans
\begin_inset LatexCommand \label{sec:conclusions}

\end_inset 


\layout Standard

We have just passed in review the most important aspects of the VRML toolbox.
 Its main utility is to examine surfaces and moderately sized sets of points,
 but it can also be used to build and assemble more general 3D objects.
\layout Standard

The presented functionality is adapted to my personal needs; if you think
 of some improvements, please send your suggestions (and perhaps patches)
 to the mailing list 
\family typewriter 
octave-dev@lists.sourceforge.net
\family default 
.
 In the future, I will focus on making more concise VRML code and articulating
 better the library around that language.
\the_end
