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.

hfl=create_object(x,y,r,no)
function hfl=create_object(x,y,r,no)
global ha c
% create movable with mouse object
% ha - axes handler
% (x,y) - object position
% r - object radius
% c - object color
% no - object number


% draw marker as circle:
nr=12; % resolution
al=0:pi/nr:(2*pi-pi/nr);
xa=x+r*cos(al);
ya=y+r*sin(al);
hfl=fill(xa,ya,c,'parent',ha);

% what to do if ckicked:
set(hfl,'ButtonDownFcn',['bdf(' num2str(hfl,'%20.20f') ')']);

set(hfl,'Userdata',no); % memorize number


Contact us at files@mathworks.com