comparison scripts/plot/surfl.m @ 11587:c792872f8942

all script files: untabify and strip trailing whitespace
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:35:29 -0500
parents 3c6e8aaa9555
children 5ec6aa05638d
comparison
equal deleted inserted replaced
11586:12df7854fa7c 11587:c792872f8942
35 ## vector [lx, ly, lz]. 35 ## vector [lx, ly, lz].
36 ## The default value is rotated 45° counter-clockwise from the current view. 36 ## The default value is rotated 45° counter-clockwise from the current view.
37 ## 37 ##
38 ## The material properties of the surface can specified using a 4-element vector 38 ## The material properties of the surface can specified using a 4-element vector
39 ## @var{P} = [@var{AM} @var{D} @var{SP} @var{exp}] which defaults to 39 ## @var{P} = [@var{AM} @var{D} @var{SP} @var{exp}] which defaults to
40 ## @var{p} = [0.55 0.6 0.4 10]. 40 ## @var{p} = [0.55 0.6 0.4 10].
41 ## @table @code 41 ## @table @code
42 ## @item "AM" strength of ambient light 42 ## @item "AM" strength of ambient light
43 ## 43 ##
44 ## @item "D" strength of diffuse reflection 44 ## @item "D" strength of diffuse reflection
45 ## 45 ##
46 ## @item "SP" strength of specular reflection 46 ## @item "SP" strength of specular reflection
47 ## 47 ##
48 ## @item "EXP" specular exponent 48 ## @item "EXP" specular exponent
49 ## @end table 49 ## @end table
50 ## 50 ##
51 ## The default lighting mode "cdata", changes the cdata property to give the 51 ## The default lighting mode "cdata", changes the cdata property to give the
52 ## impression 52 ## impression
53 ## of a lighted surface. Please note: the alternative "light" mode, which 53 ## of a lighted surface. Please note: the alternative "light" mode, which
54 ## creates a light 54 ## creates a light
55 ## object to illuminate the surface is not implemented (yet). 55 ## object to illuminate the surface is not implemented (yet).
96 ## Check for reflection properties argument. 96 ## Check for reflection properties argument.
97 ## 97 ##
98 ## r = [ambient light strength, 98 ## r = [ambient light strength,
99 ## diffuse reflection strength, 99 ## diffuse reflection strength,
100 ## specular reflection strength, 100 ## specular reflection strength,
101 ## specular shine] 101 ## specular shine]
102 if (length (varargin{end}) == 4 && isnumeric (varargin{end})) 102 if (length (varargin{end}) == 4 && isnumeric (varargin{end}))
103 r = varargin{end}; 103 r = varargin{end};
104 varargin(end) = []; 104 varargin(end) = [];
105 else 105 else
106 ## Default values. 106 ## Default values.
120 [lv(1), lv(2), lv(3)] = sph2cart ((lastarg(1) - 90) * pi/180, lastarg(2) * pi/180, 1.0); 120 [lv(1), lv(2), lv(3)] = sph2cart ((lastarg(1) - 90) * pi/180, lastarg(2) * pi/180, 1.0);
121 varargin(end) = []; 121 varargin(end) = [];
122 have_lv = true; 122 have_lv = true;
123 endif 123 endif
124 endif 124 endif
125 125
126 tmp = surface (varargin{:}); 126 tmp = surface (varargin{:});
127 if (! ishold ()) 127 if (! ishold ())
128 set (h, "view", [-37.5, 30], 128 set (h, "view", [-37.5, 30],
129 "xgrid", "on", "ygrid", "on", "zgrid", "on", "clim", [0 1]); 129 "xgrid", "on", "ygrid", "on", "zgrid", "on", "clim", [0 1]);
130 endif 130 endif
158 cdata = (r(1) * ones (nr, nc) 158 cdata = (r(1) * ones (nr, nc)
159 + r(2) * diffuse (vn(:,:,1), vn(:,:,2), vn(:,:,3), lv) 159 + r(2) * diffuse (vn(:,:,1), vn(:,:,2), vn(:,:,3), lv)
160 + r(3) * specular (vn(:,:,1), vn(:,:,2), vn(:,:,3), lv, vv, r(4))); 160 + r(3) * specular (vn(:,:,1), vn(:,:,2), vn(:,:,3), lv, vv, r(4)));
161 161
162 set (tmp, "cdata", cdata ./ sum (r(1:3))); 162 set (tmp, "cdata", cdata ./ sum (r(1:3)));
163 163
164 unwind_protect_cleanup 164 unwind_protect_cleanup
165 axes (oldh); 165 axes (oldh);
166 end_unwind_protect 166 end_unwind_protect
167 167
168 if (nargout > 0) 168 if (nargout > 0)