function eknot
%   Realistic lighting in MATLAB 5 allows you to discern subtle
%  visual shape cues.
%
%  Here a tube is surrounding a three-dimensional knot.
% 
%  Filename: eknot.m

%   Yama Habibzai
%   Copyright (c) 1984-98 by The MathWorks, Inc. All Rights Reserved
%   $Revision: 1.6 $
%   $Date: 1997/11/21 19:39:03 $

figs = allchild(0);
figName = findobj(figs, 'Name', 'Knot');

if isempty(figName)
  load payload
  figurePos = getfgpos(400, 330);
  figurePos(1) = figurePos(1)+88;
  figurePos(2) = figurePos(2)+31;
  
  
  fig = figure('Position', figurePos,...
      'Color', [1 1 1],...
      'NumberTitle', 'off',...
      'Name', 'Knot',...
      'Tag', 'FrontImage',...
      'Resize', 'off');
  axes('Parent', fig, 'Position', [.02 .06 .95 .95]);
  
  frame = uicontrol('Units','pixels', ...
      'Position',[330 10 55 55], ...
      'BackGroundColor', [.7 .7 .7],...
      'Style','frame', ...
      'Tag','Frame1');
  
  push1 = uicontrol('Units','pixels', ...
      'Position',[335 15 45 20], ...
      'callback', 'close',...
      'String', 'Close',...
      'Tag','Pushbutton1');
  
  push1 = uicontrol('Units','pixels', ...
      'Position',[335 40 45 20], ...
      'callback', 'helpwin(help(''eknot''), ''Knot'');',...
      'String', 'Info',...
      'Tag','Pushbutton1');
  
  axis off
  s=surface('xda',atx, 'yda',aty, 'zdata',atz,...
      'EdgeColor','None', 'Clipping', 'off');
  ccylnrm(s)
  set(s, 'BackFaceLighting', 'lit', 'Vertexn', -get(s, 'vertexn'))
  set(s, 'CData', kron(ones(21,1), 1:61));
  l1=light('pos',[1 -2 1]);
  l2=light('pos',-[1 -2 1]);
  axis vis3d
  set(gca, 'DataAspectRatio', [1 1 1])
  shading interp; 
  lighting phong
  set(gca, 'CameraViewAngle', 7);
  axis([-5.2232    4.5125   -5.2232    4.5125   -5.2232    4.5125])
  colormap(hsv(180))
  view(130,30) 
  material([.25 .5 .9]) 
  set(l2, 'Position', [1 1 1]) 
end
