mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
view_frustum.h
Go to the documentation of this file.
1 #ifndef MF_VIEW_FRUSTUM_H_
2 #define MF_VIEW_FRUSTUM_H_
3 
4 #include <utility>
5 #include <array>
6 #include "angle.h"
7 #include "../eigen.h"
9 #include "bounding_box.h"
10 // TODO bounding_box -> Eigen_alignedbox
11 
12 namespace mf {
13 
15 
18 class view_frustum {
19 public:
20  enum intersection {
24  };
25 
26  using edge = std::pair<Eigen_vec3, Eigen_vec3>;
27  using corners_array = std::array<Eigen_vec3, 8>;
28  using edges_array = std::array<edge, 12>;
29  using planes_array = std::array<Eigen_hyperplane3, 6>;
30 
31 protected:
32  view_frustum(const Eigen_mat4& mat, const depth_projection_parameters& dparam);
33  view_frustum() = delete;
34 
35  Eigen_mat4& matrix_() { return view_projection_transformation_.matrix(); }
36  const Eigen_mat4& matrix_() const { return view_projection_transformation_.matrix(); }
37 
38 private:
39  Eigen_projective3 view_projection_transformation_;
40  depth_projection_parameters depth_parameters_;
41 
42 public:
43  const Eigen_projective3& view_projection_transformation() const { return view_projection_transformation_; }
44  const depth_projection_parameters& depth_parameters() const { return depth_parameters_; }
45 
52 
53  planes_array planes() const;
54  corners_array corners() const;
55  edges_array edges() const;
56 
57  bool contains(const Eigen_vec3&, bool consider_z_planes = true) const;
58  intersection contains(const bounding_box&) const;
59  static intersection contains(const planes_array&, const bounding_box&);
60 
61  view_frustum transform(const Eigen_affine3&) const;
62 };
63 
64 }
65 
66 #endif
Parameters of Z to depth projection.
Definition: depth_projection_parameters.h:12
edges_array edges() const
Definition: view_frustum.cc:117
Definition: view_frustum.h:23
Eigen_hyperplane3 near_plane() const
Definition: view_frustum.cc:14
std::pair< Eigen_vec3, Eigen_vec3 > edge
Definition: view_frustum.h:26
const Eigen_mat4 & matrix_() const
Definition: view_frustum.h:36
bool contains(const Eigen_vec3 &, bool consider_z_planes=true) const
Definition: view_frustum.cc:141
Eigen::Transform< Eigen_scalar, 3, Eigen::Affine > Eigen_affine3
Definition: eigen.h:37
Eigen_hyperplane3 left_plane() const
Definition: view_frustum.cc:41
Eigen_hyperplane3 right_plane() const
Definition: view_frustum.cc:51
View frustum of a perspective camera.
Definition: view_frustum.h:18
corners_array corners() const
Definition: view_frustum.cc:93
std::array< Eigen_vec3, 8 > corners_array
Definition: view_frustum.h:27
Eigen_hyperplane3 top_plane() const
Definition: view_frustum.cc:71
std::array< edge, 12 > edges_array
Definition: view_frustum.h:28
Eigen_mat4 & matrix_()
Definition: view_frustum.h:35
view_frustum transform(const Eigen_affine3 &) const
Definition: view_frustum.cc:176
Eigen_hyperplane3 far_plane() const
Definition: view_frustum.cc:31
intersection
Definition: view_frustum.h:20
Eigen::Transform< Eigen_scalar, 3, Eigen::Projective > Eigen_projective3
Definition: eigen.h:40
planes_array planes() const
Definition: view_frustum.cc:81
Axis-aligned 3D cuboid bounding box.
Definition: bounding_box.h:16
const depth_projection_parameters & depth_parameters() const
Definition: view_frustum.h:44
Definition: view_frustum.h:22
Eigen_hyperplane3 bottom_plane() const
Definition: view_frustum.cc:61
view_frustum()=delete
Eigen::Hyperplane< Eigen_scalar, 3 > Eigen_hyperplane3
Definition: eigen.h:43
Eigen_mat< 3, 1 > Eigen_vec3
Definition: eigen.h:25
Definition: view_frustum.h:21
const Eigen_projective3 & view_projection_transformation() const
Definition: view_frustum.h:43
Eigen_mat< 4, 4 > Eigen_mat4
Definition: eigen.h:30
std::array< Eigen_hyperplane3, 6 > planes_array
Definition: view_frustum.h:29