1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| function pushbutton1_Callback(hObject, eventdata, handles)
%pour afficher la droite :
hold on
axes(handles.axes2);
AxMain = axes('XLim', [0,10]);
%pour afficher la courbe vibratoire:
load dat
global Z;
Fe=48000;
dt=1/Fe;
time=0:dt:dt*length(data)-dt;
axes(handles.axes2);
plot(time,data)
%pour afficher l'outil
world = vrworld('assembly.wrl');
open(world);
fig = view(world, '-internal');
vrdrawnow;
get(world);
nodes(world);
car = vrnode(world, 'piece');
fields(car);
world = vrworld('assembly.wrl');
open(world);
fig = view(world, '-internal');
vrdrawnow;
get(world);
nodes(world);
car = vrnode(world, 'piece');
fields(car);
% for i=0:2*3.14*10
% car.rotation = [0 0 1 i*0.1];
% vrdrawnow;
% V_A=pause(0.01);
% end
x_pos=0.1;
y1=0;
y2=0.3;
hLine=line([x_pos x_pos],[y1 y2] ,'Color','b','Parent',AxMain)
z1 = 0:40;
x1 = 0 + zeros(size(z1));
y1 = 0 + zeros(size(z1));
x2 = 0:40;
z2 = 0.4 + zeros(size(x2));
y2 = 0 + zeros(size(x2));
y3 = 0:40;
x3 = 0.4 + zeros(size(y3));
z3 = 0.4 + zeros(size(y3));
for i=1:length(x1)
car.translation = [x1(i) y1(i) .01.*z1(i)];
vrdrawnow;
x_pos = x_pos +(0.001*i);
set(hLine, 'XData', [x_pos x_pos]);
drawnow;
Z(i)=.01.*z1(i);
pause(0.001);
set(handles.edit7,'string',num2str(Z(i)))
end
for i=1:length(x2)
car.translation = [ -.01*x2(i) y2(i) z2(i)];
vrdrawnow;
% X(i,1:3)=car.translation;
x_pos = x_pos +(0.001*i);
set(hLine, 'XData', [x_pos x_pos]);
drawnow;
X(i)=-.01*x2(i);
pause(0.001);
set(handles.edit5,'string',num2str(-1*X(i)))
end |