-
Notifications
You must be signed in to change notification settings - Fork 0
/
Disc.m
36 lines (28 loc) · 868 Bytes
/
Disc.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
classdef Disc < Shape
properties
Radius
end
methods
function obj = Disc(r, varargin)
obj@Shape(varargin{:});
obj.Radius = r;
t = 0:0.01:2*pi;
obj.Vertices = r*[cos(t); sin(t)];
end
function J = inertia(obj)
J = obj.Mass * obj.Radius^2/2;
end
function params = collisionParams(obj)
params = [obj.Radius 1];
end
function bb = boundingBox(obj, parent_tf)
if nargin < 2
parent_tf = eye(4);
end
tform = parent_tf * obj.Transform;
[R, p] = FreeBodyDiagram.tform2Rp(tform);
bb = [p(1) - obj.Radius, p(1) + obj.Radius, ...
p(2) - obj.Radius, p(2) + obj.Radius];
end
end
end