1
+ function h_out = frustrum(R ,t ,h )
2
+ % Work in progress
3
+ %
4
+ % Author: Sergio Agostinho - sergio(dot)r(dot)agostinho(at)gmail(dot)com
5
+ % Date: Mar 2015
6
+ % Version: 0.9
7
+ % Repo: https://github.com/SergioRAgostinho/five_point_algorithm
8
+ % Feel free to provide feedback or contribute.
9
+
10
+ T = [R t ; zeros(1 ,3 ) 1 ];
11
+ R_view = [0 0 1 0 ; - 1 0 0 0 ; 0 - 1 0 0 ; 0 0 0 1 ];
12
+ frame = [1 0 0 0 ;
13
+ 0 1 0 0 ;
14
+ 0 0 1 0 ;
15
+ 1 1 1 1 ];
16
+
17
+
18
+ pts = R_view *(T \ frame );
19
+
20
+
21
+ if nargin > 2 && ishandle(h )
22
+ next_plot = get(h , ' NextPlot' );
23
+ set(h , ' NextPlot' , ' add' );
24
+
25
+ h_p = plot3(h , [pts(1 ,4 ) pts(1 ,1 )], [pts(2 ,4 ) pts(2 ,1 )], [pts(3 ,4 ) pts(3 ,1 )], ' r' , ...
26
+ [pts(1 ,4 ) pts(1 ,2 )], [pts(2 ,4 ) pts(2 ,2 )], [pts(3 ,4 ) pts(3 ,2 )], ' g' , ...
27
+ [pts(1 ,4 ) pts(1 ,3 )], [pts(2 ,4 ) pts(2 ,3 )], [pts(3 ,4 ) pts(3 ,3 )], ' b' );
28
+ set(h , ' NextPlot' , next_plot );
29
+ else
30
+ h_p = plot3([pts(1 ,4 ) pts(1 ,1 )], [pts(2 ,4 ) pts(2 ,1 )], [pts(3 ,4 ) pts(3 ,1 )], ' r' , ...
31
+ [pts(1 ,4 ) pts(1 ,2 )], [pts(2 ,4 ) pts(2 ,2 )], [pts(3 ,4 ) pts(3 ,2 )], ' g' , ...
32
+ [pts(1 ,4 ) pts(1 ,3 )], [pts(2 ,4 ) pts(2 ,3 )], [pts(3 ,4 ) pts(3 ,3 )], ' b' );
33
+ end
34
+
35
+ h_out = get(h_p(1 ), ' Parent' );
36
+
37
+ end
0 commit comments