Code:

function LemniscateClock(StartTime,Duration,DoRender)
% LemniscateClock(StartTime,Duration,Render)
% Plots 3 Lemniscates (hour, min, sec)
% at StartTime in minutes
% for Duration in minutes
% DoRender == 1 does render to animated GIF
% -- Author ---
% Marc falkao Falk, Entropia Universe
%lemnisacte param
a=1; %scale parameter for Lemniscate, not used atm
l = 2*a*5.2441; %circumference std lemniscate
t = 0:.01:2*pi; %time vector
%timers
d = 24; %total hours
tim = d; %multiplier for min
tis = d*60; %multiplier for sec
%simple param handling
if nargin < 1
StartTime = 0; %00:00
Duration = 10; %6 min
DoRender = 0; %render off
end
if nargin == 1
StartTime = 2*pi/d/60 * StartTime;
Duration = 10;
DoRender = 0;
end
if nargin == 2
StartTime = 2*pi/d/60 * StartTime;
Duration = 60 / Duration;
DoRender = 0;
end
%define axis
ax = axes('XLim',[-4 4],'YLim',[-4 4]);
axis equal
%== Clock ==
hc = rectangle('Position',[-sqrt(2)*a,-sqrt(2)*a,2*sqrt(2)*a,2*sqrt(2)*a],'Curvature',[1,1]);
hold on
% Plot the numbers 1-12 on the screen
% --Declare variables to be used in the plotting the clock numbers
Clk_fSize = 12; % controls the font size of the numbers of the clock
Clk_fTheta = ((d-4)*pi/d/2:-2*pi/d:-3/2*pi)'; % sets the Theta for each number position, goes from pi/2 to -3/2pi
Clk_fRad = sqrt(2)*a+.3; % sets the Raduis for each number position
Clk_numbas = (1:1:d)';
Clk_nData = [Clk_fRad*cos(Clk_fTheta) Clk_fRad*sin(Clk_fTheta) Clk_numbas];
text(Clk_nData(:,1),Clk_nData(:,2),num2str(Clk_nData(:,3)),...
'horizontalAlignment','center','verticalAlignment','middle','FontSize',Clk_fSize);
%== Tic Marks
% Define the Length of the Tic marks
TLenStart = sqrt(2)*a-.1; % Start of the Tick mark (distance from origin)
TLenStop = sqrt(2)*a; % End of the Tick mark (distance from origin)
[STX,STY,TTX,TTY] = ticMark(TLenStart,TLenStop);
% Plot Skinny and Thick Tick marks on the clock face
plot(TTX,TTY, 'linewidth',2,'color','k');
%hour marker
hh = plot([-sqrt(2)*a,-sqrt(2)*a-.1],[0,0], 'linewidth',2,'color','b');
%== Leminscate ==
h = plot(sqrt(2)*a*cos(t)./(1+sin(t).^2),2*pi/d*sqrt(2)*a*cos(t).*sin(t)./(1+sin(t).^2));
axis(a*[-2.2 2.2 -2.2 2.2])
hold off
%transforms
th = hgtransform('Parent',ax);
thc = hgtransform('Parent',ax); %circle
tm = hgtransform('Parent',th);
ts = hgtransform('Parent',th);
set(get(ax,'Parent'),'Renderer','opengl','DoubleBuffer','on')
set(h,'Parent',th); %Hour Lamnisacte
set(hc,'Parent',thc); %circle
set(hh,'Parent',th); %hour marker
hm = copyobj(h,tm);copyobj(hh,tm); %Min Lamnisacte
hs = copyobj(h,ts);copyobj(hh,ts); %Sec Lamnisacte
set(h,'Color','k');
set(hm,'Color','b');
set(hs,'Color','r');
Sxy = makehgtform('scale',[1 2*pi/d*sqrt(2)*a 1]);
Rz = makehgtform('zrotate',pi/2+StartTime); %Start at 0 hour+ StartTime
set(th,'Matrix',Rz)
drawnow;
if DoRender == 1
M = getframe;
map = [0 0 0;.8 .8 .8; 1 0 0; 0 0 1; 1 1 1];
im(:,:,1,1) = rgb2ind(M.cdata,map,'nodither');
end
%end part1 insert part 2 thereafter to complete the m-file
%part 2
%animation
i = 2;
for r = pi/2+StartTime:.0001:pi/2+StartTime+2*pi/d/Duration
% Form z-axis rotation matrix
Rz = makehgtform('zrotate',-r);
Rzm = makehgtform('zrotate',-r*tim);
Rzs = makehgtform('zrotate',-r*tis);
rm = (r -pi/2) * tim + pi/2;
Txym = makehgtform('translate',sqrt(2)*a*[cos(rm)./(1+sin(rm).^2) 2*pi/d*cos(rm).*sin(rm)./(1+sin(rm).^2) 0]);
rs = (r -pi/2) * tis + pi/2;
Txys = makehgtform('translate',sqrt(2)*a*[cos(rs)/(1+sin(rs).^2) 2*pi/d*cos(rs).*sin(rs)./(1+sin(rs).^2) 0]);
% Set transforms for both hgtransform objects
set(th,'Matrix',Rz)
%with rotation
set(tm,'Matrix',Txym*Rzm*eye(4))
set(ts,'Matrix',Txys*Rzs*eye(4))
drawnow,%pause(.1)
if DoRender == 1
M = getframe;
im(:,:,1,i) = rgb2ind(M.cdata,map,'nodither');
end
i = i + 1;
end
if DoRender == 1
imwrite(im,map,'LemniscateClock_tmp.gif','DelayTime',0,'LoopCount',inf)
end
function [STX,STY,TTX,TTY] = ticMark(TLenStart,TLenStop)
%ticMark is given the distance from center to start the tick
% marks (TLenStart) and the distance from origin to stop the
% tick marks (TLenStop).
%STTTheta 60 point array going clockwise skinny ticmarks
STTheta = ((d-4)*pi/d/2:-2*pi/d/60:-3/2*pi);
%Calculates X Y coordinates for all 60 skinny tick marks
STX = [TLenStart*cos(STTheta') TLenStop*cos(STTheta')]';
STY = [TLenStart*sin(STTheta') TLenStop*sin(STTheta')]';
%TTTheta 12 point array going around clockwise thick tic marks
TTTheta = ((d-4)*pi/d/2:-2*pi/d:-3/2*pi);
%Calculates X Y coordinates for all 12 thick tic marks
TTX = [TLenStart*cos(TTTheta') TLenStop*cos(TTTheta')]';
TTY = [TLenStart*sin(TTTheta') TLenStop*sin(TTTheta')]';
end %end ticmark function
end %main function