diff options
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/affine/hemisphere_s.m')
-rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/affine/hemisphere_s.m | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/hemisphere_s.m b/SD-VBS/common/toolbox/toolbox_basic/affine/hemisphere_s.m new file mode 100755 index 0000000..5300183 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/hemisphere_s.m | |||
@@ -0,0 +1,27 @@ | |||
1 | function [x,y,z] = hemisphere(r) | ||
2 | %HEMISPHERE Generate sphere and transform from spherical coordinates. | ||
3 | % | ||
4 | % [X,Y,Z] = HEMISPHERE(N) generates three (n+1)-by-(n+1) | ||
5 | % matrices so that SURF(X,Y,Z) produces a sphere. | ||
6 | % | ||
7 | % [X,Y,Z] = HEMISPHERE(R,N) generates three (n+1)-by-(n+1) | ||
8 | % matrices so that SURF(X,Y,Z,R) produces a sphere colored by R | ||
9 | % | ||
10 | % [X,Y,Z] = HEMISPHERE(R,THETA,PHI) converts from spherical coordinates | ||
11 | % to cartesian coordinates. | ||
12 | |||
13 | % Modified from | ||
14 | % Clay M. Thompson 4-24-91 | ||
15 | % Copyright (c) 1991-92 by the MathWorks, Inc. | ||
16 | % by Carlo Tomasi | ||
17 | |||
18 | error(nargchk(1,3,nargin)); | ||
19 | |||
20 | n = r; | ||
21 | % 0 <= theta <= 2*pi and 0 <= phi <= pi/2 | ||
22 | [theta,phi] = meshgrid((pi/n/2)*[-n:2:n],(pi/2/n)*[-n:2:n]); | ||
23 | r = ones(n+1,n+1); | ||
24 | |||
25 | x = r .* cos(phi) .* sin(theta); | ||
26 | y = r .* sin(phi); | ||
27 | z = r .* cos(phi) .* cos(theta).*phi.*theta; | ||