-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbikeride.m
73 lines (39 loc) · 1.23 KB
/
bikeride.m
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
world = vrworld('libertycity.wrl');% Create a World Object, with our world inside
open(world);% Open and View the World
fig = view(world, '-internal');% to view it internally and not from the browser
vrdrawnow;
get(world)
% Finding Nodes of the World
nodes(world)% gets all nodes in the virtual world
% Accessing VRML Nodes
car = vrnode(world, 'Human_and_bicycle');%access the bike node
% Viewing Fields of Nodes
fields(car) %responsible for translation and rotation(can move the bike by changing this fields)
% Moving the bike Node
x3 = 23:300; %1st road section
z3 = 26 + zeros(size(x3));
y3 = -60 + zeros(size(z3));
for i=1:length(x3) %1st straight stretch
car.translation = [x3(i) y3(i) z3(i)];
disp(i);
vrdrawnow;
pause(0.01);
end
car.rotation = [0, 1, 0 , 1];
%car.rotation = [-1, 1, 0 , 1];%make a proper left turn
vrdrawnow;
z1 = 26:200;
x1 = 300 + zeros(size(z1));
y1 = -60 + zeros(size(z1));
for j= 1:length(z1)
car.translation = [x1(j) y1(j) -z1(j)];
disp(j);
vrdrawnow;
pause(0.01);
end
reload(world); %resets the bike to its original
vrdrawnow;
% close(world);
% leave the world open
%clear ans car i x1 x2 x3 y1 y2 y3 z1 z2 z3
displayEndOfDemoMessage(mfilename)