I'm trying to write a code using matlab that emulates a laser pointer in a way that my cat will enjoy chasing it on the screen. This is what I've done so far:
figure('menubar','none','color','k')
h = plot(0,'r.','MarkerSize',20);
xlim([-1 1]); ylim([-1 1])
axis off
phi1=(1+sqrt(5))/2;
phi2=sqrt(3);
step= 0.0001; % change according to machine speed
for t=0:step:100
set(h,'xdata',sin(t+phi1*t),'ydata',cos(phi2*t))
drawnow
end
The "issues" with this code are the following:
the pointer moves more or less at a constant speed and doesn't slow to a near stop and then unexpectedly proceed.
The trajectory is somewhat repeating itself, though I tried to make it using irrational numbers, the overall motions is continuous from right to left. I think a sharper trajectory change will help.
I know this is not a traditional programming question but still I want to solve a programming issue. I'd appreciate your help and of course open to new ways to answer my question that doesn't use the code I added.
set(gcf,'Position',get(0,'Screensize'));
orset(gcf,'Units','Normalized','OuterPosition',[0 0 1 1]);
. – Ammonssign
variable to create a discontinuous trajectory via sign flips, and also add a slow random step size modification that will change the effective speed of the pointer... – Halfhour