-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplotCamera.m
More file actions
50 lines (43 loc) · 1.71 KB
/
Copy pathplotCamera.m
File metadata and controls
50 lines (43 loc) · 1.71 KB
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
function hc = plotCamera(P,fast,model,num,fc,scale,showtext,ec)
if nargin<8, ec = 'k'; end
if nargin<7, showtext = 0; end
if nargin<6, scale = 0.05; end
if nargin<5, fc = []; end
if nargin<4, num = []; end
if nargin<3, model = 0; end
if nargin<2, fast = 0; end
if fast, ec = fc; fc = 'none'; end
if model==0
vertices = [-1 -1 1; 1 -1 1; 1 1 1; -1 1 1; -1 1 -1; 1 1 -1; 1 -1 -1;
-1 -1 -1; -1 1 -3; 1 1 -3; 1 -1 -3; -1 -1 -3; 0 0 0; -0.5 1 1;
0.5 1 1; 0.5 1 -1; -0.5 1 -1; -0.5 2 0; 0.5 2 0]*scale;
faces = [1 2 3 4; 2 3 6 7; 3 4 5 6; 1 2 7 8;
1 4 5 8; 5 6 7 8; 9 10 13 13; 10 11 13 13;
11 12 13 13; 12 9 13 13; 14 15 19 18; 16 17 18 19;
15 16 19 19; 14 17 18 18];
elseif model==1
vertices = [-1 1 -3; 1 1 -3; 1 -1 -3; -1 -1 -3; 0 0 0; 0 1.5 0]*scale;
faces = [1 2 3 4; 1 2 5 5; 3 4 5 5; 1 4 5 5; 2 3 5 5; 5 5 6 6];
% faces = [1 2 3; 1 3 4; 1 2 5; 3 4 5; 1 4 5; 2 3 5; 5 5 6]; % Asymptote only handles triangles (now fixed in exporter)
elseif model==2
vertices = [-1 1 -3; 1 1 -3; 1 -1 -3; -1 -1 -3; 0 0 0; 0 1.5 0; 0 0 -3]*scale;
faces = [1 2 3 4; 5 5 6 6; 7 7 5 5];
else
vertices = [0 0 0; 0 1.5 0; 0 0 -3]*scale;
faces = [1 1 2 2; 1 1 3 3];
end
flip = [1 0 0; 0 -1 0; 0 0 -1];
Pt = [P(:,1:3)' -P(:,1:3)'*P(:,4)];
tvert = Pt*[flip*vertices'; ones(1,size(vertices,1))];
color = [repmat([0 0.2 0.8],8,1); repmat([0.4 1 0.6],5,1); repmat([1 0.6 0],6,1)];
color = color(1:size(vertices,1),:);
if isempty(fc)
hc = patch('Vertices',tvert(1:3,:)','Faces',faces,'FaceVertexCData',color);
shading faceted;
else
hc = patch('Vertices',tvert(1:3,:)','Faces',faces,'FaceColor',fc,'EdgeColor',ec);
end
if showtext
tp = Pt*[0 -2.5*scale 0 1]';
text(tp(1),tp(2),tp(3),num2str(num),'Background',[1 1 1],'FontSize',8);
end