forked from wspr/hatze-biomech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_elliptic_paraboloid.m
44 lines (37 loc) · 1012 Bytes
/
plot_elliptic_paraboloid.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
function plot_elliptic_paraboloid(origin,ab,h,varargin)
p = inputParser;
p.addRequired('origin');
p.addRequired('ab');
p.addRequired('h');
p.addParamValue('rotate',[0 0 0]);
p.addParamValue('colour',[1 0 0]);
p.addParamValue('opacity',0.2);
p.addParamValue('edgeopacity',0.2);
p.addParamValue('N',20);
p.parse(origin,ab,h,varargin{:})
O = p.Results.origin;
ab = p.Results.ab;
h = p.Results.h;
R = p.Results.rotate;
N = p.Results.N;
if length(N) == 1
N = [N N];
end
if length(ab) == 1
a = ab; b = ab;
else
a = ab(1); b = ab(2);
end
nu = linspace(0,2*pi,N(1)); % row
u = linspace(0,h,N(2))'; % column
x = a*sqrt(u/h)*cos(nu);
y = b*sqrt(u/h)*sin(nu);
z = h-u*ones(1,N(1));
pos = rotation_matrix_zyx(R)*[x(:) y(:) z(:)]';
xx = reshape(pos(1,:),size(x,1),size(x,2));
yy = reshape(pos(2,:),size(y,1),size(y,2));
zz = reshape(pos(3,:),size(z,1),size(z,2));
surf(O(1)+xx,O(2)+yy,O(3)+zz,...
'facecolor',p.Results.colour,...
'facealpha',p.Results.opacity,...
'edgealpha',p.Results.edgeopacity)