forked from s-kajita/IntroductionToHumanoidRobotics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakeRigidBody.m
More file actions
25 lines (24 loc) · 795 Bytes
/
MakeRigidBody.m
File metadata and controls
25 lines (24 loc) · 795 Bytes
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
function MakeRigidBody(j, wdh, mass)
global uLINK
uLINK(j).m = mass; % 質量
uLINK(j).c = [0 0 0]'; % 重心
uLINK(j).I = [1/12*(wdh(2)^2 + wdh(3)^2) 0 0;...
0 1/12*(wdh(1)^2 + wdh(3)^2) 0;...
0 0 1/12*(wdh(1)^2 + wdh(2)^2)] * mass; % 慣性テンソル
uLINK(j).vertex = [
0 0 0;
0 wdh(2) 0;
wdh(1) wdh(2) 0;
wdh(1) 0 0;
0 0 wdh(3);
0 wdh(2) wdh(3);
wdh(1) wdh(2) wdh(3);
wdh(1) 0 wdh(3);
]'; % 頂点座標
for n=1:3
uLINK(j).vertex(n,:) = uLINK(j).vertex(n,:) - wdh(n)/2; % 原点を物体中心へ
end
uLINK(1).face = [
1 2 3 4; 2 6 7 3; 4 3 7 8;
1 5 8 4; 1 2 6 5; 5 6 7 8;
]'; % ポリゴン