function sphz()
% SPHZ movsph move sphere demo
%
% To launch, simply type "sphz" in your command window.
% Alternatively, you can choose run from this editor window, or press F5.
%
% numandina@gmail.com
%
% create figure
figure('color',[1 1 1],'me','n','nu','off')
he=uicontrol('sty','e','ba','w','un','n','p',[.04 .1 .1 .05],'str','5 0');
hs=uicontrol('sty','e','ba','w','un','n','p',[.04 .25 .1 .05],'str',10);
uicontrol('sty','pu','ba','w','str','Go','ca',@go1)
uicontrol('sty','te','ba','w','str','X - Y','un','n','p',[.04 .16 .1 .05])
uicontrol('sty','te','ba','w','str','Speed','un','n','p',[.04 .3 .1 .05])
% create ground and adjust axis
hold on
grid on
axis([-5 5 -5 5 -5 5].*2)
axis square
aaa=[-5 -5 0;
5 -5 0;
5 5 0;
-5 5 0;
-5 -5 0;
5 -5 0;
5 5 0;
-5 5 0].*2;
b=[1 2 6 5;2 3 7 6;3 4 8 7;4 1 5 8;1 2 3 4;5 6 7 8];
patch('vertices',aaa,'faces',b,'edgecolor','w','facecolor',[.3 .3 .3],'facevertexalphadata',0.5,'facealpha','flat');
view(3)
rotate3d
xlabel('X')
ylabel('Y')
% create sphere
h=movsph(1,[0,0],[0,0],25,0);
% move sphere
function go1(varargin)
pt=str2num(get(he,'string')); %#ok
plot3(pt(1),pt(2),1,'k.')
deg=str2double(get(hs,'string'));
h=movsph(1,[rand,rand],pt,deg,0,h);
end
end