forked from wspr/hatze-biomech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_trapzoidal_plate.m
36 lines (30 loc) · 938 Bytes
/
plot_trapzoidal_plate.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
function plot_trapzoidal_plate(O,b,c,l,h,varargin)
% origin is the *centre* of the trapezoid.
% Straight edges are along X and perpendicular to Z. Height is Y.
if nargin == 0
O = [0;0;0];
b = 1;
c = 2;
l = 3;
h = 0.5;
end
p = inputParser;
p.addParamValue('colour',[0.5 0 0.5]);
p.addParamValue('opacity',0.2);
p.addParamValue('edgeopacity',0.2);
p.addParamValue('rotate',[0 0 0]);
p.parse(varargin{:})
R = rotation_matrix_zyx(p.Results.rotate);
vertex_l = [O O O O]+R*transpose([b/2 0 l/2; -b/2 0 l/2; -c/2 0 -l/2; c/2 0 -l/2]);
vertex_h = [O O O O]+R*transpose([b/2 h l/2; -b/2 h l/2; -c/2 h -l/2; c/2 h -l/2]);
trapz.Vertices = [vertex_l, vertex_h]';
trapz.Faces = [1 2 3 4;
5 6 7 8;
1 2 6 5;
2 3 7 6;
1 4 8 5;
3 4 8 7];
patch(trapz,...
'facecolor',p.Results.colour,...
'facealpha',p.Results.opacity,...
'edgealpha',p.Results.edgeopacity)