-
Notifications
You must be signed in to change notification settings - Fork 0
/
L_TOOL3D.m
102 lines (84 loc) · 2.54 KB
/
L_TOOL3D.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
%% draw solid for end-effector according to H matrix and coordsys it represents
% Michal Komorowski, January 2013
function L_TOOL3D(a,l,H, coordsysName)
% end-effector:
% a - side length,
% l - end-effector length,
% H - position and orientation matrix,
% coordsysName - name of the coordsys attached
%% end-effectors arm
% PREPARATION
k = [0 0 1]';
% Vertex matrix
% helper notation
Vertices = [ a/4 a/4 0
-a/4 a/4 0
-a/4 -a/4 0
a/4 -a/4 0
a/4 a/4 0.5*l
-a/4 a/4 0.5*l
-a/4 -a/4 0.5*l
a/4 -a/4 0.5*l
];
% set position and orientation
Vertices = Vertices';
Vertices = H*[Vertices;ones(1,8)];
Vertices = Vertices(1:3,:)';
% matrix representing an order of joining vertices into faces
Faces = [ 1 2 6 5
2 3 7 6
3 4 8 7
4 1 5 8
1 2 3 4
5 6 7 8];
% color matrix
faceColor = [0.2 0.1 0]; % [R G B] range 0-1
colormat = [faceColor
faceColor
faceColor
faceColor
faceColor
faceColor
]; % color for each face
% DRAW solid
patch('Vertices',Vertices,'Faces',Faces,'FaceVertexCData',colormat,'FaceAlpha',0.5,'FaceColor','flat');
% FaceAlpha - 0 for transparent, 1 for opaque
%% end-effector's end
% PREPARATION
% Vertex matrix
% helper notation
Vertices = [ a/2 a/2 0.5*l
-a/2 a/2 0.5*l
-a/2 -a/2 0.5*l
a/2 -a/2 0.5*l
0 0 l
0 0 l
0 0 l
0 0 l
];
% set position and orientation
Vertices = Vertices';
Vertices = H*[Vertices;ones(1,8)];
Vertices = Vertices(1:3,:)';
% matrix representing an order of joining vertices into faces
Faces = [ 1 2 6 5
2 3 7 6
3 4 8 7
4 1 5 8
1 2 3 4
5 6 7 8];
% color matrix
faceColor = [0.5 0.1 0]; % [R G B] range 0-1
colormat = [faceColor
faceColor
faceColor
faceColor
faceColor
faceColor
]; % color for each face
% DRAW solid
patch('Vertices',Vertices,'Faces',Faces,'FaceVertexCData',colormat,'FaceAlpha',0.5,'FaceColor','flat');
% FaceAlpha - 0 for transparent, 1 for opaque
% end-effector coordsys
drawCoordsys(H*Trans(0,0,l),coordsysName);
end