[Index for tmp_for_tar/vrml.doc] [Return to Master Index]

vrml_cyl

(tmp_for_tar/vrml.doc/vrml_cyl.m)


Function Synopsis

s = vrml_cyl(x,...) 

Help text

       s = vrml_cyl(x,...) 

 Makes a cylinder that links x(:,1) to x(:,2) 

 Options : 

 "tran", transparency    : default = 0
 "col" , col             : default = [ 0.3 0.4 0.9 ]
 "rad" , radius          : default = 0.05
 "balls"                 : add balls to extremities

 Last modified: December 2000



Listing of function file tmp_for_tar/vrml.doc/vrml_cyl.m

##       s = vrml_cyl(x,...) 
##
## Makes a cylinder that links x(:,1) to x(:,2) 
## 
## Options : 
##
## "tran", transparency    : default = 0
## "col" , col             : default = [ 0.3 0.4 0.9 ]
## "rad" , radius          : default = 0.05
## "balls"                 : add balls to extremities
##

## Author:        Etienne Grossmann  <etienne@isr.ist.utl.pt>
## Last modified: December 2000

function s = vrml_cyl(x,...) 

rad = 0.05 ;
col = [0.3,0.4,0.9] ;
balls = 0 ;
tran = 0 ;
verbose = 0 ;
opt1 = " tran col rad " ;
opt0 = " verbose balls " ;
nargin-- ;

filename = "vrml_cyl" ;

read_options 


s = "" ;

for i = 2:columns(x),
  d = x(:,i)-x(:,i-1) ;
  n = norm(d) ;
  if n,
    d = d/n ;

    ax = cross([0,1,0],d') ;
    an = norm(ax) ;
    if abs(an)>eps, ax = ax/an ; else ax = [1,0,0] ; end
    an = acos(d(2)) ;

    t = mean(x(:,[i,i-1])')' ;
    
    s = [s,sprintf(["Transform {\n",\
		    "  translation %8.3f %8.3f %8.3f\n",\
		    "  children [\n",\
		    "    Transform {\n",\
		    "      rotation    %8.3f %8.3f %8.3f %8.3f\n",\
		    "      children [\n",\
		    "        Shape {\n",\
		    "          appearance Appearance {\n",\
		    "            material Material {\n",\
		    "              diffuseColor %8.3f %8.3f %8.3f \n",\
		    "              emissiveColor %8.3f %8.3f %8.3f\n",\
		    "              transparency %8.3f\n",\
		    "            }\n",\
		    "          }\n",\
		    "          geometry Cylinder {\n",\
		    "            height %8.3f\n",\
		    "            radius %8.3f\n",\
		    "          }\n",\
		    "        }\n",\
		    "      ]\n",\
		    "    }\n",\
		    "  ]\n",\
		    "}\n"],\
		   t,\
		   ax,an,\
		   col,col,\
		   tran,\
		   n,\
		   rad)] ;
  end
end

if balls,
  ## "balls on"
  s = [s, vrml_points(x,"balls","col",col)] ;
elseif columns(x)>2,
				# Make a rounded junction
  s = [s, vrml_points(x(:,2:columns(x)-1),"balls","col",col,"rad",rad)];
end





Produced by oct2html on Sat Dec 2 19:08:39 2000
Cross-Directory links are: ON