-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuildBoat.asv
executable file
·65 lines (49 loc) · 1.77 KB
/
buildBoat.asv
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Creates boat model
% MEJ 6/2/11
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function model = buildBoat()
model.sail = buildSail();
model.hull = buildHull();
model.rudder = buildRudder();
function rudder = buildRudder()
%build at centre of rotation
cyl = UnitCylinder(2);
hinge = scale(translate(cyl,0,0,-1),0.02, 0.02, 0.05);
hinge.facecolor = [.5 .5 .5];
hinge.edgecolor = [.5 .5 .5];
flat.vertices = [0 0 0; 0.3 0 0; 0.3 0 -0.4; 0 0 -0.5];
flat.faces = [1 2 3 4];
flat.facecolor = [1 .86 .72];
rudder.model = translate(combine(hinge, flat), 4, 0, 0);
rudder.transVector = [4; 0; 0];
function sail = buildSail()
%build at centre of rotation
cyl = UnitCylinder(2);
mast = scale(translate(cyl,0,0,1),0.05,0.05,1.6);
mast.facecolor = [.5 .5 .5];
mast.edgecolor = [.5 .5 .5];
boom = translate(rotateY(scale(cyl,0.02,0.02,1),-90),1.05,0,0.2);
boom.facecolor = [.5 .5 .5];
boom.edgecolor = [.5 .5 .5];
sheet.vertices = [0 0 0; 0 0 1; 1 0 0];
sheet.faces = [1 2 3];
sheet = translate(scale(sheet,2,1,2.8),0.05,0,0.2);
sheet.facecolor = [.7 .7 .2];
sheet.edgecolor = 'black';
sail.model = translate(combine(mast,boom,sheet),1,0,0);
sail.transVector = [;0;0];
function hull = buildHull()
model.vertices = [0.5 -0.4 -0.4; ...
0 -0.5 0; ...
0 0.5 0; ...
0.5 0.4 -0.4; ...
3.8 0.4 -0.4; ...
4 0.5 0; ...
4 -0.5 0; ...
3.8 -0.4 -0.4 ];
model.faces = [1 2 3 4; 3 4 5 6; 5 6 7 8; 1 2 7 8; 1 4 5 8; 2 3 6 7];
model.facecolor = 'red';
model.edgecolor = 'black';
hull.model = translate(model, -2,0,0);
hull.transVector = [0;0;0];