Code covered by the BSD License  

Highlights from
throw body with mouse

image thumbnail
from throw body with mouse by Maxim Vedenyov
It throws body in gravitation. Initial velocity defined by pointer velocity.

ret_body
function ret_body
% return body
global xys vx vy xyh th hsm hlg hfl00 xa1 ya1
% reset hystory:
xys=[0;0];

update_in_main;
% update in small:
xa=xys(1,:)+xa1;
ya=xys(2,:)+ya1;
set(hfl00,'Xdata',xa,'Ydata',ya);
drawnow;

vx=0;
vy=0;

xyh=[];
th=[];
hlg=0; % hystory length

Contact us at files@mathworks.com