Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to make fluid biomotion walkers
Replies: 0

 YoYo Posts: 1 Registered: 8/17/13
How to make fluid biomotion walkers
Posted: Aug 17, 2013 7:29 AM

Hi,

I'm new here and I'm not sure if this is the right forum to post this but here goes.

I'm dealing with a code that displays biomotion point light walkers. However, I have a problem with its fluidity. It's not fluid. It makes a brief stop motion before re-starting its cycle. Can anyone help me on this?

Here is the full code:

(Btw, this code is written on Matlab version 7.6.0.324 (R2008a) using PsychToolbox 2.)
------------------------------------------------------------
clear all; clc; rand('state',sum(100*clock))
wptr = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

vecty=VectLeftY
vectx=VectLeftX
starty=StartLeftY
startx=StartLeftX

[NumFrames, NumDots, NumMovies] = size(vectx); % 20 12 50

%%%%%%%%%%%%%%%%%%%%%%

DotSz = 7;
DotColor = 0;
bkgdColor = 127;
stimRect = [0 0 1440 900];

% % % % % % % % % FrameX = 126;
% % % % % % % % % FrameY = 220;
FrameX = 158;
FrameY = 275;

% % % % % % % NumCycles = 7;
% % % % % % % StimPerBlock = 8;
NumCycles = 1 %3; %%%%%%%%%%%%%%%%%%%%% !!!!!!!!!!!!!!!!1 %%%%%%%%%%%%%%%%%%%%%%%%%
StimPerBlock = 4 %4;%%%%%%%%%%%%%%%%%%%%%%%%%%%% !!!!!!!!!!!!!!!!!!! %%%%%%%%%%%%%%%%%%%

ifi =120;
% ifi = 0.5;

%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
screen('CloseAll')

[w, wRect] = screen(wptr,'OpenWindow', bkgdColor,[],32);

screen(w, 'FillRect', bkgdColor, wRect);

[ctrx, ctry] = RectCenter(stimRect);
ctrShiftX = ctrx-FrameX/2;
ctrShiftY = ctry-FrameY/2;

fixRect = [0 0 11 11];
fixpt = screen(w, 'OpenOffscreenWindow', bkgdColor, fixRect);
screen(fixpt, 'DrawLine', 0, 0, 5, 10, 5);
screen(fixpt, 'DrawLine', 0, 5, 0, 5, 10);

for frame = 1:NumFrames
stimpt(frame) = screen(w, 'OpenOffscreenWindow', bkgdColor, stimRect);
screen('CopyWindow', fixpt, stimpt(frame), fixRect, CenterRect(fixRect, stimRect));
end %for frame

%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%

start = GetSecs;

screen(w, 'FillRect', bkgdColor, wRect);
HideCursor;
screen('CopyWindow', fixpt, w, fixRect, CenterRect(fixRect, wRect));

%shift offcenter slightly
%if StimType == 1 %!!!!!!!
posx = startx(1, :, pick)+900; %?? ?? ?? ?? ??
posy = starty(1, :, pick)+320; %?? ?? ?? ?? ??

posxRight = StartRightX(1, :, pick); %?? ?? ?? ?? ??
posyRight = StartRightY(1, :, pick);

%elseif StimType == 0 & (samediff ==0 | stim == 1)
%%%%%%%%%%%%%%%% !!!!!!!!!!!!!!!!!!!!!!

posx3 = posx+200;
posy3 = posy;

for cycle = 1:NumCycles*2
for stim = 1:StimPerBlock
trialStart = GetSecs;

% if (samediff ==0 | stim == 1), pick = 1

end

for frame = 1:NumFrames
for dot= 1:NumDots

left = posx2(dot) + VectRightX(frame, dot, pick);
top = posy2(dot) + VectRightY(frame, dot, pick);

left2=posx3(dot) + vectx(frame, dot, pick); %added 130613
top2=posy3(dot) + vecty(frame, dot, pick);

left1=posx(dot) + vectx(frame, dot, pick); %added 130613
top1=posy(dot) + vecty(frame, dot, pick); %added 130613

screen(stimpt(frame),'FillOval',DotColor, [left1 top1 left1+DotSz top1+DotSz]);%added 130613
screen(stimpt(frame),'FillOval',DotColor, [left2 top2 left2+DotSz top2+DotSz]);
screen(stimpt(frame),'FillOval',DotColor, [left top left+DotSz top+DotSz]);
end %for dot
end %for frame

for frame = 1:NumFrames
% screen(w,'WaitVBL', 1); % ?? ???? ??? ?????
screen(w,'WaitVBL', ifi); % biomotion ??
screen('CopyWindow',stimpt(frame),w,stimRect,CenterRect(stimRect, wRect)); % biomotion
% screen(stimpt(frame), 'FillRect', bkgdColor, stimRect); % ??? ??? ?? ????
% screen('CopyWindow', fixpt, stimpt(frame), fixRect, CenterRect(fixRect, stimRect));

end %for frame & biomotion

% end %for stim
end %for cycle

ended_session=GetSecs;
session_dur = ended_session - start

screen(w, 'FillRect', bkgdColor, stimRect);
screen('CopyWindow', fixpt, w, fixRect, CenterRect(fixRect, wRect));

%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%

for frame = 1:NumFrames
screen(stimpt(frame), 'Close')
end

screen('CloseAll')
% clear
-----------------------------------------------------------------------