I am trying to write code using matlab that emulates a laser pointer so that my cat enjoys chasing it on the screen. This is what I have 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 "problems" with this code are as follows:
the pointer moves more or less at a constant speed and does not slow down to the nearest stop, and then continues unexpectedly.
The trajectory repeats somewhat, although I tried to do this using irrational numbers, the general movements are continuous from right to left. I think a sharper change in trajectory will help.
I know this is not a traditional programming issue, but still I want to solve the programming problem. I would appreciate your help and, of course, opened up to new ways to answer my question, which does not use the code that I added.
matlab motion game-physics
user2383329
source share